Problem with post-processing effects
Page 1 of 1

Author:  UrsusMaritimus [ 04.03.2012, 16:01 ]
Post subject:  Problem with post-processing effects

Hi guys, I'm presently trying to implement a few post-processing effects in a pipeline (basically at an experimental stage atm), but I can't seem to get things to work.

My custom pipeline is, to a large extent, simply the forward light one extended with a post-processing stage, and it looks something like:
      <RenderTarget id="PRBUFFER" depthBuf="true" numColBufs="1" format="RGBA8" scale="1.0" />

      <Stage id="Geometry" link="pipelines/globalSettings.material.xml">
         <SwitchTarget target="PRBUFFER"/>
         <ClearTarget depthBuf="true" colBuf0="true"/>
         <DrawGeometry context="AMBIENT" class="~Translucent"/>
         <DoForwardLightLoop class="~Translucent"/>
         <DrawGeometry context="TRANSLUCENT" class="Translucent" order="BACK_TO_FRONT"/>
      <Stage id="PostProcess">
         <SwitchTarget target=""/>
         <ClearTarget colBuf0="true"/>
         <BindBuffer sampler="buf0" sourceRT="PRBUFFER" bufIndex="0"/>
         <DrawQuad material="materials/pproc.material.xml" context="PPROC"/>
      <Stage id="Overlays">
         <DrawOverlays contexc="OVERLAY"/>

The referenced "pproc" material looks like
   <Shader source="shaders/pproc.shader"/>

And that shader contains

sampler2D buf0 = sampler_state
   Address = Clamp;

context PPROC
   VertexShader = compile GLSL VS_FSQUAD;
   PixelShader = compile GLSL FS_PPROC;

   ZWriteEnable = false;

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

uniform sampler2D buf0;
varying vec2 texCoord;

void main(void)
   gl_FragColor = texture2D(buf0, texCoord);

Now, as far as I've understood things, this ought to produce output that is identical to a normal forward lighting pass, as the post-processing pass actually doesn't do anything yet. Except, the result is that the entire screen is rendered in a single-colour (which one changes as you look around, so at least *something* is happening). Removing the post-processing stage and setting the render target to "" for the first stage results in the scene looking exactly as expected.

So, what am I missing or doing wrong?

Author:  worstplayer [ 04.03.2012, 17:23 ]
Post subject:  Re: Problem with post-processing effects

Looks like simple typo. You have texCoords in vertex shader, but texCoord in pixel. That could be a problem.

Author:  UrsusMaritimus [ 04.03.2012, 18:21 ]
Post subject:  Re: Problem with post-processing effects

God damn, how did I miss that? I poured over the stuff for hours before posting about it here... Guess I'll blame it on sleep deprivation.

Anyway, thanks, that cleared everything up!

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group