Page 1 of 1

RenderTarget unexpected results (blurry)

Posted: Sun Jan 10, 2016 5:00 am
by rrTea
I'm trying to render some stuff to a texture and later stretch that texture over the screen, but it seems RenderTarget doesn't have Nearest / Linear modes like Bitmap components?

Also I must have set something wrong, the results I'm getting do not look like they're scaled correctly (resulting in the image being "unevenly blurry" as opposed to smoothly antialiased), I'm attaching the project like I currently have it set up. What am I doing wrong?

Re: RenderTarget unexpected results (blurry)

Posted: Sun Jan 10, 2016 10:01 am
by VilleK
Hi,

Setting the rendertarget-properties so it has the same size as the viewport makes it look good here:

Code: Select all

<RenderTarget Name="ScreenProjection_rt" Width="0" Height="0" ClearColor="0.6235 0.8588 1 1"/>

Re: RenderTarget unexpected results (blurry)

Posted: Sun Jan 10, 2016 10:39 am
by Kjell
Hi rrTea,
rrTea wrote:I'm trying to render some stuff to a texture and later stretch that texture over the screen, but it seems RenderTarget doesn't have Nearest / Linear modes like Bitmap components?
Correct, no idea why it doesn't. Fortunately you can do-this-yourself quite easily using a OpenGL call ( see attached demo ).
rrTea wrote:IAlso I must have set something wrong, the results I'm getting do not look like they're scaled correctly (resulting in the image being "unevenly blurry" as opposed to smoothly antialiased), I'm attaching the project like I currently have it set up. What am I doing wrong?
Two things ...

- Since you're using a target resolution of 160x120 you should set App.ViewportRatio to 4:3.
- When you use a viewport ratio you shouldn't use the App.ScreenWidth & App.ScreenHeight values to calculate the aspect ratio. Either just enter the values you're using ( Ratio = 4/3 ) or use App.ViewportWidth & App.ViewportHeight*

*Personally i prefer simply resetting the matrices in a RenderTarget situation though ( see attached demo ).

K

Re: RenderTarget unexpected results (blurry)

Posted: Sun Jan 10, 2016 11:43 am
by VilleK
Ah, I didn't understand the original question correctly. Now I see that you intend to render to lower resolution and stretch it. Indeed, we should add filtering options to rendertarget-component.

Re: RenderTarget unexpected results (blurry)

Posted: Mon Jan 11, 2016 4:14 am
by rrTea
Kjell wrote:- Since you're using a target resolution of 160x120 you should set App.ViewportRatio to 4:3.
Isn't the ViewportRatio in my example 4:3 anyway since I'm using 800*600?

Anyway I tried setting it like that too but that didn't help with what bothers me the most: the image looks... off? Weirdly blurry, as if it were an image scaled using a mix between Linear and Nearest (especially visible on edges of the rotating cube) while it's neither. Is there anything I can do about it?

Re: RenderTarget unexpected results (blurry)

Posted: Mon Jan 11, 2016 10:16 am
by rrTea
Haa just tried the new build (with added filtering options), looks great! Thanks!

Re: RenderTarget unexpected results (blurry)

Posted: Mon Jan 11, 2016 11:48 am
by Kjell
Hi rrTea,
rrTea wrote:Isn't the ViewportRatio in my example 4:3 anyway since I'm using 800*600?
Ah, i tried your project inside the IDE ( using the Preview feature ), which i usually have scaled to 16:9.
rrTea wrote:Anyway I tried setting it like that too but that didn't help with what bothers me the most: the image looks... off?
As i mentioned in my post ( and showed in the demo ), you needed to switch your RenderTarget to nearest neighbor filtering using a OpenGL call. But since Ville already added a property for that on RenderTarget, there's no need for that anymore :wink:

K

Re: RenderTarget unexpected results (blurry)

Posted: Tue Jan 12, 2016 3:10 am
by rrTea
Kjell wrote:Ah, i tried your project inside the IDE ( using the Preview feature ), which i usually have scaled to 16:9.
I see, thanks for the clarification, but yes you're right I should have set it to 4:3 explicitly (and use Viewport) so it works in the IDE too.