We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi team,
I have an issue regarding the updating of the colorfill when using a beginShape() / endShape() function.
I have a plane ( x & y grid) which has a colorfill that changes during time (updates). It doesnt update though. When i use random(255) it does change, though when using a variable it only takes the1st (or last). the colorgrid (static looks as such:
Do i need to include a command that allows updtating fill colors with changing values on the x-y grid. code with example of variable that changes the grid ( in real it will be an array with data for each gridpoint (vertex) that refreshes ech iteration):
void setup() { size(900, 700, P3D); //noStroke(); } void draw() { background(0); translate(width/4, height/1.2); int fillvariable= 0; for(int w=0; w< 400; w+= 25){ for(int h=0; h> -400; h-= 25){ beginShape(QUADS); normal(0, 0, 1); fill(w/2, h/2, 200); vertex(w, h); fill(fillvariable, h/2, 200); vertex(w+25, h); fill(w/2, h/2, 200); vertex(w+25, h-25); fill(w/2, h/2, 200); vertex(w, h-25); endShape(); fillvariable += 20; if( fillvariable >255) { fillvariable=0; } println(fillvariable); } } }
Is this way of filling a grid the smartest way (basically its making an colored isosurface)? Might be that this way takes much memory or cpu in the way its looping. I am trying to read into shaders and how + when to use them, but at the beginning of the gpu to cpu difference and how processing uses such.
Answers
Please also post the code which failed to work as expected. Also note the the correct way to format code is-
Dear L_o_t_Galaxy: Did my best to adjust it in the correct format. hope its readable in this way. warmest regards,
Dino
OK.
Did you mean to declare your fillvariable inside draw? If so, your code cannot be dynamic.
The variable itself is dynamically updated by a for loop that opens an array of data that will influence the color and make up the isosurface. I think the only way to do so is to hav ethem both in draw() .
Not yet sure how to solve this using another approach in order to achieve a dynamically update color.
What exactly was your question anyway?
Dear L_o_t_Galaxy.
The question : How can i upate the fill color data in a BeginShape() ......endShape() in which the pixels are colored by the local vertex points?
Secondly is there a better aproach (it might be the wrong way trying to color the pixels like this)
seems only a "random(255)" will dynamically change the values. The goal is to drive the fill() command by data comming from an array that changes each iteration.
warmest regards,
Dino
No, as long as your variable is dynamically changing, the color also changes. However, note that only one edge of the square is affected by the "Variable".
Dear L_o_t_Galaxy, It gave me the insight i needed , from here i can build further to include the array's.
much much apreciated
Yes, that's what I meant. And that's why I asked why you declared your variable in draw().