RimLightingMaterial.glsl 565 B

123456789101112131415161718
  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. material.diffuse = color.rgb;
  11. material.emission = rimColor.rgb * s;
  12. material.alpha = mix(color.a, rimColor.a, s);
  13. return material;
  14. }