Jump to content
  • Advertisement
Sign in to follow this  

rendertargets and resolution independency problems

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

Ever since i've implemented resolution independency to my game, everything was working fine, changing resolutions was simple and everything was being drawn correctly.
2 days ago, so i could implement refraction and other types of screen effects, i've switched my normal way of rendering everything to rendertargets.
Today, when i tested my game on the laptop i've run into a problem. Because i need to put the resolution down on my laptop, for it to handle the game, i noticed the game was no longer being drawn correctly.
Everything i draw into the rendertargets gets messed up, everything else i draw after it is being drawn like it's suppose to.
What happens in this case, when i change the resolution for example, 800x600, everything that is being drawn to the rendertargets becomes very small and if i change the resolution to 1920x1080, everything inside the rendertarget becomes huge.
(the base resolution is 1280x720).
Here's a comparison between the non-rendertarget draw and drawing with render targets at 800x600 resolution :
I'm not sure if the shader is wrong or something in the steps to draw the rendertargets.
I'll post the draw code here along with the shader in hope someone could find the problem and point it out smile.png


I'm using David Amador's resolution class, you can find it here :
//draw entities and map to first RT
spritebatch.begin(...., camera matrix * resolution matrix); 
//draw particles and what not that will refract the screen to the second RT
spritebatch.begin(...., camera matrix * resolution matrix); 
//combine both RT to a third RT
//draw combined RT
Well, removing the resolution matrix on the last rendertarget does this :
3rd situation.
It's weird because everything is being drawn correctly but it's not taking into consideration the position, it should have a black bar on top and below, but there's only a black bar below.
If i draw everything "normally" (without using render targets), it works fine, the shader just applies a color tint as it's suppose to.
If i draw, even a single texture to a render target, it draws like the 3rd square....
Or even if i do this :
spritebatch.begin(...., coloreffect, resolution.matrix);        
spritebatch.draw(texture, vector.zero, Color.White);        
spritebatch.end();  } 
the 3rd square example still happens.
If something else is necessary, let me know.
Thank you in advance
Edited by kopano

Share this post

Link to post
Share on other sites

Well, after some debugging and messing around with values and what not, i found out what's wrong.


Every time i set a new render target, the viewport is set to default, which messes with the position.


I found a hacky way of fixing this issue but i'm wondering if there's a way to prevent the graphicsdevice.setrendertarget() to reset the viewport values?

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!