Horde3D
http://horde3d.org/forums/

Operations on Render Target
http://horde3d.org/forums/viewtopic.php?f=2&t=2321
Page 1 of 1

Author:  PawelMalecki [ 25.07.2019, 11:58 ]
Post subject:  Operations on Render Target

Newbie here needing help. Game engine I'm modding uses slightly older version of Horde.
Code:
<Pipeline name="FOW">
   <Setup>
      <GlobalRenderTarget id="FogOfWarRT" />
   </Setup>
   <CommandQueue>
      <Stage id="FogOfWar_RT">
         <SwitchTarget target="FogOfWarRT" />
         <ClearTarget colBuf0="true" depthBuf="true"/>
         <DrawGeometry scene="0" context="HEIGHT" forceLodLevel="0" cached="false"/>
         <DrawGeometry context="FOW_RT_EXPLORED" forceLodLevel="0" cached="false"/>
         <DrawGeometry context="FOW_RT_VISIBLE" forceLodLevel="0" cached="false"/>
      </Stage>
   </CommandQueue>
</Pipeline>


The thing is I'd like to perform channel multiplying (green *= red) after all DrawGeometry calls are finished (i.e. post-process the target) then do a Gaussian blur on the alpha channel. How do I perform such operations (without geometry calls) on a current render target?

Author:  Irdis [ 25.07.2019, 20:06 ]
Post subject:  Re: Operations on Render Target

Hello. You can check the hdr pipeline, it has exactly the steps that you want.
It would probably look something like that:
Code:
<RenderTarget id="PostProcBuf" depthBuf="false" numColBufs="1" format="RGBA8" />
...
 <Stage id="FogOfWar_RT">
         <SwitchTarget target="FogOfWarRT" />
         <ClearTarget colBuf0="true" depthBuf="true"/>
         <DrawGeometry scene="0" context="HEIGHT" forceLodLevel="0" cached="false"/>
         <DrawGeometry context="FOW_RT_EXPLORED" forceLodLevel="0" cached="false"/>
         <DrawGeometry context="FOW_RT_VISIBLE" forceLodLevel="0" cached="false"/>
      </Stage>
<Stage id="PostProcess">
   <SwitchTarget target="PostProcBuf" />
   <BindBuffer sampler="buf0" sourceRT="FogOfWarRT" bufIndex="0" />
   <DrawQuad material="pipelines/postProc.material.xml" context="POSTPROCESSING" />
   <UnbindBuffers />
</Stage>
<Stage id="Combination">
   <SwitchTarget target="" />
   <BindBuffer sampler="buf0" sourceRT="PostProcBuf" bufIndex="0" />
   <DrawQuad material="pipelines/final.material.xml" context="FINALPASS" />
   <UnbindBuffers />
</Stage>


So, you would have to create a material that references the shader that would be called. The shader should contain the POSTPROCESSING context. You can check the postHDR.shader to see how it is done.
Please note that the code above is not tested but should be pretty close to reality.

Author:  PawelMalecki [ 26.07.2019, 10:35 ]
Post subject:  Re: Operations on Render Target

Thanks.

Now my next question is: do I need two more stages if I want to skip the blur and do just G *= R? In case of an image processing such a filter doesn't rely on the whole result, can be applied per pixel as all information is held by that pixel so no cached copy is required to probe pixels from.

Author:  Irdis [ 26.07.2019, 12:00 ]
Post subject:  Re: Operations on Render Target

You would probably have a pipeline stage for blur, like I've shown for post-processing. You can disable the blur pipeline stage when needed from horde's api and just use the post-processing one that is the next stage (I guess that you have 3-4 stages - geometry, blur, post-processing, combination (optional, can be merged with post processing stage)).
It should be something like that:
Code:
h3dSetResParamI( pipelineRes, H3DPipeRes::StageElem, stageInPipelineIndex, H3DPipeRes::StageActivationI, 0 );


Please note: if you are going to use several cameras, do not use the same pipeline resource for several cameras simultaneously. It seems that currently it is not supported. You should create a clone of pipeline resource if needed.

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