I’m a relative noob when it comes to shaders, and I’m coming up against a wall. I’m trying use a vertex shader to generate texture coordinates for a jit.gl.mesh that re-create OpenGL’s GL_SPHERE_MAP mode for a reflection effect. This would ideally mimic the behavior of OB3D’s tex_map attribute (@tex_map 2).
I have created a shader (attached) that I believe should be doing this. The code is essentially a direct copy of the source taken from the Orange Book and the Shadergen program. Unfortunately the shader does not work as expected – it appears that it’s referencing a single coordinate rather than map across the entire texture.
I’m hoping that someone with more shader experience can comment. Any insight would be greatly appreciated!
The only remaining difference between this shader and @tex_map 2 is that the shader appears to flip the texture along the y axis. I’m getting around this with jit.dimmap but I’m sure it could be done more efficiently in the shader itself.
Is my understanding correct that with @rectangle 0 jit.gl.texture coerces incoming rectangular matrices to be square?
I’m attaching the corrected code in case this is useful to anyone else. Now if only jit.gl.mesh supported multi-texturing I would be a very happy camper!