Geometry shader not working properly

Started by
1 comment, last by Beosar 8 years, 9 months ago

Hi,

I am working on the shadow rendering and tried to use a geometry shader to write to SV_RenderTargetArrayIndex. When I disable the geometry shader using DeviceContext->GSSetShader(0, 0, 0); the shadows are rendered correctly. When I enable it, it does not work properly: Some triangles (about 50% of them) are rendered, some are not, resulting in flickering shadows.

I'm 100% sure the right shader is loaded and set, becaused I changed the shader to output nothing (using an if clause which can't be true) and this resulted in no shadows being rendered.

I set the position of vertices which should not be displayed to float4(-10, -10, 2, 1) in the vertex shader, so this is the reason why I added this odd if clause in the geometry shader.

I tried settings RTAI to 0, but this did not change anything, so I'm sure the RenderTargetArrayIndex constant is correctly set to 0.

Edit: If I set the position for every vertex properly in the vertex shader, it works with enabled geometry shader. But why?


cbuffer GSMatrixBuffer{
	matrix ViewProjectionMatrix;
	uint RenderTargetArrayIndex;
	float3 padding;
}


struct GeometryInputType
{
	float4 position : SV_POSITION;
};

struct PixelInputType
{
	float4 position : SV_POSITION;
	uint RTAI : SV_RenderTargetArrayIndex;
};

[maxvertexcount(3)]
void main(triangle GeometryInputType input[3], inout TriangleStream<PixelInputType> OutputStream){

	
	//if (input[0].position.x > -2.0f){
		PixelInputType output[3];
		output[0].position = input[0].position;
		output[0].RTAI = RenderTargetArrayIndex;

		output[1].position = input[1].position;
		output[1].RTAI = RenderTargetArrayIndex;

		output[2].position = input[2].position;
		output[2].RTAI = RenderTargetArrayIndex;

		OutputStream.Append(output[0]);
		OutputStream.Append(output[1]);
		OutputStream.Append(output[2]);

		OutputStream.RestartStrip();
	//}

	
}
Advertisement

Is this for updating the slices of a 3d rendertarget?

It's for updating a depth buffer array (2d texture with array size > 1 used as depth buffer). I did not bind any render target since I only need the depth.

This topic is closed to new replies.

Advertisement