Advertisement

Rendering and compositing G-buffers.

Started by July 12, 2018 06:26 AM
2 comments, last by pcmaster 6 years, 6 months ago

When I directly render to the primary surface using the z-buffer on, the particles do go behind the buildings. However, when I turn on the z-buffer while rendering on the g-buffer (render targets) then composite the surfaces using z-buffer off, then the z-buffer properties are gone, and the particles are in front of the buildings. How come?

thanks

Jack

Dear all,

I am wondering when I output a stencil value on a float2, and I got an additional sampler. Assuming I output color2 to a texture or some kind without leaving the shader, how does the sampler got knowledge about the stencil texture?

 


	sampler depthSampler;
//--------------------------------------------------------------------------------------
// Render particle information into the particle buffer
//--------------------------------------------------------------------------------------
struct PBUFFER_OUTPUT
{
    float4 color0 : COLOR0;
    float4 color1 : COLOR1;
    float4 color2 : COLOR2;  // depth buffer
};
	

thanks

Jack

Advertisement

COLOR2 isn't a depth buffer. It's just a colour buffer on slot 2.

What does mean "output a stencil value on a float2"? What samplers are you talking about?

On the OUTPUT of a pixel shader, there's 0-1 depth-stencil target and 0-8 colour render targets. Stencil and depth are implicit, i.e. depend on the fragment position and external stencil settings, i.e. you cannot set them manually in your pixel shader, there's specialised HW handling them; the colours are explicit and you must calculate them in the pixel shader.

On the INPUT to any shader, there's 0-128 of textures (I'm simplifying). Some of those textures can be the same memory as your render targets or depth-stencil targets.

A sampler is a recipe to sample the neighbourhood (neighbouring pixels and neighbouring mipmaps) at a UV coordinate on your texture to fetch you a colour. Any texture can be sampled with any sampler. Example samplers are: point, bilinear, anisotropic, etc.

The definition of a sampler in GLSL (texture + recipe) and in HLSL (recipe only) is fundamentally different, watch out.

This topic is closed to new replies.

Advertisement