Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void main() {
- float build_fraction = BuildInfo.x;
- float wire_width = BuildInfo.y;
- float model_height = BuildInfo.w;
- float model_radius = BuildInfo.z;
- //useful variables
- float height_fraction = v_ModelPosition.z / model_height + (texture2D(NoiseTexture, v_ModelPosition.xy / 80.0 + build_fraction).r + texture2D(NoiseTexture, v_ModelPosition.xy / -90.0 + build_fraction).g) * 0.02;
- vec3 normalizedPosition = v_ModelPosition / model_radius;
- float distanceFromModelCenterSquared = dot(normalizedPosition, normalizedPosition);
- vec2 xy_scaled = v_ModelPosition.xy / model_radius;
- float xy_distSquared = dot(xy_scaled, xy_scaled);
- if (distanceFromModelCenterSquared > build_fraction)
- {
- discard;
- }
- //prelight_pa_unit.fs from here on
- vec2 tc = v_TexCoord;
- vec4 diffuse_raw = texture2D(DiffuseTexture, tc);
- vec4 material_raw = texture2D(MaterialTexture, tc);
- vec4 mask = texture2D(MaskTexture, tc);
- vec3 viewNormal = normalize(v_Normal);
- // Mix team color - fast & cheap photoshop overlay
- vec3 teamColor = mix(vec3(0.5,0.5,0.5), TeamColor_Primary, mask.r);
- teamColor = mix(teamColor, TeamColor_Secondary, mask.g);
- vec3 team_overlay_mult = clamp(2.0 * diffuse_raw.rgb, 0.0, 1.0);
- vec3 team_overlay_screen = 1.0 - 2.0 * (1.0 - clamp(diffuse_raw.rgb, 0.5, 1.0)) * (1.0 - teamColor);
- vec3 diffuse = team_overlay_mult * team_overlay_screen;
- float specularMask = material_raw.r;
- float specularExp = material_raw.g;
- float emissive = mask.b;
- vec3 ambientColor = calcAmbient(viewNormal, v_Forward);
- vec3 ambient = mix(ambientColor * diffuse.rgb, diffuse.rgb * 2.0, emissive + max(mask.r, mask.g) * 0.1);
- gl_FragData[0] = vec4(ambient, 1.0);
- gl_FragData[1] = vec4(diffuse.rgb * (1.0 - emissive), specularMask);
- gl_FragData[2] = vec4(length(v_Forward) * GBufferDepth_range.z - GBufferDepth_range.w, 0.0, 0.0, 1.0);
- gl_FragData[3] = vec4(encodeViewNormal(viewNormal), specularExp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement