From: Mikko Rasa Date: Sat, 20 Mar 2021 17:33:15 +0000 (+0200) Subject: Rearrange various uniforms to be declared in the file which uses them X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=a3c33df71e507380100069ad7ef802b61de351bb;p=libs%2Fgl.git Rearrange various uniforms to be declared in the file which uses them --- diff --git a/shaderlib/common.glsl b/shaderlib/common.glsl index 9e794f1d..f952c8bd 100644 --- a/shaderlib/common.glsl +++ b/shaderlib/common.glsl @@ -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) diff --git a/shaderlib/cooktorrance.glsl b/shaderlib/cooktorrance.glsl index c866058d..33035ee3 100644 --- a/shaderlib/cooktorrance.glsl +++ b/shaderlib/cooktorrance.glsl @@ -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; diff --git a/shaderlib/msp_interface.glsl b/shaderlib/msp_interface.glsl index 1c3029ef..e20e36dd 100644 --- a/shaderlib/msp_interface.glsl +++ b/shaderlib/msp_interface.glsl @@ -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 { diff --git a/shaderlib/phong.glsl b/shaderlib/phong.glsl index f9d8d1e7..482f895b 100644 --- a/shaderlib/phong.glsl +++ b/shaderlib/phong.glsl @@ -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; diff --git a/shaderlib/shadow.glsl b/shaderlib/shadow.glsl index 6f4acd27..f168fe79 100644 --- a/shaderlib/shadow.glsl +++ b/shaderlib/shadow.glsl @@ -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)