summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class3
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class3')
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl167
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl97
5 files changed, 38 insertions, 234 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
index d8175aa260..3b57821758 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
@@ -112,7 +112,7 @@ void main()
if (dist <= 1.0 && nl > 0.0)
{
float dist_atten = calcLegacyDistanceAttenuation(dist, falloff);
- vec3 intensity = dist_atten * nl * lightColor;
+ vec3 intensity = dist_atten * nl * lightColor * 2.0;
colorDiffuse += intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh);
colorSpec += intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh);
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
index bc4b4eb7e1..cabc175da9 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
@@ -28,40 +28,6 @@
/*[EXTRA_CODE_HERE]*/
-#define DEBUG_ANY_LIGHT_TYPE 0 // Output blue light cone
-#define DEBUG_LEG_LIGHT_TYPE 0 // Show Legacy objects in blue
-#define DEBUG_PBR_LIGHT_TYPE 0 // Ouput gray if PBR multiSpot lights object
-#define DEBUG_PBR_SPOT 0
-#define DEBUG_PBR_SPOT_DIFFUSE 0 // PBR diffuse lit
-#define DEBUG_PBR_SPOT_SPECULAR 0 // PBR spec lit
-
-#define DEBUG_LIGHT_FRUSTUM 0 // If projected light effects a surface
-#define DEBUG_AMBIANCE_COLOR 0 // calculated ambiance color
-#define DEBUG_AMBIANCE_AOE 0 // area of effect using inverse ambiance color
-#define DEBUG_AMBIANCE_FINAL 0 // light color * ambiance color
-#define DEBUG_NOISE 0 // monochrome noise
-#define DEBUG_SHADOW 0 // Show inverted shadow
-#define DEBUG_SPOT_DIFFUSE 0 // dot(n,l) * dist_atten
-#define DEBUG_SPOT_NL 0 // monochome area effected by light
-#define DEBUG_SPOT_SPEC_POS 0
-#define DEBUG_SPOT_REFLECTION 0 // color: pos reflected along n
-#define DEBUG_SPOT_ZERO 0 // Output zero for spotlight
-
-#define DEBUG_PBR_LIGHT_H 0 // Half vector
-#define DEBUG_PBR_LIHGT_L 0 // Light vector
-#define DEBUG_PBR_LIGHT_NH 0 // colorized dot(n,h)
-#define DEBUG_PBR_LIGHT_NL 0 // colorized dot(n,l)
-#define DEBUG_PBR_LIGHT_NV 0 // colorized dot(n,v)
-#define DEBUG_PBR_LIGHT_VH 0 // colorized dot(v,h)
-#define DEBUG_PBR_LIGHT_DIFFUSE_COLOR 0 // non PBR spotlight
-#define DEBUG_PBR_LIGHT_SPECULAR_COLOR 0 // non PBR spotlight
-#define DEBUG_PBR_LIGHT_INTENSITY 0 // Light intensity
-#define DEBUG_PBR_LIGHT_INTENSITY_NL 0 // Light intensity * dot(n,l)
-#define DEBUG_PBR_LIGHT_BRDF_DIFFUSE 0 // like "fullbright" if no "nl" factor
-#define DEBUG_PBR_LIGHT_BRDF_SPECULAR 0
-#define DEBUG_PBR_LIGHT_BRDF_FINAL 0 // BRDF Diffuse + BRDF Specular
-
-
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
@@ -211,93 +177,13 @@ void main()
colorSpec = shadow * lit * slit * BRDFSpecularGGX( reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh );
colorSpec += shadow * lit * BRDFSpecularGGX( reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh );
- #if DEBUG_PBR_SPOT_DIFFUSE
- colorDiffuse = dlit.rgb; colorSpec = vec3(0);
- #endif
- #if DEBUG_PBR_SPOT_SPECULAR
- colorDiffuse = vec3(0); colorSpec = slit.rgb;
- #endif
- #if DEBUG_PBR_SPOT
- colorDiffuse = dlit; colorSpec = vec3(0);
- colorDiffuse *= nl;
- colorDiffuse *= shadow;
- #endif
}
amb_rgb = getProjectedLightAmbiance( amb_da, dist_atten, lit, nl, 1.0, proj_tc.xy );
colorDiffuse += diffuse.rgb * amb_rgb;
- #if DEBUG_AMBIANCE_FINAL
- colorDiffuse = diffuse.rgb * amb_rgb; colorSpec = vec3(0);
- #endif
- #if DEBUG_LIGHT_FRUSTUM
- colorDiffuse = vec3(0,1,0); colorSpec = vec3(0);
- #endif
- #if DEBUG_NOISE
- float noise = texture2D(noiseMap, tc/128.0).b;
- colorDiffuse = vec3(noise); colorSpec = vec3(0);
- #endif
}
- #if DEBUG_PBR_LIGHT_TYPE
- colorDiffuse = vec3(0.5,0,0); colorSpec = vec3(0);
- #endif
-
- #if DEBUG_PBR_LIGHT_H
- colorDiffuse = h*0.5 + 0.5; colorSpec = vec3(0);
- #endif
- #if DEBUG_PBR_LIHGT_L
- colorDiffuse = l*0.5 + 0.5; colorSpec = vec3(0);
- #endif
- #if DEBUG_PBR_LIGHT_NH
- colorDiffuse = colorized_dot(nh); colorSpec = vec3(0);
- #endif
- #if DEBUG_PBR_LIGHT_NL
- colorDiffuse = colorized_dot(nl); colorSpec = vec3(0);
- #endif
- #if DEBUG_PBR_LIGHT_NV
- colorDiffuse = colorized_dot(nv); colorSpec = vec3(0);
- #endif
- #if DEBUG_PBR_LIGHT_VH
- colorDiffuse = colorized_dot(vh); colorSpec = vec3(0);
- #endif
- #if DEBUG_PBR_LIGHT_DIFFUSE_COLOR
- colorDiffuse = dlit;
- #endif
- #if DEBUG_PBR_LIGHT_SPECULAR_COLOR
- colorDiffuse = slit;
- #endif
- #if DEBUG_PBR_LIGHT_INTENSITY
- colorDiffuse = getLightIntensitySpot( color, size, lightDist, v ); colorSpec = vec3(0);
-// colorDiffuse = nl * dist_atten;
- #endif
- #if DEBUG_PBR_LIGHT_INTENSITY_NL
- colorDiffuse = getLightIntensitySpot( color, size, lightDist, v ) * nl; colorSpec = vec3(0);
- #endif
- #if DEBUG_PBR_LIGHT_BRDF_DIFFUSE
- vec3 c_diff, reflect0, reflect90;
- float alphaRough, specWeight;
- initMaterial( diffuse, packedORM, alphaRough, c_diff, reflect0, reflect90, specWeight );
-
- colorDiffuse = BRDFLambertian ( reflect0, reflect90, c_diff , specWeight, vh );
- colorSpec = vec3(0);
- #endif
- #if DEBUG_PBR_LIGHT_BRDF_SPECULAR
- vec3 c_diff, reflect0, reflect90;
- float alphaRough, specWeight;
- initMaterial( diffuse, packedORM, alphaRough, c_diff, reflect0, reflect90, specWeight );
-
- colorDiffuse = vec3(0);
- colorSpec = BRDFSpecularGGX( reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh );
- #endif
- #if DEBUG_PBR_LIGHT_BRDF_FINAL
- vec3 c_diff, reflect0, reflect90;
- float alphaRough, specWeight;
- initMaterial( diffuse, packedORM, alphaRough, c_diff, reflect0, reflect90, specWeight );
- colorDiffuse = nl * BRDFLambertian ( reflect0, reflect90, c_diff , specWeight, vh );
- colorSpec = nl * BRDFSpecularGGX( reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh );
- #endif
-
final_color = colorDiffuse + colorSpec;
}
else
@@ -326,9 +212,6 @@ void main()
amb_rgb = getProjectedLightAmbiance( amb_da, dist_atten, lit, nl, noise, proj_tc.xy );
final_color += diffuse.rgb * amb_rgb;
-#if DEBUG_LEG_LIGHT_TYPE
- final_color = vec3(0,0,0.5);
-#endif
}
if (spec.a > 0.0)
@@ -376,58 +259,8 @@ void main()
}
}
}
- #if DEBUG_SPOT_REFLECTION
- final_color = ref;
- #endif
- }
-
-#if DEBUG_LIGHT_FRUSTUM
- if (proj_tc.x > 0.0 && proj_tc.x < 1.0
- && proj_tc.y > 0.0 && proj_tc.y < 1.0)
- {
- final_color = vec3(0,0,1);
}
-#endif
- }
-
-#if DEBUG_AMBIANCE_AOE
- if (proj_tc.x > 0.0 && proj_tc.x < 1.0
- && proj_tc.y > 0.0 && proj_tc.y < 1.0)
- {
- final_color = 1.0 - amb_rgb;
- }
-#endif
-#if DEBUG_AMBIANCE_COLOR
- if (proj_tc.x > 0.0 && proj_tc.x < 1.0
- && proj_tc.y > 0.0 && proj_tc.y < 1.0)
- {
- final_color = amb_rgb;
}
-#endif
-#if DEBUG_SHADOW
- final_color = 1.0 - vec3(shadow);
-#endif
-#if DEBUG_SPOT_DIFFUSE
- final_color = vec3(nl * dist_atten);
-#endif
-#if DEBUG_SPOT_NL
- final_color =vec3(nl);
-#endif
-#if DEBUG_SPOT_SPEC_POS
- vec3 ref = reflect(normalize(pos), n);
- vec3 pdelta = proj_p-pos;
- float ds = dot(ref, proj_n);
- final_color = pos + ref * dot(pdelta, proj_n)/ds;
-#endif
-#if DEBUG_SPOT_REFLECTION
- final_color = reflect(normalize(pos), n);
-#endif
-#if DEBUG_SPOT_ZERO
- final_color = vec3(0,0,0);
-#endif
-#if DEBUG_ANY_LIGHT_TYPE
- final_color = vec3(0,0,0.3333);
-#endif
//not sure why, but this line prevents MATBUG-194
final_color = max(final_color, vec3(0.0));
diff --git a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
index 509f9f6dd0..0472f08852 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
@@ -109,7 +109,7 @@ void main()
if (nl > 0.0)
{
- vec3 intensity = dist_atten * nl * lightColor; // Legacy attenuation
+ vec3 intensity = dist_atten * nl * lightColor * 2.0; // Legacy attenuation
colorDiffuse += intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh);
colorSpec += intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh);
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
index 3ff039261b..37fe5f53a2 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
@@ -524,14 +524,14 @@ void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, inout vec3 l
vec3 pos, vec3 norm, float glossiness, float envIntensity)
{
// TODO - don't hard code lods
- float reflection_lods = 8;
+ float reflection_lods = 7;
preProbeSample(pos);
vec3 refnormpersp = reflect(pos.xyz, norm.xyz);
ambenv = sampleProbeAmbient(pos, norm);
- if (glossiness > 0.0)
+ //if (glossiness > 0.0)
{
float lod = (1.0-glossiness)*reflection_lods;
glossenv = sampleProbes(pos, normalize(refnormpersp), lod, 1.f);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 1a7e11a1cd..6dd140bff3 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -89,34 +89,21 @@ vec4 applyWaterFogView(vec3 pos, vec4 color);
#endif
// PBR interface
-void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float nh, out float nl, out float nv, out float vh, out float lightDist);
-void initMaterial( vec3 diffuse, vec3 packedORM,
- out float alphaRough, out vec3 c_diff, out vec3 reflect0, out vec3 reflect90, out float specWeight );
-// perform PBR image based lighting according to GLTF spec
-// all parameters are in linear space
-void pbrIbl(out vec3 colorDiffuse, // diffuse color output
- out vec3 colorSpec, // specular color output,
+vec3 pbrIbl(vec3 diffuseColor,
+ vec3 specularColor,
vec3 radiance, // radiance map sample
vec3 irradiance, // irradiance map sample
float ao, // ambient occlusion factor
- float nv,
- float perceptualRough, // roughness factor
- float gloss, // 1.0 - roughness factor
- vec3 reflect0,
- vec3 c_diff);
-
-void pbrDirectionalLight(inout vec3 colorDiffuse,
- inout vec3 colorSpec,
- vec3 sunlit,
- float scol,
- vec3 reflect0,
- vec3 reflect90,
- vec3 c_diff,
- float alphaRough,
- float vh,
- float nl,
- float nv,
- float nh);
+ float nv, // normal dot view vector
+ float perceptualRoughness);
+
+vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
+ float perceptualRoughness,
+ float metallic,
+ vec3 n, // normal
+ vec3 v, // surface point to camera
+ vec3 l); //surface point to light
+
void main()
{
@@ -160,51 +147,34 @@ void main()
bool hasPBR = GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR);
if (hasPBR)
{
- // 5.22.2. material.pbrMetallicRoughness.baseColorTexture
- // The first three components (RGB) MUST be encoded with the sRGB transfer function.
- //
- // 5.19.7. material.emissiveTexture
- // This texture contains RGB components encoded with the sRGB transfer function.
- //
- // 5.22.5. material.pbrMetallicRoughness.metallicRoughnessTexture
- // These values MUST be encoded with a linear transfer function.
-
- vec3 colorDiffuse = vec3(0);
- vec3 colorEmissive = spec.rgb; // PBR sRGB Emissive. See: pbropaqueF.glsl
- vec3 colorSpec = vec3(0);
-
- vec3 packedORM = texture2DRect(emissiveRect, tc).rgb; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
- float IOR = 1.5; // default Index Of Refraction 1.5 (dielectrics)
- float ao = packedORM.r;
- float metal = packedORM.b;
- vec3 v = -normalize(pos.xyz);
- vec3 n = norm.xyz;
-
- vec3 h, l;
- float nh, nl, nv, vh, lightDist;
- calcHalfVectors(light_dir, n, v, h, l, nh, nl, nv, vh, lightDist);
-
- float perceptualRough = packedORM.g; // NOTE: do NOT clamp here to be consistent with Blender, Blender is wrong and Substance is right
-
- vec3 c_diff, reflect0, reflect90;
- float alphaRough, specWeight;
- initMaterial( diffuse.rgb, packedORM, alphaRough, c_diff, reflect0, reflect90, specWeight );
+ vec3 orm = texture2DRect(emissiveRect, tc).rgb; //orm is packed into "emissiveRect" to keep the data in linear color space
+ float perceptualRoughness = orm.g;
+ float metallic = orm.b;
+ float ao = orm.r * ambocc;
- float gloss = 1.0 - perceptualRough;
+ vec3 colorEmissive = texture2DRect(specularRect, tc).rgb; //specularRect is sRGB sampler, result is in linear space
+
+ // PBR IBL
+ float gloss = 1.0 - perceptualRoughness;
vec3 irradiance = vec3(0);
vec3 radiance = vec3(0);
sampleReflectionProbes(irradiance, radiance, legacyenv, pos.xyz, norm.xyz, gloss, 0.0);
- irradiance = max(amblit,irradiance) * ambocc;
+ irradiance = max(srgb_to_linear(amblit),irradiance) * ambocc*4.0;
- pbrIbl(colorDiffuse, colorSpec, radiance, irradiance, ao, nv, perceptualRough, gloss, reflect0, c_diff);
+ vec3 f0 = vec3(0.04);
+ vec3 baseColor = diffuse.rgb;
- // Add in sun/moon punctual light
- if (nl > 0.0 || nv > 0.0)
- {
- pbrDirectionalLight(colorDiffuse, colorSpec, srgb_to_linear(sunlit), scol, reflect0, reflect90, c_diff, alphaRough, vh, nl, nv, nh);
- }
+ vec3 diffuseColor = baseColor.rgb*(vec3(1.0)-f0);
+ diffuseColor *= 1.0 - metallic;
+
+ vec3 specularColor = mix(f0, baseColor.rgb, metallic);
- color.rgb = colorDiffuse + colorEmissive + colorSpec;
+ vec3 v = -normalize(pos.xyz);
+ float NdotV = clamp(abs(dot(norm.xyz, v)), 0.001, 1.0);
+
+ color.rgb += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, perceptualRoughness);
+ color.rgb += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm.xyz, v, normalize(light_dir)) * sunlit*8.0 * scol;
+ color.rgb += colorEmissive;
color = linear_to_srgb(color);
color *= atten.r;
@@ -212,6 +182,7 @@ void main()
color = scaleSoftClipFrag(color);
color = srgb_to_linear(color);
+
frag_color.rgb = color.rgb; //output linear since local lights will be added to this shader's results
}
else