Skip to content

Commit d4a3cb1

Browse files
committed
Altered the deferred alpha fragment shader to handle alphamasking when drawing avatar hair/skirts. (Special handling for these two seems weird, considering all other mesh parts are also alphamasked.. It also prevents skirts from casting shadows. Future alteration may be desired.)
1 parent f03376c commit d4a3cb1

1 file changed

Lines changed: 31 additions & 28 deletions

File tree

  • indra/newview/app_settings/shaders/class1/deferred

indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ uniform float shadow_bias;
7474
uniform sampler2D diffuseMap;
7575
#endif
7676

77+
#ifdef IS_AVATAR_SKIN
78+
uniform float minimum_alpha;
79+
#endif
80+
7781
VARYING vec3 vary_fragcoord;
7882
VARYING vec3 vary_position;
7983
VARYING vec2 vary_texcoord0;
@@ -454,7 +458,33 @@ vec3 fullbrightScaleSoftClip(vec3 light)
454458

455459
void main()
456460
{
457-
461+
#ifdef USE_INDEXED_TEX
462+
vec4 diff = diffuseLookup(vary_texcoord0.xy);
463+
#else
464+
vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy);
465+
#endif
466+
#ifdef USE_VERTEX_COLOR
467+
float final_alpha = diff.a * vertex_color.a;
468+
diff.rgb *= vertex_color.rgb;
469+
#else
470+
float final_alpha = diff.a;
471+
#endif
472+
473+
#ifdef IS_AVATAR_SKIN
474+
if(final_alpha < minimum_alpha)
475+
{
476+
discard;
477+
}
478+
#endif
479+
#ifdef FOR_IMPOSTOR
480+
// Insure we don't pollute depth with invis pixels in impostor rendering
481+
//
482+
if (final_alpha < 0.01)
483+
{
484+
discard;
485+
}
486+
#endif
487+
458488
vec4 pos = vec4(vary_position, 1.0);
459489

460490
float shadow = 1.0;
@@ -528,37 +558,10 @@ void main()
528558
}
529559
#endif
530560

531-
#ifdef USE_INDEXED_TEX
532-
vec4 diff = diffuseLookup(vary_texcoord0.xy);
533-
#else
534-
vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy);
535-
#endif
536561

537562
#ifdef FOR_IMPOSTOR
538-
539-
#ifdef USE_VERTEX_COLOR
540-
float final_alpha = diff.a * vertex_color.a;
541-
diff.rgb *= vertex_color.rgb;
542-
#else
543-
float final_alpha = diff.a;
544-
#endif
545-
546-
// Insure we don't pollute depth with invis pixels in impostor rendering
547-
//
548-
if (final_alpha < 0.01)
549-
{
550-
discard;
551-
}
552563
vec4 color = vec4(diff.rgb,final_alpha);
553564
#else
554-
555-
#ifdef USE_VERTEX_COLOR
556-
float final_alpha = diff.a * vertex_color.a;
557-
diff.rgb *= vertex_color.rgb;
558-
#else
559-
float final_alpha = diff.a;
560-
#endif
561-
562565

563566
vec4 gamma_diff = diff;
564567
diff.rgb = srgb_to_linear(diff.rgb);

0 commit comments

Comments
 (0)