Multple passes
Asked Answered
H

7

1

WHAT IS WANT: mesh with diffuse shader and wireframe over top

I have 2 shaders. one is a simple wireframe shader and the other is a simple diffuse shader.
when I put 2 materials on the mesh, with first material having the diffuse shader and the "next pass" section I add second material with the wireframe. it looks "OK"... but we don't see the wireframe mesh all too well. I put "depth_test_disabled" and wow, it looks amazing! but... the wireframe also draws over every other object in scene...
is there a way to properly get the wireframe pass to be over top the previous pass? To look as good as depth_test_disabled? or perhaps to ONLY disable depth test for previous material??
Before responding not, Ive tried several things including:
->changing the "priority" of the material
-> using a shader that draws wireframe AND a color on the mesh (it didn't look as clean as wireframe shader for some reason)

wireframe shader:
`shader_type spatial;
render_mode unshaded,wireframe,cull_disabled;

uniform vec4 albedo : source_color = vec4(0.0,0.0,0.0,1.0);

void fragment() {
ALBEDO = albedo.rgb;
}`

diffuse shader:
`shader_type spatial;
render_mode blend_mix,depth_draw_opaque,diffuse_burley,specular_schlick_ggx;
uniform vec4 albedo : source_color;

void fragment() {
ALBEDO = albedo.rgb;
}`

Hindermost answered 9/3, 2024 at 21:2 Comment(0)
V
0

Hindermost Offset vertices slightly along the normal in the wireframe pass to avoid z fight. This is equivalent to enabling grow in the standard material.

uniform float grow = .001;
void vertex(){
	VERTEX += NORMAL * grow;
}
Von answered 9/3, 2024 at 21:49 Comment(0)
H
0

Von thanks for you help, but sadly, it didnt solve the issue. Here is an image showing the issue.
the top shows the shader with grow 0.001. its pretty much same as I had.
the middle image, I put grow to 0.2
it is now out of the mesh, floating on top... but still looks so faint.
the final image shows with depth_test_disabled. look how noticeable the difference is. You really see the outlines around the plane (its to see the tris in the world as I deform the terrain)
but it's annoying kuz the objects nearby have the wireframe over them....
but look how thicker and darker the wireframe is!!

Hindermost answered 10/3, 2024 at 6:46 Comment(0)
V
0

Hindermost Check that normals in your meshes are actually correct, i.e. pointing perpendicularly out of the surface. For start try it with one of Godot's built in meshes, a sphere for example.

Von answered 10/3, 2024 at 14:16 Comment(0)
H
0

Von wow you are good! I really didnt think of this yet seems pretty obvious... I just checked and the mesh actually does not have normals at all!!
I changed it, but sadly it didnt help much 🙁
good suggestion tho!

Hindermost answered 10/3, 2024 at 22:37 Comment(0)
H
0

I just checked with a PlaneMesh and a SphereMesh and I dont really see much difference with or without depth_test_disabled....
so mb its the ArrayMesh im using...
i checked and all the normals are now up... so not sure what else could be...

Hindermost answered 10/3, 2024 at 22:42 Comment(0)
H
0

Von ok, I solved it! I set the grow to 0.002 (so doubled) and with normal fixed it solved it. looks great!! thanks!!

Hindermost answered 10/3, 2024 at 22:51 Comment(0)
V
0

Hindermost If your mesh is a plane, make sure that it's not upside down. Take a clue from how the wireframe behaves when you change the grow uniform. It should expand along the normals. If it doesn't do so, then normals are still screwed up. The whole thing should work properly when the normals are correct.

EDIT: Ok. You solved it.

Von answered 10/3, 2024 at 22:53 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.