Picking and Rendertargets

/ April 25, 2020/ Allgemein

Thanks to Corona, I had some more time lately to go on with Native Web development. After I created the Picking for DirectX and implementing it in OpenGL, I found some issues that needed a refactoring. Mainly Rendertarget handling, Shader Variable handling and effect design.

Therefore I implemented a new way of rendertarget/framebuffer handling, I simplified the effectfiles, so that there is only one common effect for the different 3D APIs and only keeping different shaders, that are referenced by a given path.

Here is the current effect for rendering 2D elements:

<?xml version="1.0"?>
<effect version="1.0">
  <pass AlphaBlendEnable="FALSE" AlphaTestEnable="FALSE" AlphaRef="0x00000088" AlphaFunc="GREATER" CullMode="NONE" ZWriteEnable="TRUE" StencilEnable="TRUE" StencilPass="INCR" StencilFunc="ALWAYS" StencilRef="0">
    <vertexshader file="2D_vs"/>
    <pixelshader file="2D_ps"/>
    <rendertarget id="backbuffer" type="BACKBUFFER" clear="true" clearcolor="0.3f,0.3f,0.3f,1.0f"/>
    <rendertarget id="pickbuffer" type="PICKBUFFER" clear="true" clearcolor="0.0f,1.0f,0.0f,1.0f"/>
    <depthstenciltarget id="depth" format="D24S8" clear="true"/>

In the background, depending on the 3D API it pulls in shaders 2D_vs.hlsl or 2D_vs.glsl.

It now also defines the handling of the different rendertargets.

The third thing is the Constant Buffers I use for efficient shader constants updates. The places where I used them were not the best, leading to OpenGL not rendering 2D contents. So I had to do a refactoring that now put the buffers in the right places and they are now only updated when the contents change.

One last step is missing for everything to run correctly. The objects that now create the constant buffers are not created at the right time. After fixing that. All APIs should render fine. So stay tuned.

Share this Post