diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred')
3 files changed, 137 insertions, 18 deletions
| diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl index a2ad1b70fb..597ab22f42 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl @@ -23,10 +23,10 @@   * $/LicenseInfo$   */ -#define DIFFUSE_ALPHA_MODE_IGNORE 0 -#define DIFFUSE_ALPHA_MODE_BLEND 1 -#define DIFFUSE_ALPHA_MODE_MASK 2 -#define DIFFUSE_ALPHA_MODE_EMISSIVE 3 + +#ifndef IS_HUD + +// default alpha implementation  #ifdef HAS_SKIN  uniform mat4 modelview_matrix; @@ -38,13 +38,12 @@ uniform mat4 modelview_projection_matrix;  #endif  uniform mat4 texture_matrix0; -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) -  #if !defined(HAS_SKIN) -    uniform mat4 modelview_matrix; -  #endif -    VARYING vec3 vary_position; +#if !defined(HAS_SKIN) +uniform mat4 modelview_matrix;  #endif +out vec3 vary_position; +  uniform mat3 texture_basecolor_matrix;  uniform mat3 texture_normal_matrix;  uniform mat3 texture_metallic_roughness_matrix; @@ -79,9 +78,7 @@ void main()  	mat4 mat = getObjectSkinnedTransform();  	mat = modelview_matrix * mat;  	vec3 pos = (mat*vec4(position.xyz,1.0)).xyz; -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)  	vary_position = pos; -#endif      vec4 vert = projection_matrix * vec4(pos,1.0);  #else  	//transform vertex @@ -112,9 +109,45 @@ void main()  	vertex_color = diffuse_color; -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) -  #if !defined(HAS_SKIN) +#if !defined(HAS_SKIN)  	vary_position = (modelview_matrix*vec4(position.xyz, 1.0)).xyz; -  #endif  #endif  } + +#else + +// fullbright HUD alpha implementation + +uniform mat4 modelview_projection_matrix; + +uniform mat4 texture_matrix0; + +uniform mat4 modelview_matrix; + +out vec3 vary_position; + +uniform mat3 texture_basecolor_matrix; +uniform mat3 texture_emissive_matrix; + +in vec3 position; +in vec4 diffuse_color; +in vec2 texcoord0; + +out vec2 basecolor_texcoord; +out vec2 emissive_texcoord; + +out vec4 vertex_color; + +void main() +{ +	//transform vertex +    vec4 vert = modelview_projection_matrix * vec4(position.xyz, 1.0); +    gl_Position = vert; + +	basecolor_texcoord = (texture_matrix0 * vec4(texture_basecolor_matrix * vec3(texcoord0,1), 1)).xy; +	emissive_texcoord = (texture_matrix0 * vec4(texture_emissive_matrix * vec3(texcoord0,1), 1)).xy; + +	vertex_color = diffuse_color; +} + +#endif diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl index 39419e9d78..483ce4c3d0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl @@ -25,6 +25,11 @@  /*[EXTRA_CODE_HERE]*/ + +#ifndef IS_HUD + +// deferred opaque implementation  +  uniform sampler2D diffuseMap;  //always in sRGB space  uniform float metallicFactor; @@ -101,3 +106,47 @@ void main()      frag_data[2] = vec4(encode_normal(tnorm), vertex_color.a, GBUFFER_FLAG_HAS_PBR); // normal, environment intensity, flags      frag_data[3] = vec4(emissive,0);                                                // PBR sRGB Emissive  } + +#else + +// forward fullbright implementation for HUDs + +uniform sampler2D diffuseMap;  //always in sRGB space + +uniform vec3 emissiveColor; +uniform sampler2D emissiveMap; + +out vec4 frag_color; + +in vec3 vary_position; +in vec4 vertex_color; + +in vec2 basecolor_texcoord; +in vec2 emissive_texcoord; + +uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlphaCutoff() + +vec3 linear_to_srgb(vec3 c); +vec3 srgb_to_linear(vec3 c); + +void main() +{ +    vec4 basecolor = texture2D(diffuseMap, basecolor_texcoord.xy).rgba; +    if (basecolor.a < minimum_alpha) +    { +        discard; +    } + +    vec3 col = vertex_color.rgb * srgb_to_linear(basecolor.rgb); + +    vec3 emissive = emissiveColor; +    emissive *= srgb_to_linear(texture2D(emissiveMap, emissive_texcoord.xy).rgb); + +    col += emissive; + +    // HUDs are rendered after gamma correction, output in sRGB space +    frag_color.rgb = linear_to_srgb(col); +    frag_color.a = 0.0; +} + +#endif
\ No newline at end of file diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl index 5a69da641a..8320640e42 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl @@ -23,10 +23,10 @@   * $/LicenseInfo$   */ -#define DIFFUSE_ALPHA_MODE_IGNORE 0 -#define DIFFUSE_ALPHA_MODE_BLEND 1 -#define DIFFUSE_ALPHA_MODE_MASK 2 -#define DIFFUSE_ALPHA_MODE_EMISSIVE 3 + +#ifndef IS_HUD + +//deferred opaque implementation  #ifdef HAS_SKIN  uniform mat4 modelview_matrix; @@ -95,3 +95,40 @@ void main()  	vertex_color = diffuse_color;  } + +#else  + +// fullbright HUD implementation + +uniform mat4 modelview_projection_matrix; + +uniform mat4 texture_matrix0; + +uniform mat3 texture_basecolor_matrix; +uniform mat3 texture_normal_matrix; +uniform mat3 texture_metallic_roughness_matrix; +uniform mat3 texture_emissive_matrix; + +in vec3 position; +in vec4 diffuse_color; +in vec2 texcoord0; + +out vec2 basecolor_texcoord; +out vec2 emissive_texcoord; +  +out vec4 vertex_color; + +void main() +{ +    //transform vertex +    gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);  + +    basecolor_texcoord = (texture_matrix0 * vec4(texture_basecolor_matrix * vec3(texcoord0,1), 1)).xy; +    emissive_texcoord = (texture_matrix0 * vec4(texture_emissive_matrix * vec3(texcoord0,1), 1)).xy; + +    vertex_color = diffuse_color; +} + +#endif + + | 
