diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred')
9 files changed, 59 insertions, 118 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index cf9ce646d1..fe796a054d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -52,9 +52,6 @@ VARYING vec2 vary_texcoord2;  VARYING vec2 vary_texcoord3;  VARYING float altitude_blend_factor; -/// Soft clips the light with a gamma correction -vec3 scaleSoftClip(vec3 light); -  vec4 cloudNoise(vec2 uv)  {     vec4 a = texture2D(cloud_noise_texture, uv); @@ -119,7 +116,6 @@ void main()      color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient);      color.rgb= max(vec3(0), color.rgb);      color.rgb *= 2.0; -    color.rgb = scaleSoftClip(color.rgb);      /// Gamma correct for WL (soft clip effect).      frag_data[0] = vec4(color.rgb, alpha1); diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index 6ab966ae01..4bf16b50bf 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -74,7 +74,6 @@ const float ONE_OVER_PI = 0.3183098861;  vec3 srgb_to_linear(vec3 cs);  vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten); -vec3 scaleSoftClipFragLinear(vec3 light);  float calcLegacyDistanceAttenuation(float distance, float falloff)  { @@ -396,7 +395,7 @@ vec3 pbrIbl(vec3 diffuseColor,      specContrib = specular * ao; -	return (diffuse + specular*0.5) * ao;  //reduce by half to place in appropriate color space for atmospherics +	return (diffuse + specular) * ao;  }  vec3 pbrIbl(vec3 diffuseColor, @@ -562,16 +561,13 @@ vec3 pbrBaseLight(vec3 diffuseColor, vec3 specularColor, float metallic, vec3 v,      float NdotV = clamp(abs(dot(norm, v)), 0.001, 1.0);      vec3 ibl_spec; -    color += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, 0.2, ibl_spec); +    color += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, perceptualRoughness, ibl_spec);      color += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm, v, normalize(light_dir), specContrib) * sunlit * 2.75 * scol;      specContrib *= sunlit * 2.75 * scol;      specContrib += ibl_spec; -    color += colorEmissive*0.5; - -    color = atmosFragLightingLinear(color, additive, atten); -    color = scaleSoftClipFragLinear(color); +    color += colorEmissive;      return color;  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl index f0522850de..fb97cd95b4 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl @@ -27,14 +27,9 @@  /*[EXTRA_CODE_HERE]*/ -#ifdef DEFINE_GL_FRAGCOLOR  out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif  vec3 fullbrightAtmosTransport(vec3 light); -vec3 fullbrightScaleSoftClip(vec3 light);  VARYING vec4 vertex_color;  VARYING vec2 vary_texcoord0; @@ -46,8 +41,6 @@ void main()  	vec4 color = diffuseLookup(vary_texcoord0.xy)*vertex_color;  	color.rgb = fullbrightAtmosTransport(color.rgb); -	color.rgb = fullbrightScaleSoftClip(color.rgb); -  	frag_color = color;  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index afe504743d..3a15fd1111 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -88,8 +88,10 @@ void main()  #endif  #ifndef IS_HUD +    color.rgb = fullbrightAtmosTransport(color.rgb);      color.rgb = srgb_to_linear(color.rgb);  #endif +      frag_color.rgb = color.rgb;      frag_color.a   = color.a;  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl index a9e114dddc..e9515a9187 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl @@ -44,18 +44,10 @@ uniform mat4 modelview_matrix;  out vec3 vary_position; -uniform vec2 texture_base_color_scale; -uniform float texture_base_color_rotation; -uniform vec2 texture_base_color_offset; -uniform vec2 texture_normal_scale; -uniform float texture_normal_rotation; -uniform vec2 texture_normal_offset; -uniform vec2 texture_metallic_roughness_scale; -uniform float texture_metallic_roughness_rotation; -uniform vec2 texture_metallic_roughness_offset; -uniform vec2 texture_emissive_scale; -uniform float texture_emissive_rotation; -uniform vec2 texture_emissive_offset; +uniform vec4[2] texture_base_color_transform; +uniform vec4[2] texture_normal_transform; +uniform vec4[2] texture_metallic_roughness_transform; +uniform vec4[2] texture_emissive_transform;  out vec3 vary_fragcoord; @@ -78,7 +70,7 @@ out vec3 vary_tangent;  flat out float vary_sign;  out vec3 vary_normal; -vec2 texture_transform(vec2 vertex_texcoord, vec2 khr_gltf_scale, float khr_gltf_rotation, vec2 khr_gltf_offset, mat4 sl_animation_transform); +vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform);  void main() @@ -97,10 +89,10 @@ void main()      vary_fragcoord.xyz = vert.xyz + vec3(0,0,near_clip); -	base_color_texcoord = texture_transform(texcoord0, texture_base_color_scale, texture_base_color_rotation, texture_base_color_offset, texture_matrix0); -	normal_texcoord = texture_transform(texcoord0, texture_normal_scale, texture_normal_rotation, texture_normal_offset, texture_matrix0); -	metallic_roughness_texcoord = texture_transform(texcoord0, texture_metallic_roughness_scale, texture_metallic_roughness_rotation, texture_metallic_roughness_offset, texture_matrix0); -	emissive_texcoord = texture_transform(texcoord0, texture_emissive_scale, texture_emissive_rotation, texture_emissive_offset, texture_matrix0); +    base_color_texcoord = texture_transform(texcoord0, texture_base_color_transform, texture_matrix0); +    normal_texcoord = texture_transform(texcoord0, texture_normal_transform, texture_matrix0); +    metallic_roughness_texcoord = texture_transform(texcoord0, texture_metallic_roughness_transform, texture_matrix0); +    emissive_texcoord = texture_transform(texcoord0, texture_emissive_transform, texture_matrix0);  #ifdef HAS_SKIN  	vec3 n = (mat*vec4(normal.xyz+position.xyz,1.0)).xyz-pos.xyz; @@ -133,12 +125,8 @@ uniform mat4 modelview_matrix;  out vec3 vary_position; -uniform vec2 texture_base_color_scale; -uniform float texture_base_color_rotation; -uniform vec2 texture_base_color_offset; -uniform vec2 texture_emissive_scale; -uniform float texture_emissive_rotation; -uniform vec2 texture_emissive_offset; +uniform vec4[2] texture_base_color_transform; +uniform vec4[2] texture_emissive_transform;  in vec3 position;  in vec4 diffuse_color; @@ -149,7 +137,7 @@ out vec2 emissive_texcoord;  out vec4 vertex_color; -vec2 texture_transform(vec2 vertex_texcoord, vec2 khr_gltf_scale, float khr_gltf_rotation, vec2 khr_gltf_offset, mat4 sl_animation_transform); +vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform);  void main() @@ -159,8 +147,8 @@ void main()      gl_Position = vert;      vary_position = vert.xyz; -	base_color_texcoord = texture_transform(texcoord0, texture_base_color_scale, texture_base_color_rotation, texture_base_color_offset, texture_matrix0); -	emissive_texcoord = texture_transform(texcoord0, texture_emissive_scale, texture_emissive_rotation, texture_emissive_offset, texture_matrix0); +    base_color_texcoord = texture_transform(texcoord0, texture_base_color_transform, texture_matrix0); +    emissive_texcoord = texture_transform(texcoord0, texture_emissive_transform, texture_matrix0);  	vertex_color = diffuse_color;  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrglowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrglowV.glsl index b73d08cf0d..82a50a115c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbrglowV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbrglowV.glsl @@ -34,12 +34,8 @@ uniform mat4 modelview_projection_matrix;  uniform mat4 texture_matrix0; -uniform vec2 texture_base_color_scale; -uniform float texture_base_color_rotation; -uniform vec2 texture_base_color_offset; -uniform vec2 texture_emissive_scale; -uniform float texture_emissive_rotation; -uniform vec2 texture_emissive_offset; +uniform vec4[2] texture_base_color_transform; +uniform vec4[2] texture_emissive_transform;  in vec3 position;  in vec4 emissive; @@ -51,7 +47,7 @@ out vec2 emissive_texcoord;  out vec4 vertex_emissive; -vec2 texture_transform(vec2 vertex_texcoord, vec2 khr_gltf_scale, float khr_gltf_rotation, vec2 khr_gltf_offset, mat4 sl_animation_transform); +vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform);  void main()  { @@ -68,8 +64,8 @@ void main()      gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);   #endif -    base_color_texcoord = texture_transform(texcoord0, texture_base_color_scale, texture_base_color_rotation, texture_base_color_offset, texture_matrix0); -    emissive_texcoord = texture_transform(texcoord0, texture_emissive_scale, texture_emissive_rotation, texture_emissive_offset, texture_matrix0); +    base_color_texcoord = texture_transform(texcoord0, texture_base_color_transform, texture_matrix0); +    emissive_texcoord = texture_transform(texcoord0, texture_emissive_transform, texture_matrix0);      vertex_emissive = emissive;  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl index 6f50aefdab..e2c23ac8f0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl @@ -38,18 +38,10 @@ uniform mat4 modelview_projection_matrix;  #endif  uniform mat4 texture_matrix0; -uniform vec2 texture_base_color_scale; -uniform float texture_base_color_rotation; -uniform vec2 texture_base_color_offset; -uniform vec2 texture_normal_scale; -uniform float texture_normal_rotation; -uniform vec2 texture_normal_offset; -uniform vec2 texture_metallic_roughness_scale; -uniform float texture_metallic_roughness_rotation; -uniform vec2 texture_metallic_roughness_offset; -uniform vec2 texture_emissive_scale; -uniform float texture_emissive_rotation; -uniform vec2 texture_emissive_offset; +uniform vec4[2] texture_base_color_transform; +uniform vec4[2] texture_normal_transform; +uniform vec4[2] texture_metallic_roughness_transform; +uniform vec4[2] texture_emissive_transform;  in vec3 position;  in vec4 diffuse_color; @@ -68,7 +60,7 @@ out vec3 vary_tangent;  flat out float vary_sign;  out vec3 vary_normal; -vec2 texture_transform(vec2 vertex_texcoord, vec2 khr_gltf_scale, float khr_gltf_rotation, vec2 khr_gltf_offset, mat4 sl_animation_transform); +vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform);  void main()  { @@ -86,10 +78,10 @@ void main()  	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);   #endif -    base_color_texcoord = texture_transform(texcoord0, texture_base_color_scale, texture_base_color_rotation, texture_base_color_offset, texture_matrix0); -    normal_texcoord = texture_transform(texcoord0, texture_normal_scale, texture_normal_rotation, texture_normal_offset, texture_matrix0); -    metallic_roughness_texcoord = texture_transform(texcoord0, texture_metallic_roughness_scale, texture_metallic_roughness_rotation, texture_metallic_roughness_offset, texture_matrix0); -    emissive_texcoord = texture_transform(texcoord0, texture_emissive_scale, texture_emissive_rotation, texture_emissive_offset, texture_matrix0); +    base_color_texcoord = texture_transform(texcoord0, texture_base_color_transform, texture_matrix0); +    normal_texcoord = texture_transform(texcoord0, texture_normal_transform, texture_matrix0); +    metallic_roughness_texcoord = texture_transform(texcoord0, texture_metallic_roughness_transform, texture_matrix0); +    emissive_texcoord = texture_transform(texcoord0, texture_emissive_transform, texture_matrix0);  #ifdef HAS_SKIN  	vec3 n = (mat*vec4(normal.xyz+position.xyz,1.0)).xyz-pos.xyz; @@ -114,18 +106,10 @@ uniform mat4 modelview_projection_matrix;  uniform mat4 texture_matrix0; -uniform vec2 texture_base_color_scale; -uniform float texture_base_color_rotation; -uniform vec2 texture_base_color_offset; -uniform vec2 texture_normal_scale; -uniform float texture_normal_rotation; -uniform vec2 texture_normal_offset; -uniform vec2 texture_metallic_roughness_scale; -uniform float texture_metallic_roughness_rotation; -uniform vec2 texture_metallic_roughness_offset; -uniform vec2 texture_emissive_scale; -uniform float texture_emissive_rotation; -uniform vec2 texture_emissive_offset; +uniform vec4[2] texture_base_color_transform; +uniform vec4[2] texture_normal_transform; +uniform vec4[2] texture_metallic_roughness_transform; +uniform vec4[2] texture_emissive_transform;  in vec3 position;  in vec4 diffuse_color; @@ -136,15 +120,15 @@ out vec2 emissive_texcoord;  out vec4 vertex_color; -vec2 texture_transform(vec2 vertex_texcoord, vec2 khr_gltf_scale, float khr_gltf_rotation, vec2 khr_gltf_offset, mat4 sl_animation_transform); +vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform);  void main()  {      //transform vertex      gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);  -    base_color_texcoord = texture_transform(texcoord0, texture_base_color_scale, texture_base_color_rotation, texture_base_color_offset, texture_matrix0); -    emissive_texcoord = texture_transform(texcoord0, texture_emissive_scale, texture_emissive_rotation, texture_emissive_offset, texture_matrix0); +    base_color_texcoord = texture_transform(texcoord0, texture_base_color_transform, texture_matrix0); +    emissive_texcoord = texture_transform(texcoord0, texture_emissive_transform, texture_matrix0);      vertex_color = diffuse_color;  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index f0e940eb5f..383fcaa9a7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -44,9 +44,6 @@ vec3 linear_to_srgb(vec3 cl);  //===============================================================  // tone mapping taken from Khronos sample implementation  //=============================================================== -const float GAMMA = 2.2; -const float INV_GAMMA = 1.0 / GAMMA; -  // sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT  const mat3 ACESInputMat = mat3 @@ -65,29 +62,6 @@ const mat3 ACESOutputMat = mat3      -0.07367, -0.00605,  1.07602  ); - -// linear to sRGB approximation -// see http://chilliant.blogspot.com/2012/08/srgb-approximations-for-hlsl.html -vec3 linearTosRGB(vec3 color) -{ -    return pow(color, vec3(INV_GAMMA)); -} - - -// sRGB to linear approximation -// see http://chilliant.blogspot.com/2012/08/srgb-approximations-for-hlsl.html -vec3 sRGBToLinear(vec3 srgbIn) -{ -    return vec3(pow(srgbIn.xyz, vec3(GAMMA))); -} - - -vec4 sRGBToLinear(vec4 srgbIn) -{ -    return vec4(sRGBToLinear(srgbIn.xyz), srgbIn.w); -} - -  // ACES tone map (faster approximation)  // see: https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/  vec3 toneMapACES_Narkowicz(vec3 color) @@ -128,6 +102,7 @@ vec3 toneMapACES_Hill(vec3 color)  }  uniform float exposure; +uniform float gamma;  vec3 toneMap(vec3 color)  { @@ -145,11 +120,12 @@ vec3 toneMap(vec3 color)      // boost exposure as discussed in https://github.com/mrdoob/three.js/pull/19621      // this factor is based on the exposure correction of Krzysztof Narkowicz in his      // implemetation of ACES tone mapping -    color /= 0.6; +    color *= 1.0/0.6; +    //color /= 0.6;      color = toneMapACES_Hill(color);  #endif -    return linearTosRGB(color); +    return linear_to_srgb(color);  }  //=============================================================== @@ -192,16 +168,26 @@ float noise(vec2 x) {  //============================= + +vec3 legacyGamma(vec3 color) +{ +    color = 1. - clamp(color, vec3(0.), vec3(1.)); +    color = 1. - pow(color, vec3(gamma)); // s/b inverted already CPU-side + +    return color; +} +  void main()   {      //this is the one of the rare spots where diffuseRect contains linear color values (not sRGB)      vec4 diff = texture2D(diffuseRect, vary_fragcoord);      diff.rgb = toneMap(diff.rgb); -    vec2 tc = vary_fragcoord.xy*screen_res; - +    diff.rgb = legacyGamma(diff.rgb); +     +    vec2 tc = vary_fragcoord.xy*screen_res*4.0;      vec3 seed = (diff.rgb+vec3(1.0))*vec3(tc.xy, tc.x+tc.y);      vec3 nz = vec3(noise(seed.rg), noise(seed.gb), noise(seed.rb)); -    diff.rgb += nz*0.008; +    diff.rgb += nz*0.003;      //diff.rgb = nz;      frag_color = diff;  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl b/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl index 39cc07d2d1..71f7ec52c4 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl @@ -58,7 +58,7 @@ vec2 khr_texture_transform(vec2 texcoord, vec2 scale, float rotation, vec2 offse  //     animations, available through LSL script functions such as  //     LlSetTextureAnim. It assumes a right-handed UV coordinate system.  // texcoord - The final texcoord to use for image sampling -vec2 texture_transform(vec2 vertex_texcoord, vec2 khr_gltf_scale, float khr_gltf_rotation, vec2 khr_gltf_offset, mat4 sl_animation_transform) +vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform)  {      vec2 texcoord = vertex_texcoord; @@ -67,7 +67,7 @@ vec2 texture_transform(vec2 vertex_texcoord, vec2 khr_gltf_scale, float khr_gltf      // Convert to left-handed coordinate system. The offset of 1 is necessary      // for rotations to be applied correctly.      texcoord.y = 1.0 - texcoord.y; -    texcoord = khr_texture_transform(texcoord, khr_gltf_scale, khr_gltf_rotation, khr_gltf_offset); +    texcoord = khr_texture_transform(texcoord, khr_gltf_transform[0].xy, khr_gltf_transform[0].z, khr_gltf_transform[1].xy);      // Convert back to right-handed coordinate system      texcoord.y = 1.0 - texcoord.y;  | 
