Followers 0

4 posts in this topic

Hi guys

I have no problems drawing a fullscreen quad without setting a vertex buffer by just giving a vertex count and then handling the positions and UV coordinates in the vertex shader. However I was wondering if it may be possible to do the same on a geometry shader. I have a simple 2D control panel here where I will be drawing several small quads in certain areas so I was hoping I might be able to handle it all on the shader. Can this be done?

Thanks

JB

0

Share on other sites

Probably you can do it with GS too, but the VS solution should work as well. Can you show the vertex shader code?

Cheers!

0

Share on other sites
struct VS_Output
{
float4 Pos : SV_POSITION;
float2 Tex : TEXCOORD0;
};

VS_Output VS(uint id : SV_VertexID)
{
VS_Output Output;
Output.Tex = float2((id << 1) & 2, id & 2);
Output.Pos = float4(Output.Tex * float2(2,-2) + float2(-1,1), 0, 1);
return Output;
}

1

Share on other sites

You'll need to provide some data in order to draw some GUI elements, such as position and element delta size. With that information, you should be able to modify the vertex shader so that it'll draw rectangles on the screen instead of full screen quad.

But since you'll need some data for the GUI drawing, you could as well give each vertex position inside a vertex or a constant buffer.

Cheers!

0

Share on other sites

I was thinking I could handle that with constant variables initialized in shader instead of on the CPU.

1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account