Merge pull request #2976 from jeremy-lunarg/hayes-fix-2975
[platform/upstream/glslang.git] / Test / vk.relaxed.stagelink.0.0.vert
1 #version 460\r
2 uniform int uTDInstanceIDOffset;\r
3 uniform int uTDNumInstances;\r
4 uniform float uTDAlphaTestVal;\r
5 #define TD_NUM_COLOR_BUFFERS 1\r
6 #define TD_NUM_LIGHTS 0\r
7 #define TD_NUM_SHADOWED_LIGHTS 0\r
8 #define TD_NUM_ENV_LIGHTS 0\r
9 #define TD_LIGHTS_ARRAY_SIZE 1\r
10 #define TD_ENV_LIGHTS_ARRAY_SIZE 1\r
11 #define TD_NUM_CAMERAS 1\r
12 struct TDPhongResult\r
13 {\r
14         vec3 diffuse;\r
15         vec3 specular;\r
16         vec3 specular2;\r
17         float shadowStrength;\r
18 };\r
19 struct TDPBRResult\r
20 {\r
21         vec3 diffuse;\r
22         vec3 specular;\r
23         float shadowStrength;\r
24 };\r
25 struct TDMatrix\r
26 {\r
27         mat4 world;\r
28         mat4 worldInverse;\r
29         mat4 worldCam;\r
30         mat4 worldCamInverse;\r
31         mat4 cam;\r
32         mat4 camInverse;\r
33         mat4 camProj;\r
34         mat4 camProjInverse;\r
35         mat4 proj;\r
36         mat4 projInverse;\r
37         mat4 worldCamProj;\r
38         mat4 worldCamProjInverse;\r
39         mat4 quadReproject;\r
40         mat3 worldForNormals;\r
41         mat3 camForNormals;\r
42         mat3 worldCamForNormals;\r
43 };\r
44 layout(std140) uniform TDMatricesBlock {\r
45         TDMatrix uTDMats[TD_NUM_CAMERAS];\r
46 };\r
47 struct TDCameraInfo\r
48 {\r
49         vec4 nearFar;\r
50         vec4 fog;\r
51         vec4 fogColor;\r
52         int renderTOPCameraIndex;\r
53 };\r
54 layout(std140) uniform TDCameraInfoBlock {\r
55         TDCameraInfo uTDCamInfos[TD_NUM_CAMERAS];\r
56 };\r
57 struct TDGeneral\r
58 {\r
59         vec4 ambientColor;\r
60         vec4 nearFar;\r
61         vec4 viewport;\r
62         vec4 viewportRes;\r
63         vec4 fog;\r
64         vec4 fogColor;\r
65 };\r
66 layout(std140) uniform TDGeneralBlock {\r
67         TDGeneral uTDGeneral;\r
68 };\r
69 layout(location = 0) in vec3 P;\r
70 layout(location = 1) in vec3 N;\r
71 layout(location = 2) in vec4 Cd;\r
72 layout(location = 3) in vec3 uv[8];\r
73 vec4 TDWorldToProj(vec4 v);\r
74 vec4 TDWorldToProj(vec3 v);\r
75 vec4 TDWorldToProj(vec4 v, vec3 uv);\r
76 vec4 TDWorldToProj(vec3 v, vec3 uv);\r
77 int TDInstanceID();\r
78 int TDCameraIndex();\r
79 vec3 TDUVUnwrapCoord();\r
80 /*********TOUCHDEFORMPREFIX**********/\r
81 #define TD_NUM_BONES 0\r
82 \r
83 vec3 TDInstanceTexCoord(int instanceID, vec3 t);\r
84 vec4 TDInstanceColor(int instanceID, vec4 curColor);\r
85 \r
86 vec4 TDDeform(vec4 pos);\r
87 vec4 TDDeform(vec3 pos);\r
88 vec3 TDInstanceTexCoord(vec3 t);\r
89 vec4 TDInstanceColor(vec4 curColor);\r
90 #line 1\r
91 \r
92 out Vertex\r
93 {\r
94         vec4 color;\r
95         vec3 worldSpacePos;\r
96         vec3 texCoord0;\r
97         flat int cameraIndex;\r
98         flat int instance;\r
99 } oVert;\r
100 \r
101 void main()\r
102 {\r
103 \r
104         { // Avoid duplicate variable defs\r
105                 vec3 texcoord = TDInstanceTexCoord(uv[0]);\r
106                 oVert.texCoord0.stp = texcoord.stp;\r
107         }\r
108         // First deform the vertex and normal\r
109         // TDDeform always returns values in world space\r
110         oVert.instance = TDInstanceID();\r
111         vec4 worldSpacePos = TDDeform(P);\r
112         vec3 uvUnwrapCoord = TDInstanceTexCoord(TDUVUnwrapCoord());\r
113         gl_Position = TDWorldToProj(worldSpacePos, uvUnwrapCoord);\r
114 \r
115 \r
116         // This is here to ensure we only execute lighting etc. code\r
117         // when we need it. If picking is active we don't need lighting, so\r
118         // this entire block of code will be ommited from the compile.\r
119         // The TD_PICKING_ACTIVE define will be set automatically when\r
120         // picking is active.\r
121 \r
122         int cameraIndex = TDCameraIndex();\r
123         oVert.cameraIndex = cameraIndex;\r
124         oVert.worldSpacePos.xyz = worldSpacePos.xyz;\r
125         oVert.color = TDInstanceColor(Cd);\r
126 }\r