Accumulated light (3D)

A shader implementation for “celyk” Shader -> https://godotshaders.com/shader/notes-on-the-light-function/

Shader code
/*
Re-implementation by "QJPG"
A SHADER IMPLEMENTATION for "celyk" Shader -> https://godotshaders.com/shader/notes-on-the-light-function/

*/

shader_type spatial;

render_mode ambient_light_disabled, specular_toon, cull_back;

uniform sampler2D t;
uniform vec3 color_albd = vec3(1, 1, 1);

void fragment() {
	vec4 color = texture(t, UV);
	
	ALBEDO = color.rgb * color_albd;
	//ALPHA = color.a;
}

void light() {
	// light we wish to accumulate
	DIFFUSE_LIGHT += ALBEDO * ATTENUATION * LIGHT_COLOR * max(dot(LIGHT, NORMAL), 0.0);

	// assign the result
	SPECULAR_LIGHT = round(DIFFUSE_LIGHT * 3.0 - 0.5) / 8.0; // posterizes the final color

	// cancel all contribution of the diffuse_light variable
	SPECULAR_LIGHT -= DIFFUSE_LIGHT;
}
Tags
chroma, light, psx
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from qjpg

Post-Processing, Grain PP effect and Palette Color

Related shaders

UCBC’s Stylized Light with Light Masking

Modulate Before Light

2D Rim Light

Subscribe
Notify of
guest

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Spam Rakuen
6 months ago

This fork solves this problem just changing a few lines of code in the Godot Engine:
https://github.com/spamrakuen/godot/tree/4.2MOD

Spam Rakuen
6 months ago
Reply to  Spam Rakuen

Future Shader Templetes will allow this without any MOD.

Here is a talk of Clay John were its explained
https://m.youtube.com/watch?v=MW3IFMvDTCY