RimLightingMaterial.glsl 673 B

123456789101112131415161718192021
  1. uniform vec4 color;
  2. uniform vec4 rimColor;
  3. uniform float width;
  4. czm_material czm_getMaterial(czm_materialInput materialInput)
  5. {
  6. czm_material material = czm_getDefaultMaterial(materialInput);
  7. // See http://www.fundza.com/rman_shaders/surface/fake_rim/fake_rim1.html
  8. float d = 1.0 - dot(materialInput.normalEC, normalize(materialInput.positionToEyeEC));
  9. float s = smoothstep(1.0 - width, 1.0, d);
  10. vec4 outColor = czm_gammaCorrect(color);
  11. vec4 outRimColor = czm_gammaCorrect(rimColor);
  12. material.diffuse = outColor.rgb;
  13. material.emission = outRimColor.rgb * s;
  14. material.alpha = mix(outColor.a, outRimColor.a, s);
  15. return material;
  16. }