westy Posted May 2, 2018 Share Posted May 2, 2018 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. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 2, 2018 Share Posted May 2, 2018 render it into separate RenderTexture and put it in a sprite. Quote Link to comment Share on other sites More sharing options...
westy Posted May 17, 2018 Author Share Posted May 17, 2018 @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... Quote Link to comment Share on other sites More sharing options...
botmaster Posted May 17, 2018 Share Posted May 17, 2018 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. Quote Link to comment Share on other sites More sharing options...
westy Posted May 19, 2018 Author Share Posted May 19, 2018 @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. Quote Link to comment Share on other sites More sharing options...
botmaster Posted May 21, 2018 Share Posted May 21, 2018 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. Quote Link to comment Share on other sites More sharing options...
westy Posted May 22, 2018 Author Share Posted May 22, 2018 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.