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