model_instanced_floor.vp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #version 140
  2. // Positions can be world or local space, since world and normal
  3. // matrices are identity for world vertex space materials.
  4. // If world vertex space is selected, you can remove the
  5. // normal matrix multiplication for optimal performance.
  6. in highp vec4 position;
  7. in mediump vec2 texcoord0;
  8. in mediump vec3 normal;
  9. // When 'mtx_world' and 'mtx_normal' is specified as attributes,
  10. // instanced rendering is automatically triggered.
  11. // To read more about instancing in Defold, navigate to
  12. // https://defold.com/manuals/material/#instancing
  13. in mediump mat4 mtx_world;
  14. in mediump mat4 mtx_normal;
  15. out highp vec4 var_position;
  16. out mediump vec3 var_normal;
  17. out mediump vec2 var_texcoord0;
  18. out mediump vec4 var_light;
  19. uniform vs_uniforms
  20. {
  21. mediump mat4 mtx_view;
  22. mediump mat4 mtx_proj;
  23. mediump vec4 light;
  24. mediump vec4 zoom;
  25. };
  26. void main()
  27. {
  28. vec4 p = mtx_view * mtx_world * vec4(position.xyz, 1.0);
  29. var_light = mtx_view * vec4(light.xyz, 1.0);
  30. var_position = p;
  31. var_texcoord0 = texcoord0 * zoom.x;
  32. var_normal = normalize((mtx_normal * vec4(normal, 0.0)).xyz);
  33. gl_Position = mtx_proj * p;
  34. }