namal.bambarasinghe_ Posted May 23, 2017 Share Posted May 23, 2017 I did this but doesn't seem to work for me. In the materail file, <texture name="deferred_depth" pass="post" type="procedural"/> And in the fragment shader, Texture2D s_texture_0 : register(t0); // depth float depth = getDeferredDepth(texture2DDeferredNorm(s_texture_0, s_sampler_0, IN.texcoord_0)); Link to comment
silent Posted May 23, 2017 Share Posted May 23, 2017 Hi Namal, What did you want to achieve by that? I mean what is the effect (maybe some real world one) that you are trying to implement and what the expected results?Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
namal.bambarasinghe_ Posted May 24, 2017 Author Share Posted May 24, 2017 Hi, As you can see in the attached screenshots, in Unigine 1 we used the depth value taken as above to mask out the interior of the vehilcle when we render the post processing windscreen effect. Without depth masking water drops form on the vehicle interior surfaces as well. I am upgrading the project from Unigine 1 to Unigine 2 and I need to know how to achieve the same effect (get the same depth value) in Unigine 2.4. Thank You Link to comment
fox Posted May 24, 2017 Share Posted May 24, 2017 Hi Namal, Could you provide us with a small test scene with your materials and shaders included so we can look into this issue and try to help you? Thanks! Link to comment
namal.bambarasinghe_ Posted May 25, 2017 Author Share Posted May 25, 2017 Hi, Attached a sample scene with a post processing shader to mask the interior using the values from "deferred_depth" texture. When the camera is inside the vehicle (and shader is enabled) all windscreens and windows are painted green because the depth value for the objects visible throw windows are greater than the constant defined in the fragment shader. This is the technique we used in Unigine 1. My question is how to achieve the same effect in Unigine 2.4? Thanks my_project.zip Link to comment
fox Posted May 26, 2017 Share Posted May 26, 2017 Hi Namal,I've converted Your scene to 2.4 and fixed material and shaders, please check them out (see the attachment).Hope this solves Your problem!Material: <material editable="0" name="ss_depth_mask"> <blend src="none" dest="none"/> <state name="procedural_width" type="switch" items="half_width,width">1</state> <state name="procedural_height" type="switch" items="half_height,height">1</state> <shader pass="post" defines="BASE_POST" vertex="indian_bus/shaders/vertex_ss_depth_mask.shader" fragment="indian_bus/shaders/fragment_ss_depth_mask.shader"/> <texture name="color" type="procedural" shader="all" unit="0" pass="post" filter="bilinear"/> <texture unit="1" type="opacity_depth" shader="all" pass="post" filter="bilinear"/> </material> Vertex shader: // Include the UUSL header #include <core/shaders/common/common.h> // Input data struct STRUCT(VERTEX_IN) INIT_ATTRIBUTE(float4,0,POSITION) // Vertex position INIT_ATTRIBUTE(float4,1,TEXCOORD0) // Vertex texcoords INIT_ATTRIBUTE(float4,2,COLOR0) // Vertex color END // Output data struct STRUCT(VERTEX_OUT) INIT_POSITION // Output projected position INIT_OUT(float2,0) // Texcoords (x and y only) END MAIN_BEGIN(VERTEX_OUT,VERTEX_IN) // Set output position OUT_POSITION = getPosition(IN_ATTRIBUTE(0)); OUT_DATA(0).xy = IN_ATTRIBUTE(1).xy; MAIN_END // end Fragment shader: // Include the UUSL fragment shader header #include <core/shaders/common/fragment.h> static const float MASK_DEPTH = 10.0f; // Define the color and depth textures of the scene INIT_TEXTURE(0,TEX_COLOR) INIT_TEXTURE(1,TEX_DEPTH) // Input values STRUCT(FRAGMENT_IN) INIT_POSITION // Projected position INIT_IN(float2,0) // Texcoords END MAIN_BEGIN(FRAGMENT_OUT,FRAGMENT_IN) // Get the UV float2 texcoord = IN_POSITION.xy * s_viewport.zw; // Get the scene color float4 scene_color = TEXTURE(TEX_COLOR,texcoord); // Get the linearized depth float scene_depth = getLinearizedDepth(TEXTURE_OUT(TEX_DEPTH),texcoord); // Apply depth mask if(scene_depth < MASK_DEPTH) OUT_COLOR = scene_color; else OUT_COLOR = float4(0, 1, 0, 1); MAIN_END // end Thanks! bus.zip Link to comment
namal.bambarasinghe_ Posted May 26, 2017 Author Share Posted May 26, 2017 Thanks for the solution. Tested and works as expected (although I can see some flickering near the edges). Is there any public documentation available on textures (such as 'opacity_depth') that can be used with these kinds of materials? Thanks Link to comment
fox Posted May 26, 2017 Share Posted May 26, 2017 Hi Namal, Happy to help You! Unfortunately the only information on textures currently available is in the Rendering sequence article and the list of textures in the Material class article, but we plan to update documentation on rendering and textures soon. Thanks! Link to comment
Recommended Posts