Horde3D

Next-Generation Graphics Engine
It is currently 29.03.2024, 16:13

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Deferred Particles
PostPosted: 30.10.2011, 02:24 
Offline

Joined: 29.10.2011, 01:33
Posts: 8
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Deferred Particles
PostPosted: 31.10.2011, 04:05 
Offline

Joined: 29.10.2011, 01:33
Posts: 8
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Deferred Particles
PostPosted: 31.10.2011, 15:15 
Offline

Joined: 09.09.2009, 18:58
Posts: 107
Would you care to share your solution for others to reference?


Top
 Profile  
Reply with quote  
 Post subject: Re: Deferred Particles
PostPosted: 31.10.2011, 23:26 
Offline

Joined: 29.10.2011, 01:33
Posts: 8
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


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 64 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