• Advertisement
Sign in to follow this  

Geometry shaders

This topic is 1394 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 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

Share this post


Link to post
Share on other sites
Advertisement

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

 

Cheers!

Share this post


Link to post
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;
}

Share this post


Link to post
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!

Share this post


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

  • Advertisement