stereo / VR 3d cursor

Started by
0 comments, last by mrMatrix 5 years, 10 months ago

I have a stereo 3d application that needs a scene - depth 3d cursor. I found one single post talking about this while googling - from the year 2000 - about having a sphere represent the cursor. This sphere would slide along the objects of the scene according to their depth, getting the depth buffer from at the 2D cursor mouse pos then unprojecting to get position from depth. Then, he said he made that 3d pos be the center of the sphere.

This is my function for reconstructing pos from depth in the FRAG shader....I just dont know how to do it in the VERTEX shader so that the sphere actually moves to the location. Any help? I am using a deferred renderer, Maybe his solution works only with forward rendering? 


vec3 reconstructP(vec2 UV)
{
    vec4 vProjectedPos = vec4(1.f);
    vProjectedPos.rg = UV * 2.f - 1.f;
    vProjectedPos.b = texture(gBuf_DS, UV).r * 2.f - 1.f;
    vec4 vPositionVS = scene.PMinv * vProjectedPos;

    return vPositionVS.rgb / vPositionVS.a;
}

vec3 P_VS = reconstructP(v.uv);

 

This topic is closed to new replies.

Advertisement