Understanding multi-pass materials
Asked Answered
A

3

0

Hello!
Godot version 3.5.stable. Multi-pass material duplicates geometry for me. Each material pass creates another visible mesh instance.
I'm trying to apply a geometric transform to meshes via a vertex() shader material function applying it as a second pass. However, instead of being applied to the mesh it duplicates a mesh. And I have two meshes: one before the transform, the other one after the transform.


The geometry modifying shader is trivial:

shader_type spatial;
void vertex()
{
	vec3 v = VERTEX;
	vec3 vert = vec3(v.x + 100.0, v.y, v.z);
	VERTEX = vert;
}

How should I implement the two pass material correctly so that the 2-d shader modifies the result of the first one? Now it duplicates it for some reason.
I'd appreciate any advice! Thank you!

Arvell answered 8/11, 2022 at 2:54 Comment(0)
B
0

If you are using a custom shader then you probably don't need the multiple passes.

Boaten answered 8/11, 2022 at 3:43 Comment(0)
K
0

Traditionally multi pass rendering is done by rendering a mesh over the top of itself, once for each pass. It was the standard method back in the early days when shaders didn't exist or when you need too many (or a dynamic amount) of textures.
It relies on the vertices not moving between passes (they should use the same or similar vertex shader, at least the position part should be the same).

I don't know that details of Godot's version (it's barely documented at all, as far as I can see) so I can't really help much with how to set it up right, but how we used to use it in engines like Ogre3D:

  • render an ambient pass with depth write and check.
  • for each nearby light, render again with the diffuse texture times lighting, in additive blending mode, with depth check on but depth write off.
Klondike answered 8/11, 2022 at 14:26 Comment(0)
A
0

Klondike Traditionally multi pass rendering is done by rendering a mesh over the top of itself, once for each pass. It was the standard method back in the early days when shaders didn't exist or when you need too many (or a dynamic amount) of textures.

Yes, that looks like what's happening. If 2-d pass vertices are not displaced, the 2-d mesh hides the first one. But if I displace the vertices, I see both of them. So it looks like there is no way to apply one and the same transform to all the meshes in GPU?

Arvell answered 8/11, 2022 at 16:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.