Jump to content
  • Advertisement
Sign in to follow this  
david_watt78

GUI Issue with shader

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

I am working on adding shaders and realized I can skip the transform step and not have the issue of finding the right depth value so my gui is not distorted by sampling. However what is the range of transformed coordinates that a vertex shader outputs. I tried pixels 0 - width and 0 - Height but that doesn't seem to be it.

Share this post


Link to post
Share on other sites
Advertisement
The way i did it was to pass the coordinates to the vertex shader in the range of (0-1)(0-1) by dividing the pixel-based positions of my widgets by the resolution (this step could also be done in the shader) and then transform position from that range to (-1,1) in the vertex shader.

These two code snippets can be used to do said conversions:
float4	ConvertToScreen2D( float4 input )
{
float4 output = input;

output.xy = ( output.xy * 2 ) - 1;
output.y *= -1;

return output;
}

float2 ScaleToBackBufferDimensions( float2 input )
{
float2 result;

result.x = input.x / fBackBufferDimensions.x;
result.y = input.y / fBackBufferDimensions.y;

return result;
}
Hope that helps,

Share this post


Link to post
Share on other sites
found my issue apparently the output of a vertex shader in directx10 must be SV_POSITION not POSITION and it doesn't generate an error for what ever reason. Thank you for your help.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!