Jump to content

Custom renderer plugin - render at lower resolution


westy
 Share

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.

Link to comment
Share on other sites

  • 2 weeks later...

@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...

Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...