Horde3D
http://www.horde3d.org/forums/

Deferred Particles
http://www.horde3d.org/forums/viewtopic.php?f=2&t=1587
Page 1 of 1

Author:  dazza007 [ 30.10.2011, 02:24 ]
Post subject:  Deferred Particles

Hi All,
First post - so please bear with me.

First gotta say - really liking the engine so far, pretty much doing everything I want, however just a small thing.
I am wanting to use the deferred rendering pipeline, and for the most part this works fine, however I also want to have a few particle systems, as well as glass windows - I know this has been discussed before, but this was a while ago, and for an earlier version of the engine.

Just wondering if anyone has any examples of how to set something up like this for the latest version of the engine. I've tried a few things, some sort of work - and some just plain don't, so thought I'd be better to ask the people who know.

Many Thanks in advance
Darrin

Author:  dazza007 [ 31.10.2011, 04:05 ]
Post subject:  Re: Deferred Particles

Ignore this - I've resolved the issue.
Now have transparency and particles in the deferred renderer. Not as nicely as I'd hop, but it'll do in the interim.

Thanks
Darrin

Author:  Orm [ 31.10.2011, 15:15 ]
Post subject:  Re: Deferred Particles

Would you care to share your solution for others to reference?

Author:  dazza007 [ 31.10.2011, 23:26 ]
Post subject:  Re: Deferred Particles

Here's my current Solution - I've got a few ideas which may give better lighting, but this works nicely esp for the particle system. Its pretty rough - but works which is the main thing.

I'm pretty sure that should be all that's needed - I have been chopping around in the code, so if you try this and it doesn't work, just let me know and I'll double check it. You'll have to bear with me as have only been using Horde for a week, so if anyone spots anything majorly wrong, just let me know.

in the model.shader - add the following code - just after the AMBIENT context
Code:
context TRANSLUCENT
{
   VertexShader = compile GLSL VS_GENERAL;
   PixelShader = compile GLSL FS_TRANSLUCENT;
   
   ZWriteEnable = false;
   BlendMode = Blend;
}


and at the bottom of the model.shader add
Code:
[[FS_TRANSLUCENT]]
// =================================================================================================

uniform sampler2D albedoMap;
varying vec2 texCoords;

void main( void )
{
   gl_FragColor = texture2D( albedoMap, texCoords * vec2( 1, -1 ) );
}


the following is my deferred.pipeline.xml code
Code:
<!-- Deferred Shading Pipeline -->
<Pipeline>
   <Setup>
      <RenderTarget id="GBUFFER" depthBuf="true" numColBufs="3" format="RGBA16F" scale="1.0" />
   </Setup>
   
   <CommandQueue>
      <Stage id="Attribpass">
         <SwitchTarget target="GBUFFER" />
         <ClearTarget depthBuf="true" colBuf0="true" />
         <DrawGeometry context="ATTRIBPASS"  class="~Translucent"/>
      </Stage>

    <Stage id="Lighting" link="pipelines/globalSettings.material.xml">
      <SwitchTarget target="" />
      <ClearTarget colBuf0="true" />
      <!-- Copy depth buffer to allow occlusion culling of lights -->
      <BindBuffer sampler="depthBuf" sourceRT="GBUFFER" bufIndex="32" />
      <DrawQuad material="materials/light.material.xml" context="COPY_DEPTH" />

      <UnbindBuffers />

      <BindBuffer sampler="buf0" sourceRT="GBUFFER" bufIndex="0" />
      <BindBuffer sampler="buf1" sourceRT="GBUFFER" bufIndex="1" />
      <BindBuffer sampler="buf2" sourceRT="GBUFFER" bufIndex="2" />

      <DrawQuad material="materials/light.material.xml" context="AMBIENT" class="Translucent" />
      <DoDeferredLightLoop />
     
      //particles ideally should be drawn without back to front - if you don't want translucent models just remove the order
      <DrawGeometry context="TRANSLUCENT" class="Translucent" order="BACK_TO_FRONT" />

      <UnbindBuffers />
    </Stage>

    <Stage id="Translucent">
      <ClearTarget depthBuf="true" colBuf0="false" />
    </Stage>

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


The above should work out of the box for particles, if you want to create an object with transparency, just make its material use the Translucent class - as in the example below. The alpha channel of the albedomap is the alpha for the translucency. - I'm also going to tweak and add a distortion using the normal map, to give glass distortion at some stage.

Code:
<Material class="Translucent">
   <Shader source="shaders/model.shader"/>
   <ShaderFlag name="_F03_ParallaxMapping" />

   <Sampler name="albedoMap" map="models/wall024/wall021.tga" />
   <Sampler name="normalMap" map="models/wall024/wall021_n.tga" />
</Material>



Cheers
Darrin

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/