Advertisement
Guest User

Untitled

a guest
Jun 11th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void main() {
  2.  
  3. float build_fraction = BuildInfo.x;
  4. float wire_width = BuildInfo.y;
  5. float model_height = BuildInfo.w;
  6. float model_radius = BuildInfo.z;
  7. //useful variables
  8. 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;
  9.  
  10. vec3 normalizedPosition = v_ModelPosition / model_radius;
  11. float distanceFromModelCenterSquared = dot(normalizedPosition, normalizedPosition);
  12.  
  13. vec2 xy_scaled = v_ModelPosition.xy / model_radius;
  14. float xy_distSquared = dot(xy_scaled, xy_scaled);
  15.  
  16. if (distanceFromModelCenterSquared > build_fraction)
  17. {
  18. discard;
  19. }
  20.  
  21. //prelight_pa_unit.fs from here on
  22. vec2 tc = v_TexCoord;
  23.  
  24. vec4 diffuse_raw = texture2D(DiffuseTexture, tc);
  25. vec4 material_raw = texture2D(MaterialTexture, tc);
  26. vec4 mask = texture2D(MaskTexture, tc);
  27. vec3 viewNormal = normalize(v_Normal);
  28.  
  29. // Mix team color - fast & cheap photoshop overlay
  30. vec3 teamColor = mix(vec3(0.5,0.5,0.5), TeamColor_Primary, mask.r);
  31. teamColor = mix(teamColor, TeamColor_Secondary, mask.g);
  32.  
  33. vec3 team_overlay_mult = clamp(2.0 * diffuse_raw.rgb, 0.0, 1.0);
  34. vec3 team_overlay_screen = 1.0 - 2.0 * (1.0 - clamp(diffuse_raw.rgb, 0.5, 1.0)) * (1.0 - teamColor);
  35.  
  36. vec3 diffuse = team_overlay_mult * team_overlay_screen;
  37.  
  38. float specularMask = material_raw.r;
  39. float specularExp = material_raw.g;
  40. float emissive = mask.b;
  41.  
  42. vec3 ambientColor = calcAmbient(viewNormal, v_Forward);
  43. vec3 ambient = mix(ambientColor * diffuse.rgb, diffuse.rgb * 2.0, emissive + max(mask.r, mask.g) * 0.1);
  44.  
  45. gl_FragData[0] = vec4(ambient, 1.0);
  46. gl_FragData[1] = vec4(diffuse.rgb * (1.0 - emissive), specularMask);
  47. gl_FragData[2] = vec4(length(v_Forward) * GBufferDepth_range.z - GBufferDepth_range.w, 0.0, 0.0, 1.0);
  48. gl_FragData[3] = vec4(encodeViewNormal(viewNormal), specularExp);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement