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