model_instanced_floor.fp 701 B

12345678910111213141516171819202122232425262728293031
  1. #version 140
  2. in highp vec4 var_position;
  3. in mediump vec3 var_normal;
  4. in mediump vec2 var_texcoord0;
  5. in mediump vec4 var_light;
  6. out vec4 out_fragColor;
  7. uniform mediump sampler2D tex0;
  8. uniform fs_uniforms
  9. {
  10. mediump vec4 tint;
  11. };
  12. void main()
  13. {
  14. // Pre-multiply alpha since all runtime textures already are
  15. vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w);
  16. vec4 color = texture(tex0, var_texcoord0.xy) * tint_pm;
  17. // Lighting
  18. vec3 ambient_light = vec3(0.8);
  19. vec3 L = normalize(var_light.xyz - var_position.xyz);
  20. float diff = max(dot(var_normal, L), 0.0);
  21. vec3 lighting = clamp(ambient_light + diff, 0.0, 1.0);
  22. out_fragColor = vec4(color.rgb * lighting, 1.0);
  23. }