You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-14 13:41:12 +00:00
Enable the use of all builtins on the light shader
When using the light process in spatial shader, the built-ins work as spected, now they work in forward+, mobile and compatibility renderer.
This commit is contained in:
@@ -343,6 +343,8 @@ void vertex_shader(in uint instance_index, in bool is_multimesh, in uint multime
|
||||
|
||||
mat4 modelview = scene_data.view_matrix * model_matrix;
|
||||
mat3 modelview_normal = mat3(scene_data.view_matrix) * model_normal_matrix;
|
||||
mat4 read_view_matrix = scene_data.view_matrix;
|
||||
vec2 read_viewport_size = scene_data.viewport_size;
|
||||
|
||||
{
|
||||
#CODE : VERTEX
|
||||
@@ -823,7 +825,8 @@ void fragment_shader(in SceneData scene_data) {
|
||||
inv_view_matrix[1][3] = 0.0;
|
||||
inv_view_matrix[2][3] = 0.0;
|
||||
#endif
|
||||
|
||||
mat4 read_view_matrix = scene_data.view_matrix;
|
||||
vec2 read_viewport_size = scene_data.viewport_size;
|
||||
{
|
||||
#CODE : FRAGMENT
|
||||
}
|
||||
|
||||
@@ -342,6 +342,8 @@ void main() {
|
||||
|
||||
mat4 modelview = scene_data.view_matrix * model_matrix;
|
||||
mat3 modelview_normal = mat3(scene_data.view_matrix) * model_normal_matrix;
|
||||
mat4 read_view_matrix = scene_data.view_matrix;
|
||||
vec2 read_viewport_size = scene_data.viewport_size;
|
||||
|
||||
{
|
||||
#CODE : VERTEX
|
||||
@@ -771,6 +773,9 @@ void main() {
|
||||
inv_view_matrix[2][3] = 0.0;
|
||||
#endif
|
||||
|
||||
mat4 read_view_matrix = scene_data.view_matrix;
|
||||
vec2 read_viewport_size = scene_data.viewport_size;
|
||||
|
||||
{
|
||||
#CODE : FRAGMENT
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define USING_MOBILE_RENDERER
|
||||
/* don't exceed 128 bytes!! */
|
||||
/* put instance data into our push content, not a array */
|
||||
layout(push_constant, std430) uniform DrawCall {
|
||||
|
||||
@@ -70,6 +70,21 @@ void light_compute(vec3 N, vec3 L, vec3 V, float A, vec3 light_color, bool is_di
|
||||
|
||||
mat4 inv_view_matrix = scene_data_block.data.inv_view_matrix;
|
||||
|
||||
#ifdef USING_MOBILE_RENDERER
|
||||
mat4 read_model_matrix = draw_call.transform;
|
||||
#else
|
||||
mat4 read_model_matrix = instances.data[instance_index_interp].transform;
|
||||
#endif
|
||||
|
||||
mat4 read_view_matrix = scene_data_block.data.view_matrix;
|
||||
|
||||
#undef projection_matrix
|
||||
#define projection_matrix scene_data_block.data.projection_matrix
|
||||
#undef inv_projection_matrix
|
||||
#define inv_projection_matrix scene_data_block.data.inv_projection_matrix
|
||||
|
||||
vec2 read_viewport_size = scene_data_block.data.viewport_size;
|
||||
|
||||
vec3 normal = N;
|
||||
vec3 light = L;
|
||||
vec3 view = V;
|
||||
|
||||
Reference in New Issue
Block a user