I am programming in 3d game, very need tangent to normal mapping and write depth info of scene to render target for shadow mapping.
Yeah, I didn’t find tangent variables in the shader. Would be very useful.
For depth you could use a separate render target or write depth to the alpha channel if you don’t need it.
Can you describe how to write depth to the alpha channel in detail ?
You calculate the distance from the camera and assign this value to the
.z component of the
gl_FragColor. In the very basic terms and fixed camera it could be as simple as
-- Vertex shader var_depth = (1.0 + gl_Position.z) * 1.5; -- Fragment shader gl_FragColor = vec4(color.rgb, var_depth);
I had it this way in one of my projects, you can change depth calculation to something more meaningful.
Can you share me some demo or example code ? I have tried several times but failed.