Geometry shaders

Started by
3 comments, last by JB3DG 10 years ago

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

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!


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;
}

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!

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

This topic is closed to new replies.

Advertisement