summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings')
-rw-r--r--indra/newview/app_settings/settings.xml2
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/srgbF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl176
-rw-r--r--indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessV.glsl43
4 files changed, 136 insertions, 87 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index c7999fc2e9..3dc72553dc 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -15741,7 +15741,7 @@
<key>GLTFEnabled</key>
<map>
<key>Comment</key>
- <string>Enable GLTF support. Set by SimulatorFeatures</string>
+ <string>Enable GLTF support. Set to true by simulator if the simulator you are connected to supports GLTF Asset upload. WARNING: Manually setting this to true will enable buttons that can drain your L$ balance by implicitly uploading textures without asking.</string>
<key>Persist</key>
<integer>0</integer>
<key>Type</key>
diff --git a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl
index 7e1d906878..d7f6d20547 100644
--- a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl
@@ -23,8 +23,6 @@
* $/LicenseInfo$
*/
- uniform sampler2D exposureMap;
-
vec3 srgb_to_linear(vec3 cs)
{
vec3 low_range = cs / vec3(12.92);
diff --git a/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl b/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl
index a59127ec77..d71a3fad99 100644
--- a/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl
+++ b/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessF.glsl
@@ -28,20 +28,61 @@
// GLTF pbrMetallicRoughness implementation
-uniform sampler2D diffuseMap; //always in sRGB space
-uniform float metallicFactor;
-uniform float roughnessFactor;
+// ==================================
+// needed by all variants
+// ==================================
+uniform sampler2D diffuseMap; //always in sRGB space
+uniform sampler2D emissiveMap;
uniform vec3 emissiveColor;
+in vec3 vary_position;
+in vec4 vertex_color;
+in vec2 base_color_texcoord;
+in vec2 emissive_texcoord;
+uniform float minimum_alpha;
+
+void mirrorClip(vec3 pos);
+vec3 linear_to_srgb(vec3 c);
+vec3 srgb_to_linear(vec3 c);
+// ==================================
+
+
+// ==================================
+// needed by all lit variants
+// ==================================
+#ifndef UNLIT
uniform sampler2D normalMap;
-uniform sampler2D emissiveMap;
uniform sampler2D metallicRoughnessMap;
uniform sampler2D occlusionMap;
+uniform float metallicFactor;
+uniform float roughnessFactor;
+in vec3 vary_normal;
+in vec3 vary_tangent;
+flat in float vary_sign;
+in vec2 normal_texcoord;
+in vec2 metallic_roughness_texcoord;
+#endif
+// ==================================
-#ifdef ALPHA_BLEND
-out vec4 frag_color;
+// ==================================
+// needed by all alpha variants
+// ==================================
+#ifdef ALPHA_BLEND
in vec3 vary_fragcoord;
+uniform vec4 clipPlane;
+uniform float clipSign;
+void waterClip(vec3 pos);
+void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive);
+vec4 applySkyAndWaterFog(vec3 pos, vec3 additive, vec3 atten, vec4 color);
+#endif
+// ==================================
+
+
+// ==================================
+// needed by lit alpha
+// ==================================
+#if defined(ALPHA_BLEND) && !defined(UNLIT)
#ifdef HAS_SUN_SHADOW
uniform sampler2D lightMap;
@@ -60,21 +101,12 @@ uniform int sun_up_factor;
uniform vec3 sun_dir;
uniform vec3 moon_dir;
-vec3 srgb_to_linear(vec3 c);
-vec3 linear_to_srgb(vec3 c);
-
-void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive);
-vec4 applySkyAndWaterFog(vec3 pos, vec3 additive, vec3 atten, vec4 color);
-
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);
float calcLegacyDistanceAttenuation(float distance, float falloff);
float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen);
void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv,
vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent, vec3 amblit_linear);
-void mirrorClip(vec3 pos);
-void waterClip(vec3 pos);
-
void calcDiffuseSpecular(vec3 baseColor, float metallic, inout vec3 diffuseColor, inout vec3 specularColor);
vec3 pbrBaseLight(vec3 diffuseColor,
@@ -104,44 +136,36 @@ vec3 pbrCalcPointLightOrSpotLight(vec3 diffuseColor, vec3 specularColor,
vec3 lightColor,
float lightSize, float falloff, float is_pointlight, float ambiance);
+#endif
+// ==================================
+
+// ==================================
+// output definition
+// ==================================
+#if defined(ALPHA_BLEND) || defined(UNLIT)
+out vec4 frag_color;
#else
out vec4 frag_data[4];
#endif
-
-
-in vec3 vary_position;
-in vec4 vertex_color;
-in vec3 vary_normal;
-in vec3 vary_tangent;
-flat in float vary_sign;
-
-in vec2 base_color_texcoord;
-in vec2 normal_texcoord;
-in vec2 metallic_roughness_texcoord;
-in vec2 emissive_texcoord;
-
-uniform float minimum_alpha;
-
-vec3 linear_to_srgb(vec3 c);
-vec3 srgb_to_linear(vec3 c);
-
-uniform vec4 clipPlane;
-uniform float clipSign;
-
-void mirrorClip(vec3 pos);
-
-uniform mat3 normal_matrix;
+// ==================================
void main()
{
+
+// ==================================
+// all variants
+// mirror clip
+// base color
+// masking
+// emissive
+// ==================================
vec3 pos = vary_position;
mirrorClip(pos);
vec4 basecolor = texture(diffuseMap, base_color_texcoord.xy).rgba;
basecolor.rgb = srgb_to_linear(basecolor.rgb);
-
basecolor *= vertex_color;
if (basecolor.a < minimum_alpha)
@@ -149,8 +173,16 @@ void main()
discard;
}
- vec3 col = basecolor.rgb;
-
+ vec3 emissive = emissiveColor;
+ emissive *= srgb_to_linear(texture(emissiveMap, emissive_texcoord.xy).rgb);
+// ==================================
+
+// ==================================
+// all lit variants
+// prepare norm
+// prepare orm
+// ==================================
+#ifndef UNLIT
// from mikktspace.com
vec3 vNt = texture(normalMap, normal_texcoord.xy).xyz*2.0-1.0;
float sign = vary_sign;
@@ -159,6 +191,7 @@ void main()
vec3 vB = sign * cross(vN, vT);
vec3 norm = normalize( vNt.x * vT + vNt.y * vB + vNt.z * vN );
+ norm *= gl_FrontFacing ? 1.0 : -1.0;
// RGB = Occlusion, Roughness, Metal
// default values, see LLViewerTexture::sDefaultPBRORMImagep
@@ -169,24 +202,49 @@ void main()
orm.r = texture(occlusionMap, metallic_roughness_texcoord.xy).r;
orm.g *= roughnessFactor;
orm.b *= metallicFactor;
+#endif
+// ==================================
+
+// ==================================
+// non alpha output
+// ==================================
+#ifndef ALPHA_BLEND
+#ifdef UNLIT
+ vec4 color = basecolor;
+ color.rgb += emissive.rgb;
+ frag_color = color;
+#else
+ frag_data[0] = max(vec4(basecolor.rgb, 0.0), vec4(0));
+ frag_data[1] = max(vec4(orm.rgb,0.0), vec4(0));
+ frag_data[2] = vec4(norm, GBUFFER_FLAG_HAS_PBR);
+ frag_data[3] = max(vec4(emissive,0), vec4(0));
+#endif
+#endif
- vec3 emissive = emissiveColor;
- emissive *= srgb_to_linear(texture(emissiveMap, emissive_texcoord.xy).rgb);
-
- norm *= gl_FrontFacing ? 1.0 : -1.0;
+// ==================================
+// alpha implementation
+// ==================================
#ifdef ALPHA_BLEND
- vec3 color = vec3(0,0,0);
-
- vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
float scol = 1.0;
vec3 sunlit;
vec3 amblit;
vec3 additive;
vec3 atten;
+
+ vec3 light_dir;
+
+#ifdef UNLIT
+ light_dir = vec3(0,0,1);
+ vec3 norm = vec3(0,0,1);
+#else
+ light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
+#endif
+
calcAtmosphericVarsLinear(pos.xyz, norm, light_dir, sunlit, amblit, additive, atten);
+#ifndef UNLIT
vec3 sunlit_linear = srgb_to_linear(sunlit);
vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
@@ -198,11 +256,6 @@ void main()
float perceptualRoughness = orm.g * roughnessFactor;
float metallic = orm.b * metallicFactor;
- // emissiveColor is the emissive color factor from GLTF and is already in linear space
- vec3 colorEmissive = emissiveColor;
- // emissiveMap here is a vanilla RGB texture encoded as sRGB, manually convert to linear
- colorEmissive *= srgb_to_linear(texture(emissiveMap, emissive_texcoord.xy).rgb);
-
// PBR IBL
float gloss = 1.0 - perceptualRoughness;
vec3 irradiance = vec3(0);
@@ -211,11 +264,11 @@ void main()
vec3 diffuseColor;
vec3 specularColor;
- calcDiffuseSpecular(col.rgb, metallic, diffuseColor, specularColor);
+ calcDiffuseSpecular(basecolor.rgb, metallic, diffuseColor, specularColor);
vec3 v = -normalize(pos.xyz);
- color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, orm.r, additive, atten);
+ vec3 color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, emissive, orm.r, additive, atten);
vec3 light = vec3(0);
@@ -237,12 +290,11 @@ void main()
float a = basecolor.a*vertex_color.a;
frag_color = max(vec4(color.rgb,a), vec4(0));
-#else
- // See: C++: addDeferredAttachments(), GLSL: softenLightF
- frag_data[0] = max(vec4(col, 0.0), vec4(0));
- frag_data[1] = max(vec4(orm.rgb,0.0), vec4(0));
- frag_data[2] = vec4(norm, GBUFFER_FLAG_HAS_PBR);
- frag_data[3] = max(vec4(emissive,0), vec4(0));
+#else // UNLIT
+ vec4 color = basecolor;
+ color.rgb += emissive.rgb;
+ frag_color = color;
#endif
+#endif // ALPHA_BLEND
}
diff --git a/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessV.glsl b/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessV.glsl
index 0ed1c5d315..f123c29101 100644
--- a/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessV.glsl
+++ b/indra/newview/app_settings/shaders/class1/gltf/pbrmetallicroughnessV.glsl
@@ -42,32 +42,32 @@ uniform vec4[2] texture_emissive_transform;
in vec3 position;
in vec4 diffuse_color;
-in vec3 normal;
-in vec4 tangent;
in vec2 texcoord0;
-
out vec2 base_color_texcoord;
-out vec2 normal_texcoord;
-out vec2 metallic_roughness_texcoord;
out vec2 emissive_texcoord;
-
out vec4 vertex_color;
+out vec3 vary_position;
+#ifndef UNLIT
+in vec3 normal;
+in vec4 tangent;
+out vec2 normal_texcoord;
+out vec2 metallic_roughness_texcoord;
out vec3 vary_tangent;
flat out float vary_sign;
out vec3 vary_normal;
-out vec3 vary_position;
+vec3 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform, mat4 sl_animation_transform);
+#endif
vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform);
-vec3 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform, mat4 sl_animation_transform);
#ifdef ALPHA_BLEND
out vec3 vary_fragcoord;
#endif
-
#ifdef HAS_SKIN
+in uvec4 joint;
in vec4 weight4;
layout (std140) uniform GLTFJoints
@@ -80,18 +80,12 @@ mat4 getGLTFSkinTransform()
{
int i;
- vec4 w = fract(weight4);
- vec4 index = floor(weight4);
-
- index = min(index, vec4(MAX_JOINTS_PER_GLTF_OBJECT-1));
- index = max(index, vec4( 0.0));
-
- w *= 1.0/(w.x+w.y+w.z+w.w);
+ vec4 w = weight4;
- int i1 = int(index.x);
- int i2 = int(index.y);
- int i3 = int(index.z);
- int i4 = int(index.w);
+ uint i1 = joint.x;
+ uint i2 = joint.y;
+ uint i3 = joint.z;
+ uint i4 = joint.w;
mat3 mat = mat3(gltf_joints[i1])*w.x;
mat += mat3(gltf_joints[i2])*w.y;
@@ -143,10 +137,15 @@ void main()
#endif
base_color_texcoord = texture_transform(texcoord0, texture_base_color_transform, texture_matrix0);
+ emissive_texcoord = texture_transform(texcoord0, texture_emissive_transform, texture_matrix0);
+
+#ifndef UNLIT
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);
+#endif
+
+#ifndef UNLIT
#ifdef HAS_SKIN
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;
@@ -156,10 +155,10 @@ void main()
#endif
n = normalize(n);
-
vary_tangent = normalize(tangent_space_transform(vec4(t, tangent.w), n, texture_normal_transform, texture_matrix0));
vary_sign = tangent.w;
vary_normal = n;
+#endif
vertex_color = diffuse_color;
#ifdef ALPHA_BLEND