1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Add LIGHT_VERTEX to fragment shader

Adds a new variable to the fragment shader to specify
the vertex position used when calculating lighting.
This commit is contained in:
Rob Blanckaert
2024-04-24 21:41:18 -07:00
parent 780e1a5040
commit ffe0b869f5
7 changed files with 48 additions and 0 deletions

View File

@@ -1022,6 +1022,11 @@ void fragment_shader(in SceneData scene_data) {
inv_view_matrix[1][3] = 0.0;
inv_view_matrix[2][3] = 0.0;
#endif
#ifdef LIGHT_VERTEX_USED
vec3 light_vertex = vertex;
#endif //LIGHT_VERTEX_USED
mat4 read_view_matrix = scene_data.view_matrix;
vec2 read_viewport_size = scene_data.viewport_size;
{
@@ -1032,6 +1037,15 @@ void fragment_shader(in SceneData scene_data) {
transmittance_color.a *= sss_strength;
#endif
#ifdef LIGHT_VERTEX_USED
vertex = light_vertex;
#ifdef USE_MULTIVIEW
view = -normalize(vertex - eye_offset);
#else
view = -normalize(vertex);
#endif //USE_MULTIVIEW
#endif //LIGHT_VERTEX_USED
#ifndef USE_SHADOW_TO_OPACITY
#ifdef ALPHA_SCISSOR_USED