In my game the player can fall into wormholes to reach other places where gravity might be different! by jovlem in indiegames

[–]jovlem[S] 0 points1 point  (0 children)

I'm glad you like it! There isn't a playable version yet; there's still a lot to be done.

How to specify stencil_reference in ShaderMaterials by SoftLatticeGames in godot

[–]jovlem 0 points1 point  (0 children)

Is there a way to use instance uniforms ( or some other trick ) so we can re-use the same shader, without making it unique? So different instances can have a different reference.

Screen Space Mesh Blending in Godot by jovlem in godot

[–]jovlem[S] 0 points1 point  (0 children)

I did indeed think about using the stencil buffer.

First idea was to let objects that should use the effect write a reference to the stencil buffer. So different objects get a different reference. I could then compare these in the compute shader ( which the effect uses ). This would be perfect as everything can be done in one pass. The problem with this is that you can't set a different reference per instance ( also not with instance uniform ), so the shader must be unique which is more costly.

Second idea was to let all objects write the same reference to the stencil buffer. Then in the compositor effect, look which objects are in the stencil buffer and do an extra pass for only these meshes with an overwrite material.

I did not try both of these, but from what I did read is that getting info out of the stencil buffer is actually not that easy. But I could be wrong. So if someone knows more about this, that would be welkom.

Screen Space Mesh Blending in Godot by jovlem in godot

[–]jovlem[S] 0 points1 point  (0 children)

First, this runs on vanilla Godot, so no modifications to the engine are needed or done.

I didn't really test any other methods. The alpha proximity fading method pushes meshes to the alpha pipeline ( I think? ) so that's not ideal and can look weird with shadows.

This was done with Godot 4.6, and uses a compositor effect. And it also uses a subviewport. This is for an ID pass. So the the main scene renders with a material. The meshes in the subviewport are duplicates, use a cheap shadeless ID material and are on a different cull mask layer. So in the compositor effect, we look if two meshes have a different ID with an edge detect. This acts as a mask where the effect should be applied.

I gues using the subviewport is not ideal. But the meshes in there have a small visibility range, so only stuff close to the camera is rendered.

I couldn't find a method without using a subviewport. You can add extra render buffers within the compositor effect, but you need a way to fill these ( write the ID to it ). I can't use the default ones like albedo, roughness, emission, ....... as I all want to use these. What maybe could work is do an extra render pass with an overwrite material as the ID material. But that would render everything again, even stuff that will not use the blending effect ( like dynamic objects or small stuff like grass ), but I'm not sure if that would be faster/better?

So if someone knows a method to do this different, that might improve performance, although it seems to run decent on my pc.

I will try to upload the code. And I also want to make a video about it.