You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-14 13:41:12 +00:00
Refactor GLSL shader compilation
-Used a more consistent set of keywords for the shader -Remove all harcoded entry points -Re-wrote the GLSL shader parser, new system is more flexible. Allows any entry point organization. -Entry point for sky shaders is now sky(). -Entry point for particle shaders is now process().
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
#version 450
|
||||
|
||||
VERSION_DEFINES
|
||||
#VERSION_DEFINES
|
||||
|
||||
#include "scene_forward_clustered_inc.glsl"
|
||||
|
||||
@@ -81,11 +81,11 @@ layout(location = 5) out vec3 tangent_interp;
|
||||
layout(location = 6) out vec3 binormal_interp;
|
||||
#endif
|
||||
|
||||
#ifdef USE_MATERIAL_UNIFORMS
|
||||
#ifdef MATERIAL_UNIFORMS_USED
|
||||
layout(set = MATERIAL_UNIFORM_SET, binding = 0, std140) uniform MaterialUniforms{
|
||||
/* clang-format off */
|
||||
MATERIAL_UNIFORMS
|
||||
/* clang-format on */
|
||||
|
||||
#MATERIAL_UNIFORMS
|
||||
|
||||
} material;
|
||||
#endif
|
||||
|
||||
@@ -99,11 +99,7 @@ layout(location = 8) out float dp_clip;
|
||||
|
||||
layout(location = 9) out flat uint instance_index;
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
VERTEX_SHADER_GLOBALS
|
||||
|
||||
/* clang-format on */
|
||||
#GLOBALS
|
||||
|
||||
void main() {
|
||||
vec4 instance_custom = vec4(0.0);
|
||||
@@ -230,11 +226,7 @@ void main() {
|
||||
mat3 modelview_normal = mat3(scene_data.inv_camera_matrix) * world_normal_matrix;
|
||||
|
||||
{
|
||||
/* clang-format off */
|
||||
|
||||
VERTEX_SHADER_CODE
|
||||
|
||||
/* clang-format on */
|
||||
#CODE : VERTEX
|
||||
}
|
||||
|
||||
// using local coordinates (default)
|
||||
@@ -325,7 +317,7 @@ VERTEX_SHADER_CODE
|
||||
|
||||
#version 450
|
||||
|
||||
VERSION_DEFINES
|
||||
#VERSION_DEFINES
|
||||
|
||||
#include "scene_forward_clustered_inc.glsl"
|
||||
|
||||
@@ -372,19 +364,15 @@ layout(location = 9) in flat uint instance_index;
|
||||
#define LIGHT_TRANSMITTANCE_USED
|
||||
#endif
|
||||
|
||||
#ifdef USE_MATERIAL_UNIFORMS
|
||||
#ifdef MATERIAL_UNIFORMS_USED
|
||||
layout(set = MATERIAL_UNIFORM_SET, binding = 0, std140) uniform MaterialUniforms{
|
||||
/* clang-format off */
|
||||
MATERIAL_UNIFORMS
|
||||
/* clang-format on */
|
||||
|
||||
#MATERIAL_UNIFORMS
|
||||
|
||||
} material;
|
||||
#endif
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
FRAGMENT_SHADER_GLOBALS
|
||||
|
||||
/* clang-format on */
|
||||
#GLOBALS
|
||||
|
||||
#ifdef MODE_RENDER_DEPTH
|
||||
|
||||
@@ -581,18 +569,14 @@ void light_compute(vec3 N, vec3 L, vec3 V, vec3 light_color, float attenuation,
|
||||
#endif
|
||||
inout vec3 diffuse_light, inout vec3 specular_light) {
|
||||
|
||||
#if defined(USE_LIGHT_SHADER_CODE)
|
||||
#if defined(LIGHT_CODE_USED)
|
||||
// light is written by the light shader
|
||||
|
||||
vec3 normal = N;
|
||||
vec3 light = L;
|
||||
vec3 view = V;
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
LIGHT_SHADER_CODE
|
||||
|
||||
/* clang-format on */
|
||||
#CODE : LIGHT
|
||||
|
||||
#else
|
||||
|
||||
@@ -794,7 +778,7 @@ LIGHT_SHADER_CODE
|
||||
alpha = min(alpha, clamp(1.0 - attenuation), 0.0, 1.0));
|
||||
#endif
|
||||
|
||||
#endif //defined(USE_LIGHT_SHADER_CODE)
|
||||
#endif //defined(LIGHT_CODE_USED)
|
||||
}
|
||||
|
||||
#ifndef USE_NO_SHADOWS
|
||||
@@ -1925,11 +1909,7 @@ void main() {
|
||||
#endif // ALPHA_ANTIALIASING_EDGE_USED
|
||||
|
||||
{
|
||||
/* clang-format off */
|
||||
|
||||
FRAGMENT_SHADER_CODE
|
||||
|
||||
/* clang-format on */
|
||||
#CODE : FRAGMENT
|
||||
}
|
||||
|
||||
#ifdef LIGHT_TRANSMITTANCE_USED
|
||||
|
||||
Reference in New Issue
Block a user