How to have a screen-space shader ignore certain objects? (3D)

piccobellopiccobello Posts: 2Member
edited June 2018 in Shaders

Hey guys,

I know the basics of shaders but I have no clue nor yet found any clue of how to achieve what I'm thinking of:

I imagine a screen-space shader, let's say to filter the 3d environment, but certain objects (for example items or characters) should not by affected by this.

The official demo actually covers this: the UI elements are not affected by the shader laying underneath due to the node-tree. However, since the screen-space shader is drawn on the 2d environment, the hierarchy gets ignored when setting up the shader in 3D.

Depth in godot3 doesn't seem to work yet, but this is not what I think is the solution (like DOF works), it's rather just having layers stacked on each other.

I made a rough mockup:

Can you point me to a solution? Thanks

Answers

  • arthurarthur Posts: 34Member

    I would try to add the "distortion" shader to everything I want to distort, and use screen space to make the effect. Should be equal to everything.
    Another option would be set the player to be drawn after (aka "on top of") everything, but it would be problematic when the player is behind anything (like a wall, a column, enemy, etc.).

  • TwistedTwiglegTwistedTwigleg Posts: 1,049Admin

    Another way you could maybe achieve this effect is rendering everything you do not want to distort in another Viewport. Then you could create a black and white bit mask, and then use that bit mask in a screen space shader to decide what to distort.

    I did a 2D clipping shader in Godot 2 that used a bit mask when I was trying to remake INK (for educational purposes). In theory rendering to a bit mask should work in 3D as well, it might just be a tad more complicated than a 2D implementation.

  • piccobellopiccobello Posts: 2Member

    Thanks for your replies - using different viewports is something I've thought about but it makes it hard to keep an organized structure since there are a lot of nested scenes and mutiple copies - but maybe I'm doing something wrong.
    As said I know the very basics of the shader language and still am a bit new to Godot (though I've already quite a lot experience in the blender game engine, vector math is not a problem eg., it helped me to jump right into understanding Godot)

    As for hierarchy or "on top" I'm not quite sure to achieve this, since I've tried manipulating z-indeces, visibility layers, node-tree hierarchy etc - nothing worked - maybe it's just a difference in 3D than it's in 2D.

Sign In or Register to comment.