Illuminate PlaneMesh with low-poly look

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By atorresm
:warning: Old Version Published before Godot 3 was released.

Hi!

I have generated a simple map using a MeshInstance containing a PlainMesh. As a shader, I apply the following:

shader_type spatial;
render_mode cull_disabled;

uniform sampler2D tex;

void vertex() {
    vec2 xz = VERTEX.xz;
    float h = texture(tex, UV).g * 10.0;
    VERTEX = vec3(xz.x, h, xz.y);
}

Where tex is a heightmap I generated using GIMP. With this, I get the following (I added an OmniLight to show the current state):
enter image description here
(Wireframe mode to clarify)
enter image description here

This is the effect I want to achieve:

As you can see, each triangle has an only one color.
I imagine I have to apply something in the shader regarding fragment or lighting, but I don’t really know how to get around it.

Thanks in advance!

:bust_in_silhouette: Reply From: atorresm

I solved it! Made a little demo showing how: Antonio Torres Moríñigo / Godot-LowPolyTerrainDemo · GitLab

Thank you for this! Cleared everything up.

PoisonIvy | 2023-04-17 05:06