It’s not always necessary to use complex code to produce the effect you want in case of shaders atleast in Godot. For it provides you with quite a lot of pre-built stuff to have fun playing with. So what should we do.

Use the render modes to your advantage.

In the above image you see Display type set to overdraw, can you think of any kind of uses for it in a game you might want to create.

I did say it might be useful in some stealth mechanics in a 3D game.

So how do we create it for our game? Well it’s quite easy.

All this view is a Additive Blend of the meshes over a dark background.

So here’s what I created.

So how did I do it.

Step 1: Create a MeshInstance, a new Mesh and add a ShaderMaterial to it.

Step 2: Add a New Shader, give it Shader Type of Spatial.

NOTE: Spatial type allows us to use 3D space for shader work.

Step 3: Add a uniform vec4 color : hint_color;

NOTE: uniform are variables accessible from outside and thus can be modified at runtime.

Step 4: In vertex() say COLOR *= color;

Step 5: In fragment() do ALBEDO = COLOR.xyz;

NOTE: vertex() is the only place where we can edit COLOR of our object which is then passed to fragment() as read-only in spatial shader_type. And ALBEDO is the display color of fragment() which needs to be edited to set our COLOR we get from vertex(). To know more go to the docs.

Step 6: Finally the render_mode(s) : unshaded and blend_add.

Now the mesh you had disappears, but don’t worry just go to the MeshInstance and then the ShaderMaterial and under Shader Params edit the color to something more grey. Voila!

NOTE: blend_add sets the object to be a additive blend and so it’s the same effect. _NICE_

To see the effect clearly add more meshs and set their Materials to the same one. To do this, select the MeshInstance and go to the Inspector and in the Material drop-down select Copy and for the other materials paste it.

Step 7: If you want to create the scene look even more similar to the overdraw, then go to the project settings under Rendering find Environment and set Default Clear Color to something dark. TADA!!









For the curious minds why not you try to create this effect:

And post your findings to this place and if you need any help, don’t be shy to ask.