XxOsurfer3xX

09-30-2013, 02:49 AM

I'm trying to raycast GL_POINTS on a fragment shader, so I can draw them with an orientation given by a normal vector.

Right now I have this code on my fragment shader:

float x = gl_FragCoord.x;

float y = gl_FragCoord.y;

vec3 qn = vec3(x * 2 * right / width - right, y * 2 * top / height - top, -0.001);

float denom = dot(qn,filteredN);

if (denom == 0.0) discard;

float t = numer / denom;

vec3 q = vec3(t * qn.x, t * qn.y, t * qn.z);

vec3 dist = q - vertex_pos_cam.xyz;

float sq = dist.x * dist.x + dist.y * dist.y + dist.z * dist.z;

if (sq > size*size) discard;

I am trying to compute the ray-point intersection in eye space. The problem is that I cannot get the vector qn right (the direction of the ray), so points appear as squares. 0.001 is my near plane, right, top are my frustum parameters and width and height are the viewport parameters. Am I missing something?

Right now I have this code on my fragment shader:

float x = gl_FragCoord.x;

float y = gl_FragCoord.y;

vec3 qn = vec3(x * 2 * right / width - right, y * 2 * top / height - top, -0.001);

float denom = dot(qn,filteredN);

if (denom == 0.0) discard;

float t = numer / denom;

vec3 q = vec3(t * qn.x, t * qn.y, t * qn.z);

vec3 dist = q - vertex_pos_cam.xyz;

float sq = dist.x * dist.x + dist.y * dist.y + dist.z * dist.z;

if (sq > size*size) discard;

I am trying to compute the ray-point intersection in eye space. The problem is that I cannot get the vector qn right (the direction of the ray), so points appear as squares. 0.001 is my near plane, right, top are my frustum parameters and width and height are the viewport parameters. Am I missing something?