Jump to content
  • Advertisement
Sign in to follow this  
Magogan

Geometry shader not working properly

This topic is 1119 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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();
	//}

	
}
Edited by Magogan

Share this post


Link to post
Share on other sites
Advertisement

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.

Edited by Magogan

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!