#How to draw a simple circle around multiple objects in GLSL ES?
1 messages · Page 1 of 1 (latest)
specifically a flattened vec2 array. so index 0 is x1, index 1 is y1, index 2 is x2, index 3 is y2, etc etc
lights = [
0, 13,
69, 420,
666, 23
];```
ah i see. And how would i implement this in a shader?
i tried using a for loop for smth like that once and that ended up freezing the game
the shader would need to be set up like:
uniform vec2 points[3];
void main() {
for (int i = 0; i < 3; i++) {
float x = points[i].x;
float y = points[i].y;
}
}```
huh... alright. ill test a bit and see if it works!
Getting this. The obj's with no sprites are the points that are supposed to be drawn. here's the code and what the array looks like that is being inputted 🤔
that array of coordinates seems to be floats not room coordinates, are you normalizing those to be between 0 and 1? also youre comparing them to texture coordinates which are localized to whatever the shader is applied to
This is what i did with the array to make it a value of 0-1. Pretty sure this isnt the right way. Ah, that shader is being applied to a surface that just covers the room. I didn't think about that too much.
then that should be fine
the other thing to remember is that you are running this on every fragment, which means the final color of the pixel is based on its distance from all the points not just the current one
and your loop sets dis based on the current one
uhm. Not quite sure if i understand. So i tried to apply it the way i understood it.
It's a max in the shader. 'gl_fragcolour = max(light1, light2);'
aaah... but im kinda confused. What values are light1 and 2 supposed to be?