#How to draw a simple circle around multiple objects in GLSL ES?

1 messages · Page 1 of 1 (latest)

frozen wadi
#

send an array of points to the shader

#

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
];```
candid gale
#

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

frozen wadi
#

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;
  }
}```
candid gale
#

huh... alright. ill test a bit and see if it works!

candid gale
#

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 🤔

frozen wadi
#

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

candid gale
#

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.

frozen wadi
#

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

candid gale
#

uhm. Not quite sure if i understand. So i tried to apply it the way i understood it.

gritty crow
#

It's a max in the shader. 'gl_fragcolour = max(light1, light2);'

candid gale
#

aaah... but im kinda confused. What values are light1 and 2 supposed to be?

gritty crow
#

for you Im guessing the dis

#

lights[i]