diff options
author | Ptolemy <ptolemy@lindenlab.com> | 2022-05-06 09:48:49 -0700 |
---|---|---|
committer | Ptolemy <ptolemy@lindenlab.com> | 2022-05-06 09:48:49 -0700 |
commit | 663e121f2f41b923951f122157744a529eb4bc89 (patch) | |
tree | d5a37484394e242a90f8857666a244f6d154ee28 /indra/newview/app_settings/shaders/class1/deferred | |
parent | 415380b140adf52611639def126112e7c2b7d35d (diff) |
SL-17274: Add debug rendering to pbr shader
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl | 76 |
1 files changed, 66 insertions, 10 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl index ac3c9dd054..cb9cc4958a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl @@ -25,6 +25,19 @@ /*[EXTRA_CODE_HERE]*/ +#define DEBUG_BASIC 1 +#define DEBUG_COLOR 0 +#define DEBUG_NORMAL 0 +#define DEBUG_POSITION 0 +#define DEBUG_REFLECT_VEC 0 +#define DEBUG_REFLECT_COLOR 0 + +#ifdef HAS_SPECULAR_MAP +uniform sampler2D specularMap; +#endif +uniform samplerCube environmentMap; +uniform mat3 env_mat; + #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[3]; #else @@ -35,19 +48,62 @@ VARYING vec3 vary_position; VARYING vec3 vary_normal; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; +#ifdef HAS_SPECULAR_MAP +VARYING vec2 vary_texcoord2; +#endif vec2 encode_normal(vec3 n); vec3 linear_to_srgb(vec3 c); -void main() +struct PBR { - vec3 col = vertex_color.rgb * diffuseLookup(vary_texcoord0.xy).rgb; - - vec3 spec; - spec.rgb = vec3(vertex_color.a); -col.rgb = vec3( 1, 0, 1 ); // DEBUG - frag_data[0] = vec4(col, 0.0); - frag_data[1] = vec4(spec, vertex_color.a); // spec - vec3 nvn = normalize(vary_normal); - frag_data[2] = vec4(encode_normal(nvn.xyz), vertex_color.a, 0.0); + float LdotH; // Light and Half + float NdotL; // Normal and Light + float NdotH; // Normal and Half + float VdotH; // View and Half +}; + +const float M_PI = 3.141592653589793; + +void main() +{ + vec3 col = vertex_color.rgb * diffuseLookup(vary_texcoord0.xy).rgb; + +//#ifdef HAS_SPECULAR_MAP +//#else + vec4 norm = vec4(0,0,0,1.0); + vec3 tnorm = vary_normal; +//#endif + norm.xyz = normalize(tnorm.xyz); + + vec3 spec; + spec.rgb = vec3(vertex_color.a); + + vec3 pos = vary_position; + vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); + vec3 env_vec = env_mat * refnormpersp; + vec3 reflected_color = textureCube(environmentMap, env_vec).rgb; + +#if DEBUG_BASIC + col.rgb = vec3( 1, 0, 1 ); // DEBUG +#endif +#if DEBUG_COLOR + col.rgb = vertex_color.rgb; +#endif +#if DEBUG_NORMAL + col.rgb = vary_normal; +#endif +#if DEBUG_POSITION + col.rgb = vary_position.xyz; +#endif +#if DEBUG_REFLECT_VEC + col.rgb = refnormpersp; +#endif +#if DEBUG_REFLECT_COLOR + col.rgb = reflected_color; +#endif + + frag_data[0] = vec4(col, 0.0); + frag_data[1] = vec4(spec, vertex_color.a); // spec + frag_data[2] = vec4(encode_normal(norm.xyz), vertex_color.a, 0.0); } |