I am having difficulty passing the depth texture of the rendered scene into the rendering of an ocean (in a separate pass).
How exactly would one go about this?
This is what the compositor looks like:
Code: Select all
compositor_node OsirisRenderingNode
{
in 0 rt_renderwindow
texture depthTexture target_width target_height PFG_D32_FLOAT
texture rtt01 target_width target_height target_format
rtv rtt01
{
depth_stencil depthTexture
}
target rtt01
{
pass render_scene //Normal scene
{
load
{
all clear
clear_colour 0.2 0.4 0.6 1
}
store
{
colour store_or_resolve
depth store
stencil dont_care
}
rq_first 0
rq_last 239
shadows Tutorial_TerrainShadowNode
}
}
texture rtt_final target_width target_height target_format msaa_auto
rtv rtt_final
{
depth_stencil depthTexture
}
target rtt_final
{
pass texture_copy
{
in rtt01
out rtt_final
profiling_id "Copy / Clone rtt01"
}
pass render_scene //Ocean
{
load
{
all load
}
store
{
colour store_or_resolve
depth dont_care
stencil dont_care
}
rq_first 240
rq_last 249
input 0 depthTexture
}
}
target rt_renderwindow
{
//Output to window
pass render_quad
{
load { all dont_care }
material Ogre/Copy/4xFP32
input 0 rtt_final
profiling_id "Copy to Window"
}
pass render_scene
{
camera ui_camera
rq_first 250
rq_last 255
}
}
}
And this is how the pixel shader part looks:
Code: Select all
// START UNIFORM DECLARATION
vulkan_layout( ogre_t0 ) uniform texture2D depthTexture; //<<<this one
vulkan( layout( ogre_s0 ) uniform sampler depthTextureSampler ); //<<<that one
vulkan_layout( ogre_t@value(heightMap) ) uniform texture2D heightMap;
vulkan_layout( ogre_t@value(terrainData) ) uniform texture3D terrainData;
vulkan_layout( ogre_t@value(blendMap) ) uniform texture2D blendMap;
@insertpiece( custom_ps_uniformDeclaration )
// END UNIFORM DECLARATION
(and further down)
Code: Select all
rshort2 iFragCoord = rshort2( gl_FragCoord.x, gl_FragCoord.y );
// float tTexDepth = texture( vkSampler2D( depthTexture, depthTextureSampler ), gl_FragCoord.xy/400 ).x;
float tTexDepth = 1 - OGRE_Load2DMS( depthTexture, iFragCoord.xy, 0 ).x;
outPs_colour0.xyz = vec3(tTexDepth,tTexDepth,tTexDepth);
I'm obviously doing something wrong, or I'm unable to pass the depth texture like one would do in the render_quad pass.
So how would one go about this, or what part am I missing?