Hi,

I'm looking forward to simulate the multipath propagation process by rasterization on shaders. By using dynamic cubemaps, how can I collect the depth and normal data of reflected objects, instead of colors?

Follows below my current code:

Vertex Shader:
Code :
#version 130
 
uniform mat4 osg_ViewMatrixInverse;
uniform vec3 cameraPos;
 
void main() {
    gl_Position = ftransform();
    gl_TexCoord[0] = gl_MultiTexCoord0;
    mat4 ModelWorld4x4 = osg_ViewMatrixInverse * gl_ModelViewMatrix;
    mat3 ModelWorld3x3 = mat3( ModelWorld4x4 );
    vec4 WorldPos = ModelWorld4x4 *  gl_Vertex;
    vec3 N = normalize( ModelWorld3x3 * gl_Normal );
    vec3 E = normalize( WorldPos.xyz - cameraPos.xyz );
    gl_TexCoord[1].xyz = reflect( E, N );
}

Fragment Shader:
Code :
#version 130
 
uniform samplerCube cubeMap;
uniform sampler2D colorMap;
const float reflect_factor = 0.5;
 
void main (void)                                                            
{
    vec3 base_color = texture2D(colorMap, gl_TexCoord[0].xy).rgb;
    vec3 cube_color = textureCube(cubeMap, gl_TexCoord[1].xyz).rgb;
    gl_FragColor = vec4( mix(cube_color, base_color, reflect_factor).rgb, 1.0);
}