Sign in to follow this  
westy

Custom renderer plugin - render at lower resolution

Recommended Posts

I have a custom renderer plugin (based off https://github.com/pixijs/pixi-plugin-example) that employs a very expensive fragment shader. The sprite it applies to (a map) often covers the entire screen. I'd like to be able to optionally render at a lower resolution and then scale up the result so that the fragment shader doesn't need to apply to every single screen pixel.

I understand that setting PIXI.settings.resolution will work here, but I don't want to change the resolution of the entire scene - just this object.

Share this post


Link to post
Share on other sites

@ivanpop I was able to create a lower resolution texture by using a render texture. However, when the sprite is upscaled, the fragment shader still runs on every on-screen pixel, even though the texture itself is noticeably blocky.

I suppose this is natural webGL behaviour? I suppose the alternative would be to have the sprite render to a texture every frame, but I imagine there are significant penalties there as well...

Share this post


Link to post
Share on other sites
4 hours ago, westy said:

@ivanpop I was able to create a lower resolution texture by using a render texture. However, when the sprite is upscaled, the fragment shader still runs on every on-screen pixel, even though the texture itself is noticeably blocky.

I suppose this is natural webGL behaviour? I suppose the alternative would be to have the sprite render to a texture every frame, but I imagine there are significant penalties there as well...

No it's not the natural webgl behavior, the texture sampling loop is based on whatever data you pass to your shaders and how your shaders handle that data, the size of the canvas is irrelevant, you are in complete control on how your shaders work and sample your textures.

Share this post


Link to post
Share on other sites

@botmaster Thanks for your response!

I'm not really talking about sampling here - I'm talking about how many fragments the shader is actually processing. In my tests, this seems to be completely determined by the size of the sprite in the viewport, as well as the renderer resolution. The size of the underlying texture makes no difference.

I assume this behaviour is perfectly expected. I guess what I really want to do is lower the *resolution* for a specific sprite which uses a custom renderer without affecting the resolution of the rest of the game.

Share this post


Link to post
Share on other sites
14 hours ago, botmaster said:

You'll have to take a look at the shader and see why it behaves that way, maybe that shader allows you to set a uniform to lower resolution or maybe you need to make your own and make a custom renderer.

Yep! As I said in the OP, I am using a custom renderer plugin which is pretty much identical to the renderer plugin example, minus the cropping.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.