GradientTexture Shader
A simple shader that uses a GradientTexture1D to control the color of the mesh. Similar to Toon Shading or Cell Shading, but allows the developer to be flexible to make stylistic choices. If you desire to have outlines, you can add an outline shader in the “Next Pass” property.
Shader code
// Created by Ryan Remer
// https://godotshaders.com/shader/gradienttexture-shader/
shader_type spatial;
uniform sampler2D color_ramp;
void light() {
float dotnl = dot(NORMAL, LIGHT);
float sample_position = max((dotnl + 1.0) / 2.01, 0.01);
vec4 ramp_light = texture(color_ramp, vec2(sample_position, 0.0));
vec3 diffuse_light = ramp_light.rgb * clamp(LIGHT_COLOR * ATTENUATION, vec3(0,0,0), vec3(1,1,1));
DIFFUSE_LIGHT = max(diffuse_light, DIFFUSE_LIGHT);
}
love it <3
nice
tested on 4.3, if your shader don´t work in world scene, add this tag ->
render_mode ambient_light_disabled;
What type is the color ramp variable? Anything I add (e.g. GradientTexture2D) does no difference to the scene.
I even added the tag render_mode ambient_light_disabled;