]> git.tdb.fi Git - libs/gl.git/commitdiff
Rearrange various uniforms to be declared in the file which uses them
authorMikko Rasa <tdb@tdb.fi>
Sat, 20 Mar 2021 17:33:15 +0000 (19:33 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 21 Mar 2021 15:40:22 +0000 (17:40 +0200)
shaderlib/common.glsl
shaderlib/cooktorrance.glsl
shaderlib/msp_interface.glsl
shaderlib/phong.glsl
shaderlib/shadow.glsl

index 9e794f1d2c17eca99c48f847bf0d91ba96235ac1..f952c8bd6c1cb34c647d869011ea51fd61d1ff29 100644 (file)
@@ -1,6 +1,14 @@
 import msp_interface;
 import shadow;
 
+uniform EnvMap
+{
+       mat3 env_eye_matrix;
+};
+
+uniform sampler2D normal_map;
+uniform samplerCube environment_map;
+
 layout(constant_id=auto) const bool use_normal_map = false;
 
 #pragma MSP stage(vertex)
index c866058de4dbd0c6dd06fd7b28ad72c25f5b7c44..33035ee3fa03a0b5b703ef692e710baeac336f5f 100644 (file)
@@ -2,6 +2,25 @@ import msp_interface;
 import common;
 import shadow;
 
+struct PbrMaterialParameters
+{
+       vec4 base_color;
+       vec4 emission;
+       float metalness;
+       float roughness;
+};
+
+uniform PbrMaterial
+{
+       PbrMaterialParameters pbr_material;
+};
+
+uniform sampler2D base_color_map;
+uniform sampler2D metalness_map;
+uniform sampler2D roughness_map;
+uniform sampler2D occlusion_map;
+uniform sampler2D emission_map;
+
 layout(constant_id=auto) const bool use_base_color_map = false;
 layout(constant_id=auto) const bool use_metalness_map = false;
 layout(constant_id=auto) const bool use_roughness_map = false;
index 1c3029ef343cbddb9a295951864300f9ac627b56..e20e36dd555014087999c0ef86324f7f68b6a222 100644 (file)
@@ -5,23 +5,6 @@ struct LightSourceParameters
        vec4 specular;
 };
 
-struct BasicMaterialParameters
-{
-       vec4 diffuse;
-       vec4 specular;
-       vec4 emission;
-       float shininess;
-       float reflectivity;
-};
-
-struct PbrMaterialParameters
-{
-       vec4 base_color;
-       vec4 emission;
-       float metalness;
-       float roughness;
-};
-
 struct ClipPlane
 {
        vec4 equation;
@@ -35,16 +18,6 @@ uniform Transform
        mat4 projection_matrix;
 };
 
-uniform BasicMaterial
-{
-       BasicMaterialParameters basic_material;
-};
-
-uniform PbrMaterial
-{
-       PbrMaterialParameters pbr_material;
-};
-
 uniform Lighting
 {
        // Declared as an array for compatibility reasons
@@ -57,30 +30,6 @@ uniform Lighting
        float fog_density;
 };
 
-uniform sampler2D diffuse_map;
-uniform sampler2D specular_map;
-uniform sampler2D shininess_map;
-uniform sampler2D reflectivity_map;
-uniform sampler2D base_color_map;
-uniform sampler2D metalness_map;
-uniform sampler2D roughness_map;
-uniform sampler2D occlusion_map;
-uniform sampler2D emission_map;
-uniform sampler2D normal_map;
-
-uniform sampler2DShadow shadow_map;
-uniform ShadowMap
-{
-       float shadow_darkness;
-       mat4 shd_eye_matrix;
-};
-
-uniform samplerCube environment_map;
-uniform EnvMap
-{
-       mat3 env_eye_matrix;
-};
-
 layout(constant_id=auto) const int max_clip_planes = 0;
 uniform Clipping
 {
index f9d8d1e72b971827401575a567fc7ba38f3943a9..482f895b44e3e80e50e92586a5c2144319b110c7 100644 (file)
@@ -2,6 +2,26 @@ import msp_interface;
 import common;
 import shadow;
 
+struct BasicMaterialParameters
+{
+       vec4 diffuse;
+       vec4 specular;
+       vec4 emission;
+       float shininess;
+       float reflectivity;
+};
+
+uniform BasicMaterial
+{
+       BasicMaterialParameters basic_material;
+};
+
+uniform sampler2D diffuse_map;
+uniform sampler2D specular_map;
+uniform sampler2D shininess_map;
+uniform sampler2D emission_map;
+uniform sampler2D reflectivity_map;
+
 layout(constant_id=auto) const bool use_diffuse_map = false;
 layout(constant_id=auto) const bool use_specular = false;
 layout(constant_id=auto) const bool use_specular_map = false;
index 6f4acd2786a6319c242d9ff8300a00ecc535d0a7..f168fe7955431869b25f90b8909192453929bcd0 100644 (file)
@@ -1,5 +1,13 @@
 import msp_interface;
 
+uniform ShadowMap
+{
+       float shadow_darkness;
+       mat4 shd_eye_matrix;
+};
+
+uniform sampler2DShadow shadow_map;
+
 layout(constant_id=auto) const bool use_shadow_map = false;
 
 #pragma MSP stage(vertex)