diff options
author | Dave Parks <davep@lindenlab.com> | 2022-09-09 20:56:22 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2022-09-09 20:56:22 -0500 |
commit | c822da9fe644e4a420caabb30a25b487ce75c099 (patch) | |
tree | 7d06f66a46c62dc5bbcf6cccbab8acfca552fdab /indra/newview/app_settings/shaders/class1/deferred | |
parent | dfe19c257dbb9d5af6f1e2961015e95847525412 (diff) |
SL-18095 WIP -- Allow mikktspace generator to add more vertices (skip re-welding step for now).
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl | 84 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl | 77 |
2 files changed, 26 insertions, 135 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl index 69019667de..ca304f749a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl @@ -25,61 +25,34 @@ /*[EXTRA_CODE_HERE]*/ -#define DEBUG_PBR_LIGHT_TYPE 0 // Output Diffuse=0.75, Emissive=0, ORM=0,0,0 - -#define DEBUG_BASIC 0 -#define DEBUG_VERTEX 0 -#define DEBUG_NORMAL_MAP 0 // Output packed normal map "as is" to diffuse -#define DEBUG_NORMAL_OUT 0 // Output unpacked normal to diffuse -#define DEBUG_ORM 0 // Output Occlusion Roughness Metal "as is" to diffuse -#define DEBUG_POSITION 0 - uniform sampler2D diffuseMap; //always in sRGB space uniform float metallicFactor; uniform float roughnessFactor; uniform vec3 emissiveColor; +uniform sampler2D bumpMap; +uniform sampler2D emissiveMap; +uniform sampler2D specularMap; // Packed: Occlusion, Metal, Roughness -#ifdef HAS_NORMAL_MAP - uniform sampler2D bumpMap; - VARYING vec3 vary_tangent; - flat in float vary_sign; -#endif - -#ifdef HAS_EMISSIVE_MAP - uniform sampler2D emissiveMap; -#endif - -#ifdef HAS_SPECULAR_MAP - uniform sampler2D specularMap; // Packed: Occlusion, Metal, Roughness -#endif - -uniform samplerCube environmentMap; -uniform mat3 env_mat; - -#ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_data[4]; -#else -#define frag_data gl_FragData -#endif VARYING vec3 vary_position; VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; -#ifdef HAS_NORMAL_MAP VARYING vec3 vary_normal; -VARYING vec2 vary_texcoord1; -#endif +VARYING vec3 vary_tangent; +flat in float vary_sign; -#ifdef HAS_SPECULAR_MAP - VARYING vec2 vary_texcoord2; -#endif +VARYING vec2 vary_texcoord0; +VARYING vec2 vary_texcoord1; +VARYING vec2 vary_texcoord2; uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlphaCutoff() vec2 encode_normal(vec3 n); vec3 linear_to_srgb(vec3 c); +uniform mat3 normal_matrix; + void main() { // IF .mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; @@ -94,11 +67,11 @@ void main() vec3 col = vertex_color.rgb * albedo.rgb; // from mikktspace.com - vec4 vNt = texture2D(bumpMap, vary_texcoord1.xy)*2.0-1.0; + vec3 vNt = texture2D(bumpMap, vary_texcoord1.xy).xyz*2.0-1.0; float sign = vary_sign; vec3 vN = vary_normal; vec3 vT = vary_tangent.xyz; - + vec3 vB = sign * cross(vN, vT); vec3 tnorm = normalize( vNt.x * vT + vNt.y * vB + vNt.z * vN ); @@ -107,49 +80,20 @@ void main() // occlusion 1.0 // roughness 0.0 // metal 0.0 -#ifdef HAS_SPECULAR_MAP vec3 spec = texture2D(specularMap, vary_texcoord2.xy).rgb; -#else - vec3 spec = vec3(1,0,0); -#endif spec.g *= roughnessFactor; spec.b *= metallicFactor; vec3 emissive = emissiveColor; -#ifdef HAS_EMISSIVE_MAP emissive *= texture2D(emissiveMap, vary_texcoord0.xy).rgb; -#endif - -#if DEBUG_PBR_LIGHT_TYPE - col.rgb = vec3(0.75); - emissive = vec3(0); - spec.rgb = vec3(0); -#endif -#if DEBUG_BASIC - col.rgb = vec3( 1, 0, 1 ); -#endif -#if DEBUG_VERTEX - col.rgb = vertex_color.rgb; -#endif -#if DEBUG_NORMAL_MAP - col.rgb = texture2D(bumpMap, vary_texcoord1.xy).rgb; -#endif -#if DEBUG_NORMAL_OUT - col.rgb = vary_normal; -#endif -#if DEBUG_ORM - col.rgb = linear_to_srgb(spec); -#endif -#if DEBUG_POSITION - col.rgb = vary_position.xyz; -#endif tnorm *= gl_FrontFacing ? 1.0 : -1.0; + //spec.rgb = vec3(1,1,0); //col = vec3(0,0,0); //emissive = vary_tangent.xyz*0.5+0.5; - //emissive = vec3(vary_sign*0.5+0.5); + //emissive = vec3(sign*0.5+0.5); // See: C++: addDeferredAttachments(), GLSL: softenLightF frag_data[0] = vec4(col, 0.0); // Diffuse frag_data[1] = vec4(emissive, vertex_color.a); // PBR sRGB Emissive diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl index e17d91af38..c90a17993f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl @@ -37,41 +37,24 @@ uniform mat3 normal_matrix; uniform mat4 modelview_projection_matrix; #endif -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - -#if !defined(HAS_SKIN) -uniform mat4 modelview_matrix; -#endif - -VARYING vec3 vary_position; - -#endif - uniform mat4 texture_matrix0; ATTRIBUTE vec3 position; ATTRIBUTE vec4 diffuse_color; ATTRIBUTE vec3 normal; -ATTRIBUTE vec2 texcoord0; - - -#ifdef HAS_NORMAL_MAP ATTRIBUTE vec4 tangent; +ATTRIBUTE vec2 texcoord0; ATTRIBUTE vec2 texcoord1; +ATTRIBUTE vec2 texcoord2; +VARYING vec2 vary_texcoord0; VARYING vec2 vary_texcoord1; -#endif - -#ifdef HAS_SPECULAR_MAP -ATTRIBUTE vec2 texcoord2; VARYING vec2 vary_texcoord2; -#endif VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; + VARYING vec3 vary_tangent; flat out float vary_sign; - VARYING vec3 vary_normal; void main() @@ -83,64 +66,28 @@ void main() vec3 pos = (mat*vec4(position.xyz,1.0)).xyz; -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - vary_position = pos; -#endif - gl_Position = projection_matrix*vec4(pos,1.0); #else //transform vertex gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); - #endif vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; - -#ifdef HAS_NORMAL_MAP vary_texcoord1 = (texture_matrix0 * vec4(texcoord1,0,1)).xy; -#endif - -#ifdef HAS_SPECULAR_MAP vary_texcoord2 = (texture_matrix0 * vec4(texcoord2,0,1)).xy; -#endif #ifdef HAS_SKIN - vec3 n = normalize((mat*vec4(normal.xyz+position.xyz,1.0)).xyz-pos.xyz); -#ifdef HAS_NORMAL_MAP - vec3 t = normalize((mat*vec4(tangent.xyz+position.xyz,1.0)).xyz-pos.xyz); - vec3 b = cross(n, t)*tangent.w; - - //vary_mat0 = vec3(t.x, b.x, n.x); - //vary_mat1 = vec3(t.y, b.y, n.y); - //vary_mat2 = vec3(t.z, b.z, n.z); -#else //HAS_NORMAL_MAP -vary_normal = n; -#endif //HAS_NORMAL_MAP + vec3 n = (mat*vec4(normal.xyz+position.xyz,1.0)).xyz-pos.xyz; + vec3 t = (mat*vec4(tangent.xyz+position.xyz,1.0)).xyz-pos.xyz; #else //HAS_SKIN - vec3 n = normalize(normal_matrix * normal); -#ifdef HAS_NORMAL_MAP - vec3 t = normalize(normal_matrix * tangent.xyz); - vary_tangent = t; - vary_sign = tangent.w; - vary_normal = n; + vec3 n = normal_matrix * normal; + vec3 t = normal_matrix * tangent.xyz; +#endif - //vec3 b = cross(n,t)*tangent.w; - //vec3 t = cross(b,n) * binormal.w; - - //vary_mat0 = vec3(t.x, b.x, n.x); - //vary_mat1 = vec3(t.y, b.y, n.y); - //vary_mat2 = vec3(t.z, b.z, n.z); -#else //HAS_NORMAL_MAP - vary_normal = n; -#endif //HAS_NORMAL_MAP -#endif //HAS_SKIN + vary_tangent = normalize(t); + vary_sign = tangent.w; + vary_normal = normalize(n); vertex_color = diffuse_color; - -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) -#if !defined(HAS_SKIN) - vary_position = (modelview_matrix*vec4(position.xyz, 1.0)).xyz; -#endif -#endif } |