 # prxtxn

Member

5

0 Neutral

• Rank
Newbie

• Interests
Art
Programming

## Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

1. the function "halo" makes the calculation to generate that "glow" effect/ radial blur. it takes an origin point. mi attemp is to have a shader with multiples origin points. for that, pass an array of origin positions, as you can see in the pictures, the shader calculates the different origin points well, but for each loop, they keep generate the samples for the others points.
2. i need a way to avoid this extra calculations. i understand the problem, cos the fragment computes all the pixels on the screen, i want a way to avoid that. any clues?
3. thanks, i actually fix the problem of the coordinates, but now i have another problem. because i dont know how to avoid calculate the samples once that has been calculate. this is my problem, for each loop the function calculates the shader for each coordiantes, plus the others coordinates... this is what happens: notice howthe halo is compute well for each point, plus others iterations... any idea? this is the shader now: #version 150 in vec2 varyingtexcoord; uniform sampler2DRect tex0; uniform int size; float exposure = 0.79; float decay = 0.9; float density = .9; float weight = .1; int samples = 25; out vec4 fragColor; const int MAX_SAMPLES = 25; const int N = 3; uniform vec2 ligthPos [N]; int a = 1; vec4 halo(vec2 pos){ float illuminationDecay = 1.2; vec2 texCoord = varyingtexcoord; vec2 current = pos.xy; vec2 deltaTextCoord = texCoord - current; deltaTextCoord *= 1.0 / float(samples) * density; vec4 color = texture(tex0, texCoord); for(int i=0; i < MAX_SAMPLES; i++){ texCoord -= deltaTextCoord; vec4 sample = texture(tex0, texCoord); sample *= illuminationDecay * weight; color += sample; illuminationDecay *= decay; } return color; } void main(){ vec2 uv = varyingtexcoord; vec4 color = texture(tex0, uv); vec4 accum = vec4(0.0); for(int e = 0; e < N;e++){ vec2 current =ligthPos[e]; accum += halo(current); } fragColor = (accum) * exposure; }
4. #version 150 // these are for the programmable pipeline system and are passed in // by default from OpenFrameworks uniform mat4 modelViewMatrix; uniform mat4 projectionMatrix; uniform mat4 textureMatrix; uniform mat4 modelViewProjectionMatrix; in vec3 position; in vec4 color; in vec4 normal; in vec2 texcoord; vec4 temp; // this is the end of the default functionality // this is something we're creating for this shader out vec2 varyingtexcoord; // this is coming from our C++ code uniform float mouseX; void main() { // here we move the texture coordinates varyingtexcoord = vec2(texcoord.x, texcoord.y); // send the vertices to the fragment shader gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }