Merge branch 'DRTVWR-559' of bitbucket.org:lindenlab/viewer into SL-17967
commit
6c4ff3f9c8
|
|
@ -52,6 +52,9 @@ float calcLegacyDistanceAttenuation(float distance, float falloff)
|
|||
{
|
||||
float dist_atten = 1.0 - clamp((distance + falloff)/(1.0 + falloff), 0.0, 1.0);
|
||||
dist_atten *= dist_atten;
|
||||
|
||||
// Tweak falloff slightly to match pre-EEP attenuation
|
||||
// NOTE: this magic number also shows up in a great many other places, search for dist_atten *= to audit
|
||||
dist_atten *= 2.0;
|
||||
return dist_atten;
|
||||
}
|
||||
|
|
@ -303,7 +306,7 @@ vec2 getScreenXY(vec4 clip)
|
|||
|
||||
// Color utils
|
||||
|
||||
vec3 colorized_dot(float x)
|
||||
vec3 colorize_dot(float x)
|
||||
{
|
||||
if (x > 0.0) return vec3( 0, x, 0 );
|
||||
if (x < 0.0) return vec3(-x, 0, 0 );
|
||||
|
|
|
|||
|
|
@ -68,6 +68,9 @@ vec2 getScreenXY(vec4 clip);
|
|||
void initMaterial( vec3 diffuse, vec3 packedORM, out float alphaRough, out vec3 c_diff, out vec3 reflect0, out vec3 reflect90, out float specWeight );
|
||||
vec3 srgb_to_linear(vec3 c);
|
||||
|
||||
// Util
|
||||
vec3 hue_to_rgb(float hue);
|
||||
|
||||
void main()
|
||||
{
|
||||
#if defined(LOCAL_LIGHT_KILL)
|
||||
|
|
|
|||
|
|
@ -188,6 +188,7 @@ vec3 srgb_to_linear(vec3 c);
|
|||
|
||||
// Debug Utils
|
||||
vec3 BRDFDiffuse(vec3 color);
|
||||
vec3 colorize_dot(float x);
|
||||
vec3 fresnelSchlick( vec3 reflect0, vec3 reflect90, float vh);
|
||||
float D_GGX( float nh, float alphaRough );
|
||||
float V_GGX( float nl, float nv, float alphaRough );
|
||||
|
|
@ -288,9 +289,12 @@ void main()
|
|||
vec3 b = cross( n,t);
|
||||
vec3 reflectVN = normalize(reflect(-v,n));
|
||||
|
||||
float dotNV = clamp(dot(n,v),0,1);
|
||||
float dotTV = clamp(dot(t,v),0,1);
|
||||
float dotBV = clamp(dot(b,v),0,1);
|
||||
vec3 h, l;
|
||||
float nh, nl, nv, vh, lightDist;
|
||||
calcHalfVectors(light_dir, n, v, h, l, nh, nl, nv, vh, lightDist);
|
||||
|
||||
float tv = clamp(dot(t,v),0,1);
|
||||
float bv = clamp(dot(b,v),0,1);
|
||||
|
||||
// Reference: getMetallicRoughnessInfo
|
||||
vec3 base = linear_to_srgb(diffuse.rgb);
|
||||
|
|
@ -303,10 +307,10 @@ void main()
|
|||
#endif
|
||||
|
||||
// Common to RadianceGGX and RadianceLambertian
|
||||
vec2 brdfPoint = clamp(vec2(dotNV, perceptualRough), vec2(0,0), vec2(1,1));
|
||||
vec2 brdfPoint = clamp(vec2(nv, perceptualRough), vec2(0,0), vec2(1,1));
|
||||
vec2 vScaleBias = getGGX( brdfPoint); // Environment BRDF: scale and bias applied to reflect0
|
||||
vec3 fresnelR = max(vec3(1.0 - perceptualRough), reflect0) - reflect0; // roughness dependent fresnel
|
||||
vec3 kSpec = reflect0 + fresnelR*pow(1.0 - dotNV, 5.0);
|
||||
vec3 kSpec = reflect0 + fresnelR*pow(1.0 - nv, 5.0);
|
||||
|
||||
// Reference: getIBLRadianceGGX
|
||||
// https://forum.substance3d.com/index.php?topic=3243.0
|
||||
|
|
@ -351,21 +355,18 @@ void main()
|
|||
colorSpec *= ao;
|
||||
|
||||
// Add in sun/moon reflection
|
||||
vec3 h, l;
|
||||
float nh, nl, nv, vh, lightDist;
|
||||
calcHalfVectors(light_dir, n, v, h, l, nh, nl, nv, vh, lightDist);
|
||||
|
||||
if (nl > 0.0 || nv > 0.0)
|
||||
{
|
||||
vec3 sunColor = srgb_to_linear(sunlit * 2.0); // NOTE: *2.0 Midday should have strong sunlight
|
||||
float scale = 4.9;
|
||||
vec3 sunColor = srgb_to_linear(sunlit * scale); // NOTE: Midday should have strong sunlight
|
||||
#if DEBUG_PBR_SUN_FULL_BRIGHT
|
||||
sunColor = vec3(1);
|
||||
#endif
|
||||
// scol = sun shadow
|
||||
vec3 intensity = ambocc * sunColor * nl * scol;
|
||||
vec3 sunDiffuse = intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh);
|
||||
vec3 sunSpec = intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh);
|
||||
bloom = dot(sunSpec, sunSpec) / 8.0;
|
||||
vec3 sunDiffuse = base * intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh);
|
||||
vec3 sunSpec = intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh);
|
||||
bloom = dot(sunSpec, sunSpec) / (scale * scale * scale);
|
||||
|
||||
#if DEBUG_PBR_SUN_SPEC_FRESNEL
|
||||
colorDiffuse = vec3(0);
|
||||
|
|
@ -515,13 +516,13 @@ void main()
|
|||
color.rgb = b;
|
||||
#endif
|
||||
#if DEBUG_PBR_DOT_NV
|
||||
color.rgb = vec3(dotNV);
|
||||
color.rgb = vec3(nv);
|
||||
#endif
|
||||
#if DEBUG_PBR_DOT_TV
|
||||
color.rgb = vec3(dotTV);
|
||||
color.rgb = vec3(tv);
|
||||
#endif
|
||||
#if DEBUG_PBR_DOT_BV
|
||||
color.rgb = vec3(dotBV);
|
||||
color.rgb = vec3(bv);
|
||||
#endif
|
||||
|
||||
#if DEBUG_PBR_AVG
|
||||
|
|
|
|||
Loading…
Reference in New Issue