Horde3D

Next-Generation Graphics Engine
It is currently 03.12.2024, 19:54

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: 13.03.2013, 06:44 
Offline

Joined: 13.03.2013, 06:29
Posts: 2
hi
I need to do a simple task: render "static" (walls) and "dynamic" (chars) objects to separate buffers then compine them in my shader and draw quad

ive read alsmost whole forum, tried different tehniques but nothing is working which is sad bucause it should be simple

i know what by default depth buffers dont sharing between FBOs so i need to copy them first and write to gl_FragDepth. i also tried COPY_DEPTH hack from other pipelines with no success.

Attachment:
File comment: no depth in second pass
2013-03-13-092808_800x600_scrot.png
2013-03-13-092808_800x600_scrot.png [ 142.86 KiB | Viewed 55083 times ]


here's my pipeline:
Code:
<!-- Forward Shading Pipeline -->
<Pipeline>
        <Setup>
            <RenderTarget id="BUF0" depthBuf="true" numColBufs="1" format="RGBA8"  scale="1.0" maxSamples="4"/>   
            <RenderTarget id="BUF1" depthBuf="true" numColBufs="1" format="RGBA8"  scale="1.0" maxSamples="4"/>   
        </Setup>
   <CommandQueue>
      <Stage id="StaticPass" link="pipelines/globalSettings.material.xml">
                        <SwitchTarget target="BUF0" />
         <ClearTarget depthBuf="true" colBuf0="true" />
         
         <DrawGeometry context="AMBIENT" class="wall" />
         <DoForwardLightLoop class="wall" />
      </Stage>

      <Stage id="DynamicPass">
         <SwitchTarget target="BUF1" />
         <ClearTarget depthBuf="true" colBuf0="true" />

                        <!-- xxx doesnt work -->
                        <!-- Copy depth buffer to allow occlusion culling of lights -->
                        <!--
                        <BindBuffer sampler="depthBuf" sourceRT="BUF0" bufIndex="32" />
                        <DrawQuad material="materials/light.material.xml" context="COPY_DEPTH" />

                        <UnbindBuffers />
                        -->

         <DrawGeometry context="AMBIENT" class="dynamic" />
         <DoForwardLightLoop class="dynamic" />
      </Stage>

      <Stage id="Translucent">
         <DrawGeometry context="TRANSLUCENT" class="Translucent" order="BACK_TO_FRONT" />
      </Stage>

      <Stage id="TestPass">
         <SwitchTarget target="" />
                        <BindBuffer sampler="buf0" sourceRT="BUF0" bufIndex="0" />
                        <BindBuffer sampler="buf1" sourceRT="BUF1" bufIndex="0" />
                        <DrawQuad material="pipelines/testpass.material.xml" context="TESTPASS" />
         <UnbindBuffers />
      </Stage>

      <Stage id="Overlays">
         <DrawOverlays context="OVERLAY" />
      </Stage>
   </CommandQueue>
</Pipeline>


and shader
Code:
[[FX]]

// depth
sampler2D depthBuf = sampler_state
{
    Address = Clamp;
};
 
// walls
sampler2D buf0 = sampler_state
{
    Address = Clamp;
};

// dynamic
sampler2D buf1 = sampler_state
{
    Address = Clamp;
};

sampler2D fgtex = sampler_state
{
};
 
context TESTPASS
{
    VertexShader = compile GLSL VS_GENERAL;
    PixelShader = compile GLSL FS_GENERAL;
}

context COPY_DEPTH
{
    VertexShader = compile GLSL VS_FSQUAD;
    PixelShader = compile GLSL FS_COPY_DEPTH;
}
 
 
[[VS_GENERAL]]
 
#include "shaders/utilityLib/vertCommon.glsl"

uniform mat4 projMat;
attribute vec3 vertPos;
varying vec2 texCoords;
            
void main(void)
{
   texCoords = vertPos.xy;
   gl_Position = projMat * vec4( vertPos, 1 );
}

         
[[FS_GENERAL]]
 
uniform sampler2D buf0;
uniform sampler2D buf1;
uniform sampler2D fgtex;
varying vec4 pos, vsPos;
varying vec2 texCoords;

void main(void)
{
    vec4 tex0;
    vec4 tex1;
    vec4 tex2;
    vec4 P1;

    tex0 = texture2D(buf0, texCoords);
    tex1 = texture2D(fgtex, texCoords * vec2(1.0, -1.0));
    tex2 = texture2D(buf1, texCoords);

    P1 = tex0 * (tex0 + (2.0 * tex1) * (1.0 - tex0));
    //P1 = tex0 * (tex0 + (1.6 * tex1) * (1.0 - tex0));
    P1 = P1 * (P1 + (2.0 * tex1) * (1.0 - P1));
    P1 = mix(P1, tex2, tex2.a);
    //gl_FragColor = mix(tex0, tex2, tex2.a);

    gl_FragColor = P1;
}


[[VS_FSQUAD]]

uniform mat4 projMat;
attribute vec3 vertPos;
varying vec2 texCoords;

void main( void )
{
texCoords = vertPos.xy;
gl_Position = projMat * vec4( vertPos, 1 );
}


[[FS_COPY_DEPTH]]

uniform sampler2D depthBuf;
varying vec2 texCoords;

void main( void )
{
    gl_FragDepth = texture2D( depthBuf, texCoords ).r;
}


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group