Jump to content
  • Advertisement
Sign in to follow this  
Medo Mex

Sniper Scope Screen Overlay

This topic is 880 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'm using HLSL to blend the full screen quad with sniper scope texture.

 

The problem is that I couldn't get the sniper scope overlay texture to resize based on the screen aspect ratio

 

The screen overlay is automatically resizing to fit the screen but if the screen is wide I see the sniper scope texture appear wider than it should.

 

How do I make the sniper scope texture fit the screen correctly (so it doesn't appear wide if the screen is wide)?

Share this post


Link to post
Share on other sites
Advertisement
Fix the aspect ratio of the scope image based on the screen height (if the height is less than the width), draw it centralized along the x axis, fill in the edges with solid black (or whatever color your scope image is). If the screen is wider than it is high, do it the other way around.

Share this post


Link to post
Share on other sites

@Aardvajk: How do I draw the image centralized in Pixel Shader?

 

I see that the image get resized in the pixel shader automatically.

 

What I do is similar to the following (I get the image fully resized):

return ColorTexture.Sample(SampleType, IN.TexCoord) * SniperTexture.Sample(SampleType, IN.TexCoord);
Edited by Medo3337

Share this post


Link to post
Share on other sites
I guess I would create three quads to render to the screen, one in the middle for the image and one at either end to fill with a solid colour. You could then use a different pixel shader for the solid colour quads than the image quad. You'd just need to set up a vertex shader that worked in screen coordinates rather than world coordinates.

Share this post


Link to post
Share on other sites

another option might be an oversized quad, big enough to deal with any anticipated aspect ratios.  scale the quad so the aspect ratio and size of the scope are correct, and the extra large size of the quad guarantees it will still cover the entire screen (more than cover, most likely).

Share this post


Link to post
Share on other sites

@Aardvajk: I'm already using Full screen quad, the line:

return ColorTexture.Sample(SampleType, IN.TexCoord) * SniperTexture.Sample(SampleType, IN.TexCoord);

Is from Full Screen Quad Pixel Shader

 

Do I have to create multiple Full screen Quads? it's not possible to use the FS Quad shader to produce the desired results without having to create multiple FS Quads?

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!