DALi Version 1.3.45
[platform/core/uifw/dali-demo.git] / resources / shaders / raymarch_sphere_shaded.vsh
1 attribute mediump vec2 aPosition;
2 uniform   mediump mat4 uMvpMatrix;  // DALi shader builtin
3 uniform   mediump vec3 uSize; // DALi shader builtin
4
5 varying mediump vec2 vTexCoord;
6 varying mediump vec2 vRayCastCoord;
7 void main()
8 {
9   mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
10   vertexPosition.xyz *= uSize;
11
12   // In this ray march example we supply the fragment shader with 0..1 UV texture co-ordinates
13   // incase someone wants to extend the code and add texture mapping to it.
14   // DALi geometry typically ranges from -0.5 to 0.5, hence the +0.5 to make it 0..1
15
16   vTexCoord = aPosition + vec2(0.5);
17
18
19   // Our UV texture co-ordinates for the quad geometry should now range from 0..1
20   //
21   // (0,0)
22   //    |--------|
23   //    |      / |
24   //    |    /   |
25   //    |  /     |
26   //    |/-------|(1,1)
27   //
28   //
29   //
30   // We're going to use the UV co-ordinates as our virtual screen / plane of projection on to our
31   // raycasted scene.
32   //
33   // We first modify the range to be from -1,-1 to 1,1 with 0,0 in the centre. Then
34   // pass this as a varying value to the fragment shader.
35   //
36   //
37   // (-1,-1)
38   //    |--------------|
39   //    |       |      |
40   //    |       |      |
41   //    |_____(0,0)____|
42   //    |       |      |
43   //    |       |      |
44   //    |_______|______|(1,1)
45   //
46   //
47
48   vRayCastCoord = (2.0 * vTexCoord ) - 1.0 ;
49
50   gl_Position = uMvpMatrix * vertexPosition;
51 }