# Camera can't find my geo after geo shader transform

Hi,

this is might be a silly mistake on my part. I was following the exploding geometry tutorial on learningopengl using the Geometry Shader. But after implementing their code, the resulting geometry just kinda disappeared from my camera, YET I can see it in my geo.

When I use the geometry viewer, I can’t seem to zoom out enough to see more. Very confused.

Lastly, I was wondering, is there a difference between gl_in[i].gl_Position and iVert[i].worldSpacePos? From the glsl code generated by Phong, they seem to be both in World Space.

Thank you.
GS_Exp.toe (8.73 KB)

Hi there,

The gl_in[i].gl_Position in the geometry shader is indeed the same as the worldSpacePos. The pixel shader needs a gl_position in projection-space. Normally this is done in the vertex shader, but when including a geometry shader in TD, the worldspacepos is send to the geometry shader and the convertion to screenspace is done there (using the TDWorldToProj).

It gets a bit confusing if this doesnt go well. Such like the problem you have now. Geometry seems to be uneffected by the position of the camera. Like you said, zooming in and out doesnt seem to change the viewer. This means the transformation to projection space is not going well.

The reason for this is that in your explode() function you return a vec4 with the 4th attribute to 0. This needs to be 1.0. When TDWorldToProj transforms your worldspace pos to projection space, it multiplies a 4x4 matrix. In other to also transform the point according this matrix, the 4th element should be 1 (else it wont multiply by the transform part of the matrix).

If this sounds gibberish to you, I advice you to look into matrix multiplications. (since my explaination is gibberish )

So in other words, to fix your problem change line 37 into:
return vec4(pos + direction, 1.0);

Hope this helps.
Cheers,
Tim

Thank you!!

That did indeed fix it. Your explanation makes perfect sense, no gibberish found

Yes, I know that 4th value is suppose to the w. I just didn’t think it had a function. I have always thought it was just straggler data.