RenderTarget unexpected results (blurry)

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
rrTea
Posts: 475
Joined: Sat Feb 15, 2014 9:54 am

RenderTarget unexpected results (blurry)

Post 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?
Attachments
Scrolling in low res 01.zgeproj
(124.92 KiB) Downloaded 338 times
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: RenderTarget unexpected results (blurry)

Post 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"/>
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Re: RenderTarget unexpected results (blurry)

Post 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
Attachments
Demo.zgeproj
(1.89 KiB) Downloaded 355 times
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: RenderTarget unexpected results (blurry)

Post 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.
User avatar
rrTea
Posts: 475
Joined: Sat Feb 15, 2014 9:54 am

Re: RenderTarget unexpected results (blurry)

Post 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?
User avatar
rrTea
Posts: 475
Joined: Sat Feb 15, 2014 9:54 am

Re: RenderTarget unexpected results (blurry)

Post by rrTea »

Haa just tried the new build (with added filtering options), looks great! Thanks!
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Re: RenderTarget unexpected results (blurry)

Post 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
User avatar
rrTea
Posts: 475
Joined: Sat Feb 15, 2014 9:54 am

Re: RenderTarget unexpected results (blurry)

Post 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.
Post Reply