Jump to content

  • Log In with Google      Sign In   
  • Create Account

rendertargets and resolution independency problems

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1   Members   -  Reputation: 107


Posted 04 February 2014 - 07:15 PM

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, 04 February 2014 - 07:18 PM.

#2   Members   -  Reputation: 107


Posted 04 February 2014 - 09:47 PM

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?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.