sources.go 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167
  1. // Code generated by G3NSHADERS. DO NOT EDIT.
  2. // To regenerate this file install 'g3nshaders' and execute:
  3. // 'go generate' in this folder.
  4. package shaders
  5. const include_morphtarget_vertex2_source = ` vPosition += MorphPosition{i} * morphTargetInfluences[{i}];
  6. #ifdef MORPHTARGETS_NORMAL
  7. vNormal += MorphNormal{i} * morphTargetInfluences[{i}];
  8. #endif`
  9. const include_morphtarget_vertex_declaration2_source = ` in vec3 MorphPosition{i};
  10. #ifdef MORPHTARGETS_NORMAL
  11. in vec3 MorphNormal{i};
  12. #endif
  13. `
  14. const include_morphtarget_vertex_source = `#ifdef MORPHTARGETS
  15. #include <morphtarget_vertex2> [MORPHTARGETS]
  16. #endif
  17. `
  18. const include_morphtarget_vertex_declaration_source = `#ifdef MORPHTARGETS
  19. uniform float morphTargetInfluences[MORPHTARGETS];
  20. #include <morphtarget_vertex_declaration2> [MORPHTARGETS]
  21. #endif
  22. `
  23. const include_bones_vertex_source = `#ifdef BONE_INFLUENCERS
  24. #if BONE_INFLUENCERS > 0
  25. mat4 influence = mBones[int(matricesIndices[0])] * matricesWeights[0];
  26. #if BONE_INFLUENCERS > 1
  27. influence += mBones[int(matricesIndices[1])] * matricesWeights[1];
  28. #if BONE_INFLUENCERS > 2
  29. influence += mBones[int(matricesIndices[2])] * matricesWeights[2];
  30. #if BONE_INFLUENCERS > 3
  31. influence += mBones[int(matricesIndices[3])] * matricesWeights[3];
  32. // #if BONE_INFLUENCERS > 4
  33. // influence += mBones[int(matricesIndicesExtra[0])] * matricesWeightsExtra[0];
  34. // #if BONE_INFLUENCERS > 5
  35. // influence += mBones[int(matricesIndicesExtra[1])] * matricesWeightsExtra[1];
  36. // #if BONE_INFLUENCERS > 6
  37. // influence += mBones[int(matricesIndicesExtra[2])] * matricesWeightsExtra[2];
  38. // #if BONE_INFLUENCERS > 7
  39. // influence += mBones[int(matricesIndicesExtra[3])] * matricesWeightsExtra[3];
  40. // #endif
  41. // #endif
  42. // #endif
  43. // #endif
  44. #endif
  45. #endif
  46. #endif
  47. finalWorld = finalWorld * influence;
  48. #endif
  49. #endif
  50. `
  51. const include_phong_model_source = `/***
  52. phong lighting model
  53. Parameters:
  54. position: input vertex position in camera coordinates
  55. normal: input vertex normal in camera coordinates
  56. camDir: input camera directions
  57. matAmbient: input material ambient color
  58. matDiffuse: input material diffuse color
  59. ambdiff: output ambient+diffuse color
  60. spec: output specular color
  61. Uniforms:
  62. AmbientLightColor[]
  63. DiffuseLightColor[]
  64. DiffuseLightPosition[]
  65. PointLightColor[]
  66. PointLightPosition[]
  67. PointLightLinearDecay[]
  68. PointLightQuadraticDecay[]
  69. MatSpecularColor
  70. MatShininess
  71. *****/
  72. void phongModel(vec4 position, vec3 normal, vec3 camDir, vec3 matAmbient, vec3 matDiffuse, out vec3 ambdiff, out vec3 spec) {
  73. vec3 ambientTotal = vec3(0.0);
  74. vec3 diffuseTotal = vec3(0.0);
  75. vec3 specularTotal = vec3(0.0);
  76. bool noLights = true;
  77. const float EPS = 0.00001;
  78. float specular;
  79. #if AMB_LIGHTS>0
  80. noLights = false;
  81. // Ambient lights
  82. for (int i = 0; i < AMB_LIGHTS; ++i) {
  83. ambientTotal += AmbientLightColor[i] * matAmbient;
  84. }
  85. #endif
  86. #if DIR_LIGHTS>0
  87. noLights = false;
  88. // Directional lights
  89. for (int i = 0; i < DIR_LIGHTS; ++i) {
  90. vec3 lightDirection = normalize(DirLightPosition(i)); // Vector from fragment to light source
  91. float dotNormal = dot(lightDirection, normal); // Dot product between light direction and fragment normal
  92. if (dotNormal > EPS) { // If the fragment is lit
  93. diffuseTotal += DirLightColor(i) * matDiffuse * dotNormal;
  94. #ifdef BLINN
  95. specular = pow(max(dot(normal, normalize(lightDirection + camDir)), 0.0), MatShininess);
  96. #else
  97. specular = pow(max(dot(reflect(-lightDirection, normal), camDir), 0.0), MatShininess);
  98. #endif
  99. specularTotal += DirLightColor(i) * MatSpecularColor * specular;
  100. }
  101. }
  102. #endif
  103. #if POINT_LIGHTS>0
  104. noLights = false;
  105. // Point lights
  106. for (int i = 0; i < POINT_LIGHTS; ++i) {
  107. vec3 lightDirection = PointLightPosition(i) - vec3(position); // Vector from fragment to light source
  108. float lightDistance = length(lightDirection); // Distance from fragment to light source
  109. lightDirection = lightDirection / lightDistance; // Normalize lightDirection
  110. float dotNormal = dot(lightDirection, normal); // Dot product between light direction and fragment normal
  111. if (dotNormal > EPS) { // If the fragment is lit
  112. float attenuation = 1.0 / (1.0 + lightDistance * (PointLightLinearDecay(i) + PointLightQuadraticDecay(i) * lightDistance));
  113. vec3 attenuatedColor = PointLightColor(i) * attenuation;
  114. diffuseTotal += attenuatedColor * matDiffuse * dotNormal;
  115. #ifdef BLINN
  116. specular = pow(max(dot(normal, normalize(lightDirection + camDir)), 0.0), MatShininess);
  117. #else
  118. specular = pow(max(dot(reflect(-lightDirection, normal), camDir), 0.0), MatShininess);
  119. #endif
  120. specularTotal += attenuatedColor * MatSpecularColor * specular;
  121. }
  122. }
  123. #endif
  124. #if SPOT_LIGHTS>0
  125. noLights = false;
  126. for (int i = 0; i < SPOT_LIGHTS; ++i) {
  127. // Calculates the direction and distance from the current vertex to this spot light.
  128. vec3 lightDirection = SpotLightPosition(i) - vec3(position); // Vector from fragment to light source
  129. float lightDistance = length(lightDirection); // Distance from fragment to light source
  130. lightDirection = lightDirection / lightDistance; // Normalize lightDirection
  131. float angleDot = dot(-lightDirection, SpotLightDirection(i));
  132. float angle = acos(angleDot);
  133. float cutoff = radians(clamp(SpotLightCutoffAngle(i), 0.0, 90.0));
  134. if (angle < cutoff) { // Check if fragment is inside spotlight beam
  135. float dotNormal = dot(lightDirection, normal); // Dot product between light direction and fragment normal
  136. if (dotNormal > EPS) { // If the fragment is lit
  137. float attenuation = 1.0 / (1.0 + lightDistance * (SpotLightLinearDecay(i) + SpotLightQuadraticDecay(i) * lightDistance));
  138. float spotFactor = pow(angleDot, SpotLightAngularDecay(i));
  139. vec3 attenuatedColor = SpotLightColor(i) * attenuation * spotFactor;
  140. diffuseTotal += attenuatedColor * matDiffuse * dotNormal;
  141. #ifdef BLINN
  142. specular = pow(max(dot(normal, normalize(lightDirection + camDir)), 0.0), MatShininess);
  143. #else
  144. specular = pow(max(dot(reflect(-lightDirection, normal), camDir), 0.0), MatShininess);
  145. #endif
  146. specularTotal += attenuatedColor * MatSpecularColor * specular;
  147. }
  148. }
  149. }
  150. #endif
  151. if (noLights) {
  152. diffuseTotal = matDiffuse;
  153. }
  154. // Sets output colors
  155. ambdiff = ambientTotal + MatEmissiveColor + diffuseTotal;
  156. spec = specularTotal;
  157. }
  158. `
  159. const include_attributes_source = `//
  160. // Vertex attributes
  161. //
  162. layout(location = 0) in vec3 VertexPosition;
  163. layout(location = 1) in vec3 VertexNormal;
  164. layout(location = 2) in vec3 VertexColor;
  165. layout(location = 3) in vec2 VertexTexcoord;
  166. `
  167. const include_material_source = `//
  168. // Material properties uniform
  169. //
  170. // Material parameters uniform array
  171. uniform vec3 Material[6];
  172. // Macros to access elements inside the Material array
  173. #define MatAmbientColor Material[0]
  174. #define MatDiffuseColor Material[1]
  175. #define MatSpecularColor Material[2]
  176. #define MatEmissiveColor Material[3]
  177. #define MatShininess Material[4].x
  178. #define MatOpacity Material[4].y
  179. #define MatPointSize Material[4].z
  180. #define MatPointRotationZ Material[5].x
  181. #if MAT_TEXTURES > 0
  182. // Texture unit sampler array
  183. uniform sampler2D MatTexture[MAT_TEXTURES];
  184. // Texture parameters (3*vec2 per texture)
  185. uniform vec2 MatTexinfo[3*MAT_TEXTURES];
  186. // Macros to access elements inside the MatTexinfo array
  187. #define MatTexOffset(a) MatTexinfo[(3*a)]
  188. #define MatTexRepeat(a) MatTexinfo[(3*a)+1]
  189. #define MatTexFlipY(a) bool(MatTexinfo[(3*a)+2].x)
  190. #define MatTexVisible(a) bool(MatTexinfo[(3*a)+2].y)
  191. // Alpha compositing (see here: https://ciechanow.ski/alpha-compositing/)
  192. vec4 Blend(vec4 texMixed, vec4 texColor) {
  193. texMixed.rgb *= texMixed.a;
  194. texColor.rgb *= texColor.a;
  195. texMixed = texColor + texMixed * (1 - texColor.a);
  196. if (texMixed.a > 0.0) {
  197. texMixed.rgb /= texMixed.a;
  198. }
  199. return texMixed;
  200. }
  201. #endif
  202. `
  203. const include_lights_source = `//
  204. // Lights uniforms
  205. //
  206. #if AMB_LIGHTS>0
  207. // Ambient lights color uniform
  208. uniform vec3 AmbientLightColor[AMB_LIGHTS];
  209. #endif
  210. #if DIR_LIGHTS>0
  211. // Directional lights uniform array. Each directional light uses 2 elements
  212. uniform vec3 DirLight[2*DIR_LIGHTS];
  213. // Macros to access elements inside the DirectionalLight uniform array
  214. #define DirLightColor(a) DirLight[2*a]
  215. #define DirLightPosition(a) DirLight[2*a+1]
  216. #endif
  217. #if POINT_LIGHTS>0
  218. // Point lights uniform array. Each point light uses 3 elements
  219. uniform vec3 PointLight[3*POINT_LIGHTS];
  220. // Macros to access elements inside the PointLight uniform array
  221. #define PointLightColor(a) PointLight[3*a]
  222. #define PointLightPosition(a) PointLight[3*a+1]
  223. #define PointLightLinearDecay(a) PointLight[3*a+2].x
  224. #define PointLightQuadraticDecay(a) PointLight[3*a+2].y
  225. #endif
  226. #if SPOT_LIGHTS>0
  227. // Spot lights uniforms. Each spot light uses 5 elements
  228. uniform vec3 SpotLight[5*SPOT_LIGHTS];
  229. // Macros to access elements inside the PointLight uniform array
  230. #define SpotLightColor(a) SpotLight[5*a]
  231. #define SpotLightPosition(a) SpotLight[5*a+1]
  232. #define SpotLightDirection(a) SpotLight[5*a+2]
  233. #define SpotLightAngularDecay(a) SpotLight[5*a+3].x
  234. #define SpotLightCutoffAngle(a) SpotLight[5*a+3].y
  235. #define SpotLightLinearDecay(a) SpotLight[5*a+3].z
  236. #define SpotLightQuadraticDecay(a) SpotLight[5*a+4].x
  237. #endif
  238. `
  239. const include_bones_vertex_declaration_source = `#ifdef BONE_INFLUENCERS
  240. #if BONE_INFLUENCERS > 0
  241. uniform mat4 mBones[TOTAL_BONES];
  242. in vec4 matricesIndices;
  243. in vec4 matricesWeights;
  244. // #if BONE_INFLUENCERS > 4
  245. // in vec4 matricesIndicesExtra;
  246. // in vec4 matricesWeightsExtra;
  247. // #endif
  248. #endif
  249. #endif
  250. `
  251. const point_fragment_source = `precision highp float;
  252. #include <material>
  253. // Inputs from vertex shader
  254. in vec3 Color;
  255. flat in mat2 Rotation;
  256. // Output
  257. out vec4 FragColor;
  258. void main() {
  259. // Compute final texture color
  260. vec4 texMixed = vec4(1);
  261. #if MAT_TEXTURES > 0
  262. vec2 pointCoord = Rotation * gl_PointCoord - vec2(0.5) + vec2(0.5);
  263. bool firstTex = true;
  264. if (MatTexVisible(0)) {
  265. vec4 texColor = texture(MatTexture[0], pointCoord * MatTexRepeat(0) + MatTexOffset(0));
  266. if (firstTex) {
  267. texMixed = texColor;
  268. firstTex = false;
  269. } else {
  270. texMixed = Blend(texMixed, texColor);
  271. }
  272. }
  273. #if MAT_TEXTURES > 1
  274. if (MatTexVisible(1)) {
  275. vec4 texColor = texture(MatTexture[1], pointCoord * MatTexRepeat(1) + MatTexOffset(1));
  276. if (firstTex) {
  277. texMixed = texColor;
  278. firstTex = false;
  279. } else {
  280. texMixed = Blend(texMixed, texColor);
  281. }
  282. }
  283. #if MAT_TEXTURES > 2
  284. if (MatTexVisible(2)) {
  285. vec4 texColor = texture(MatTexture[2], pointCoord * MatTexRepeat(2) + MatTexOffset(2));
  286. if (firstTex) {
  287. texMixed = texColor;
  288. firstTex = false;
  289. } else {
  290. texMixed = Blend(texMixed, texColor);
  291. }
  292. }
  293. #endif
  294. #endif
  295. #endif
  296. // Generates final color
  297. FragColor = min(vec4(Color, MatOpacity) * texMixed, vec4(1));
  298. }
  299. `
  300. const physical_vertex_source = `//
  301. // Physically Based Shading of a microfacet surface material - Vertex Shader
  302. // Modified from reference implementation at https://github.com/KhronosGroup/glTF-WebGL-PBR
  303. //
  304. #include <attributes>
  305. // Model uniforms
  306. uniform mat4 ModelViewMatrix;
  307. uniform mat3 NormalMatrix;
  308. uniform mat4 MVP;
  309. #include <morphtarget_vertex_declaration>
  310. #include <bones_vertex_declaration>
  311. // Output variables for Fragment shader
  312. out vec3 Position;
  313. out vec3 Normal;
  314. out vec3 CamDir;
  315. out vec2 FragTexcoord;
  316. void main() {
  317. // Transform this vertex position to camera coordinates.
  318. Position = vec3(ModelViewMatrix * vec4(VertexPosition, 1.0));
  319. // Transform this vertex normal to camera coordinates.
  320. Normal = normalize(NormalMatrix * VertexNormal);
  321. // Calculate the direction vector from the vertex to the camera
  322. // The camera is at 0,0,0
  323. CamDir = normalize(-Position.xyz);
  324. // Output texture coordinates to fragment shader
  325. FragTexcoord = VertexTexcoord;
  326. vec3 vPosition = VertexPosition;
  327. mat4 finalWorld = mat4(1.0);
  328. #include <morphtarget_vertex>
  329. #include <bones_vertex>
  330. gl_Position = MVP * finalWorld * vec4(vPosition, 1.0);
  331. }
  332. `
  333. const physical_fragment_source = `//
  334. // Physically Based Shading of a microfacet surface material - Fragment Shader
  335. // Modified from reference implementation at https://github.com/KhronosGroup/glTF-WebGL-PBR
  336. //
  337. // References:
  338. // [1] Real Shading in Unreal Engine 4
  339. // http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  340. // [2] Physically Based Shading at Disney
  341. // http://blog.selfshadow.com/publications/s2012-shading-course/burley/s2012_pbs_disney_brdf_notes_v3.pdf
  342. // [3] README.md - Environment Maps
  343. // https://github.com/KhronosGroup/glTF-WebGL-PBR/#environment-maps
  344. // [4] "An Inexpensive BRDF Model for Physically based Rendering" by Christophe Schlick
  345. // https://www.cs.virginia.edu/~jdl/bib/appearance/analytic%20models/schlick94b.pdf
  346. //#extension GL_EXT_shader_texture_lod: enable
  347. //#extension GL_OES_standard_derivatives : enable
  348. precision highp float;
  349. //uniform vec3 u_LightDirection;
  350. //uniform vec3 u_LightColor;
  351. //#ifdef USE_IBL
  352. //uniform samplerCube u_DiffuseEnvSampler;
  353. //uniform samplerCube u_SpecularEnvSampler;
  354. //uniform sampler2D u_brdfLUT;
  355. //#endif
  356. #ifdef HAS_BASECOLORMAP
  357. uniform sampler2D uBaseColorSampler;
  358. #endif
  359. #ifdef HAS_METALROUGHNESSMAP
  360. uniform sampler2D uMetallicRoughnessSampler;
  361. #endif
  362. #ifdef HAS_NORMALMAP
  363. uniform sampler2D uNormalSampler;
  364. //uniform float uNormalScale;
  365. #endif
  366. #ifdef HAS_EMISSIVEMAP
  367. uniform sampler2D uEmissiveSampler;
  368. #endif
  369. #ifdef HAS_OCCLUSIONMAP
  370. uniform sampler2D uOcclusionSampler;
  371. uniform float uOcclusionStrength;
  372. #endif
  373. // Material parameters uniform array
  374. uniform vec4 Material[3];
  375. // Macros to access elements inside the Material array
  376. #define uBaseColor Material[0]
  377. #define uEmissiveColor Material[1]
  378. #define uMetallicFactor Material[2].x
  379. #define uRoughnessFactor Material[2].y
  380. #include <lights>
  381. // Inputs from vertex shader
  382. in vec3 Position; // Vertex position in camera coordinates.
  383. in vec3 Normal; // Vertex normal in camera coordinates.
  384. in vec3 CamDir; // Direction from vertex to camera
  385. in vec2 FragTexcoord;
  386. // Final fragment color
  387. out vec4 FragColor;
  388. // Encapsulate the various inputs used by the various functions in the shading equation
  389. // We store values in this struct to simplify the integration of alternative implementations
  390. // of the shading terms, outlined in the Readme.MD Appendix.
  391. struct PBRLightInfo
  392. {
  393. float NdotL; // cos angle between normal and light direction
  394. float NdotV; // cos angle between normal and view direction
  395. float NdotH; // cos angle between normal and half vector
  396. float LdotH; // cos angle between light direction and half vector
  397. float VdotH; // cos angle between view direction and half vector
  398. };
  399. struct PBRInfo
  400. {
  401. float perceptualRoughness; // roughness value, as authored by the model creator (input to shader)
  402. float metalness; // metallic value at the surface
  403. vec3 reflectance0; // full reflectance color (normal incidence angle)
  404. vec3 reflectance90; // reflectance color at grazing angle
  405. float alphaRoughness; // roughness mapped to a more linear change in the roughness (proposed by [2])
  406. vec3 diffuseColor; // color contribution from diffuse lighting
  407. vec3 specularColor; // color contribution from specular lighting
  408. };
  409. const float M_PI = 3.141592653589793;
  410. const float c_MinRoughness = 0.04;
  411. vec4 SRGBtoLINEAR(vec4 srgbIn) {
  412. //#ifdef MANUAL_SRGB
  413. // #ifdef SRGB_FAST_APPROXIMATION
  414. // vec3 linOut = pow(srgbIn.xyz,vec3(2.2));
  415. // #else //SRGB_FAST_APPROXIMATION
  416. vec3 bLess = step(vec3(0.04045),srgbIn.xyz);
  417. vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );
  418. // #endif //SRGB_FAST_APPROXIMATION
  419. return vec4(linOut,srgbIn.w);
  420. //#else //MANUAL_SRGB
  421. // return srgbIn;
  422. //#endif //MANUAL_SRGB
  423. }
  424. // Find the normal for this fragment, pulling either from a predefined normal map
  425. // or from the interpolated mesh normal and tangent attributes.
  426. vec3 getNormal()
  427. {
  428. // Retrieve the tangent space matrix
  429. //#ifndef HAS_TANGENTS
  430. vec3 pos_dx = dFdx(Position);
  431. vec3 pos_dy = dFdy(Position);
  432. vec3 tex_dx = dFdx(vec3(FragTexcoord, 0.0));
  433. vec3 tex_dy = dFdy(vec3(FragTexcoord, 0.0));
  434. vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);
  435. //#ifdef HAS_NORMALS
  436. vec3 ng = normalize(Normal);
  437. //#else
  438. // vec3 ng = cross(pos_dx, pos_dy);
  439. //#endif
  440. t = normalize(t - ng * dot(ng, t));
  441. vec3 b = normalize(cross(ng, t));
  442. mat3 tbn = mat3(t, b, ng);
  443. //#else // HAS_TANGENTS
  444. // mat3 tbn = v_TBN;
  445. //#endif
  446. #ifdef HAS_NORMALMAP
  447. float uNormalScale = 1.0;
  448. vec3 n = texture(uNormalSampler, FragTexcoord).rgb;
  449. n = normalize(tbn * ((2.0 * n - 1.0) * vec3(uNormalScale, uNormalScale, 1.0)));
  450. #else
  451. // The tbn matrix is linearly interpolated, so we need to re-normalize
  452. vec3 n = normalize(tbn[2].xyz);
  453. #endif
  454. return n;
  455. }
  456. // Calculation of the lighting contribution from an optional Image Based Light source.
  457. // Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].
  458. // See our README.md on Environment Maps [3] for additional discussion.
  459. vec3 getIBLContribution(PBRInfo pbrInputs, PBRLightInfo pbrLight, vec3 n, vec3 reflection)
  460. {
  461. float mipCount = 9.0; // resolution of 512x512
  462. float lod = (pbrInputs.perceptualRoughness * mipCount);
  463. // retrieve a scale and bias to F0. See [1], Figure 3
  464. vec3 brdf = vec3(0.5,0.5,0.5);//SRGBtoLINEAR(texture(u_brdfLUT, vec2(pbrLight.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb;
  465. vec3 diffuseLight = vec3(0.5,0.5,0.5);//SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;
  466. //#ifdef USE_TEX_LOD
  467. // vec3 specularLight = SRGBtoLINEAR(textureCubeLodEXT(u_SpecularEnvSampler, reflection, lod)).rgb;
  468. //#else
  469. vec3 specularLight = vec3(0.5,0.5,0.5);//SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;
  470. //#endif
  471. vec3 diffuse = diffuseLight * pbrInputs.diffuseColor;
  472. vec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y);
  473. // For presentation, this allows us to disable IBL terms
  474. // diffuse *= u_ScaleIBLAmbient.x;
  475. // specular *= u_ScaleIBLAmbient.y;
  476. return diffuse + specular;
  477. }
  478. // Basic Lambertian diffuse
  479. // Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog
  480. // See also [1], Equation 1
  481. vec3 diffuse(PBRInfo pbrInputs)
  482. {
  483. return pbrInputs.diffuseColor / M_PI;
  484. }
  485. // The following equation models the Fresnel reflectance term of the spec equation (aka F())
  486. // Implementation of fresnel from [4], Equation 15
  487. vec3 specularReflection(PBRInfo pbrInputs, PBRLightInfo pbrLight)
  488. {
  489. return pbrInputs.reflectance0 + (pbrInputs.reflectance90 - pbrInputs.reflectance0) * pow(clamp(1.0 - pbrLight.VdotH, 0.0, 1.0), 5.0);
  490. }
  491. // This calculates the specular geometric attenuation (aka G()),
  492. // where rougher material will reflect less light back to the viewer.
  493. // This implementation is based on [1] Equation 4, and we adopt their modifications to
  494. // alphaRoughness as input as originally proposed in [2].
  495. float geometricOcclusion(PBRInfo pbrInputs, PBRLightInfo pbrLight)
  496. {
  497. float NdotL = pbrLight.NdotL;
  498. float NdotV = pbrLight.NdotV;
  499. float r = pbrInputs.alphaRoughness;
  500. float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));
  501. float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));
  502. return attenuationL * attenuationV;
  503. }
  504. // The following equation(s) model the distribution of microfacet normals across the area being drawn (aka D())
  505. // Implementation from "Average Irregularity Representation of a Roughened Surface for Ray Reflection" by T. S. Trowbridge, and K. P. Reitz
  506. // Follows the distribution function recommended in the SIGGRAPH 2013 course notes from EPIC Games [1], Equation 3.
  507. float microfacetDistribution(PBRInfo pbrInputs, PBRLightInfo pbrLight)
  508. {
  509. float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;
  510. float f = (pbrLight.NdotH * roughnessSq - pbrLight.NdotH) * pbrLight.NdotH + 1.0;
  511. return roughnessSq / (M_PI * f * f);
  512. }
  513. vec3 pbrModel(PBRInfo pbrInputs, vec3 lightColor, vec3 lightDir) {
  514. vec3 n = getNormal(); // normal at surface point
  515. vec3 v = normalize(CamDir); // Vector from surface point to camera
  516. vec3 l = normalize(lightDir); // Vector from surface point to light
  517. vec3 h = normalize(l+v); // Half vector between both l and v
  518. vec3 reflection = -normalize(reflect(v, n));
  519. float NdotL = clamp(dot(n, l), 0.001, 1.0);
  520. float NdotV = abs(dot(n, v)) + 0.001;
  521. float NdotH = clamp(dot(n, h), 0.0, 1.0);
  522. float LdotH = clamp(dot(l, h), 0.0, 1.0);
  523. float VdotH = clamp(dot(v, h), 0.0, 1.0);
  524. PBRLightInfo pbrLight = PBRLightInfo(
  525. NdotL,
  526. NdotV,
  527. NdotH,
  528. LdotH,
  529. VdotH
  530. );
  531. // Calculate the shading terms for the microfacet specular shading model
  532. vec3 F = specularReflection(pbrInputs, pbrLight);
  533. float G = geometricOcclusion(pbrInputs, pbrLight);
  534. float D = microfacetDistribution(pbrInputs, pbrLight);
  535. // Calculation of analytical lighting contribution
  536. vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);
  537. vec3 specContrib = F * G * D / (4.0 * NdotL * NdotV);
  538. // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)
  539. vec3 color = NdotL * lightColor * (diffuseContrib + specContrib);
  540. return color;
  541. }
  542. void main() {
  543. float perceptualRoughness = uRoughnessFactor;
  544. float metallic = uMetallicFactor;
  545. #ifdef HAS_METALROUGHNESSMAP
  546. // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.
  547. // This layout intentionally reserves the 'r' channel for (optional) occlusion map data
  548. vec4 mrSample = texture(uMetallicRoughnessSampler, FragTexcoord);
  549. perceptualRoughness = mrSample.g * perceptualRoughness;
  550. metallic = mrSample.b * metallic;
  551. #endif
  552. perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);
  553. metallic = clamp(metallic, 0.0, 1.0);
  554. // Roughness is authored as perceptual roughness; as is convention,
  555. // convert to material roughness by squaring the perceptual roughness [2].
  556. float alphaRoughness = perceptualRoughness * perceptualRoughness;
  557. // The albedo may be defined from a base texture or a flat color
  558. #ifdef HAS_BASECOLORMAP
  559. vec4 baseColor = SRGBtoLINEAR(texture(uBaseColorSampler, FragTexcoord)) * uBaseColor;
  560. #else
  561. vec4 baseColor = uBaseColor;
  562. #endif
  563. vec3 f0 = vec3(0.04);
  564. vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);
  565. diffuseColor *= 1.0 - metallic;
  566. vec3 specularColor = mix(f0, baseColor.rgb, uMetallicFactor);
  567. // Compute reflectance.
  568. float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
  569. // For typical incident reflectance range (between 4% to 100%) set the grazing reflectance to 100% for typical fresnel effect.
  570. // For very low reflectance range on highly diffuse objects (below 4%), incrementally reduce grazing reflectance to 0%.
  571. float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
  572. vec3 specularEnvironmentR0 = specularColor.rgb;
  573. vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;
  574. PBRInfo pbrInputs = PBRInfo(
  575. perceptualRoughness,
  576. metallic,
  577. specularEnvironmentR0,
  578. specularEnvironmentR90,
  579. alphaRoughness,
  580. diffuseColor,
  581. specularColor
  582. );
  583. // vec3 normal = getNormal();
  584. vec3 color = vec3(0.0);
  585. #if AMB_LIGHTS>0
  586. // Ambient lights
  587. for (int i = 0; i < AMB_LIGHTS; i++) {
  588. color += AmbientLightColor[i] * pbrInputs.diffuseColor;
  589. }
  590. #endif
  591. #if DIR_LIGHTS>0
  592. // Directional lights
  593. for (int i = 0; i < DIR_LIGHTS; i++) {
  594. // Diffuse reflection
  595. // DirLightPosition is the direction of the current light
  596. vec3 lightDirection = normalize(DirLightPosition(i));
  597. // PBR
  598. color += pbrModel(pbrInputs, DirLightColor(i), lightDirection);
  599. }
  600. #endif
  601. #if POINT_LIGHTS>0
  602. // Point lights
  603. for (int i = 0; i < POINT_LIGHTS; i++) {
  604. // Common calculations
  605. // Calculates the direction and distance from the current vertex to this point light.
  606. vec3 lightDirection = PointLightPosition(i) - vec3(Position);
  607. float lightDistance = length(lightDirection);
  608. // Normalizes the lightDirection
  609. lightDirection = lightDirection / lightDistance;
  610. // Calculates the attenuation due to the distance of the light
  611. float attenuation = 1.0 / (1.0 + PointLightLinearDecay(i) * lightDistance +
  612. PointLightQuadraticDecay(i) * lightDistance * lightDistance);
  613. vec3 attenuatedColor = PointLightColor(i) * attenuation;
  614. // PBR
  615. color += pbrModel(pbrInputs, attenuatedColor, lightDirection);
  616. }
  617. #endif
  618. #if SPOT_LIGHTS>0
  619. for (int i = 0; i < SPOT_LIGHTS; i++) {
  620. // Calculates the direction and distance from the current vertex to this spot light.
  621. vec3 lightDirection = SpotLightPosition(i) - vec3(Position);
  622. float lightDistance = length(lightDirection);
  623. lightDirection = lightDirection / lightDistance;
  624. // Calculates the attenuation due to the distance of the light
  625. float attenuation = 1.0 / (1.0 + SpotLightLinearDecay(i) * lightDistance +
  626. SpotLightQuadraticDecay(i) * lightDistance * lightDistance);
  627. // Calculates the angle between the vertex direction and spot direction
  628. // If this angle is greater than the cutoff the spotlight will not contribute
  629. // to the final color.
  630. float angle = acos(dot(-lightDirection, SpotLightDirection(i)));
  631. float cutoff = radians(clamp(SpotLightCutoffAngle(i), 0.0, 90.0));
  632. if (angle < cutoff) {
  633. float spotFactor = pow(dot(-lightDirection, SpotLightDirection(i)), SpotLightAngularDecay(i));
  634. vec3 attenuatedColor = SpotLightColor(i) * attenuation * spotFactor;
  635. // PBR
  636. color += pbrModel(pbrInputs, attenuatedColor, lightDirection);
  637. }
  638. }
  639. #endif
  640. // Calculate lighting contribution from image based lighting source (IBL)
  641. //#ifdef USE_IBL
  642. // color += getIBLContribution(pbrInputs, n, reflection);
  643. //#endif
  644. // Apply optional PBR terms for additional (optional) shading
  645. #ifdef HAS_OCCLUSIONMAP
  646. float ao = texture(uOcclusionSampler, FragTexcoord).r;
  647. color = mix(color, color * ao, 1.0);//, uOcclusionStrength);
  648. #endif
  649. #ifdef HAS_EMISSIVEMAP
  650. vec3 emissive = SRGBtoLINEAR(texture(uEmissiveSampler, FragTexcoord)).rgb * vec3(uEmissiveColor);
  651. #else
  652. vec3 emissive = vec3(uEmissiveColor);
  653. #endif
  654. color += emissive;
  655. // Base Color
  656. // FragColor = baseColor;
  657. // Normal
  658. // FragColor = vec4(n, 1.0);
  659. // Emissive Color
  660. // FragColor = vec4(emissive, 1.0);
  661. // F
  662. // color = F;
  663. // G
  664. // color = vec3(G);
  665. // D
  666. // color = vec3(D);
  667. // Specular
  668. // color = specContrib;
  669. // Diffuse
  670. // color = diffuseContrib;
  671. // Roughness
  672. // color = vec3(perceptualRoughness);
  673. // Metallic
  674. // color = vec3(metallic);
  675. // Final fragment color
  676. FragColor = vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
  677. }
  678. `
  679. const point_vertex_source = `#include <attributes>
  680. // Model uniforms
  681. uniform mat4 MVP;
  682. uniform mat4 MV;
  683. // Material uniforms
  684. #include <material>
  685. // Outputs for fragment shader
  686. out vec3 Color;
  687. flat out mat2 Rotation;
  688. void main() {
  689. // Rotation matrix for fragment shader
  690. float rotSin = sin(MatPointRotationZ);
  691. float rotCos = cos(MatPointRotationZ);
  692. Rotation = mat2(rotCos, rotSin, - rotSin, rotCos);
  693. // Sets the vertex position
  694. vec4 pos = MVP * vec4(VertexPosition, 1.0);
  695. gl_Position = pos;
  696. // Sets the size of the rasterized point decreasing with distance
  697. vec4 posMV = MV * vec4(VertexPosition, 1.0);
  698. gl_PointSize = MatPointSize / -posMV.z;
  699. // Outputs color
  700. Color = MatEmissiveColor;
  701. }
  702. `
  703. const standard_vertex_source = `#include <attributes>
  704. // Model uniforms
  705. uniform mat4 ModelViewMatrix;
  706. uniform mat3 NormalMatrix;
  707. uniform mat4 MVP;
  708. #include <material>
  709. #include <morphtarget_vertex_declaration>
  710. #include <bones_vertex_declaration>
  711. // Output variables for Fragment shader
  712. out vec4 Position;
  713. out vec3 Normal;
  714. out vec2 FragTexcoord;
  715. void main() {
  716. // Transform vertex position to camera coordinates
  717. Position = ModelViewMatrix * vec4(VertexPosition, 1.0);
  718. // Transform vertex normal to camera coordinates
  719. Normal = normalize(NormalMatrix * VertexNormal);
  720. vec2 texcoord = VertexTexcoord;
  721. #if MAT_TEXTURES > 0
  722. // Flip texture coordinate Y if requested.
  723. if (MatTexFlipY(0)) {
  724. texcoord.y = 1.0 - texcoord.y;
  725. }
  726. #endif
  727. FragTexcoord = texcoord;
  728. vec3 vPosition = VertexPosition;
  729. mat4 finalWorld = mat4(1.0);
  730. #include <morphtarget_vertex>
  731. #include <bones_vertex>
  732. // Output projected and transformed vertex position
  733. gl_Position = MVP * finalWorld * vec4(vPosition, 1.0);
  734. }
  735. `
  736. const basic_vertex_source = `#include <attributes>
  737. // Model uniforms
  738. uniform mat4 MVP;
  739. // Final output color for fragment shader
  740. out vec3 Color;
  741. void main() {
  742. Color = VertexColor;
  743. gl_Position = MVP * vec4(VertexPosition, 1.0);
  744. }
  745. `
  746. const standard_fragment_source = `precision highp float;
  747. // Inputs from vertex shader
  748. in vec4 Position; // Fragment position in camera coordinates
  749. in vec3 Normal; // Fragment normal in camera coordinates
  750. in vec2 FragTexcoord; // Fragment texture coordinates
  751. #include <lights>
  752. #include <material>
  753. #include <phong_model>
  754. // Final fragment color
  755. out vec4 FragColor;
  756. void main() {
  757. // Compute final texture color
  758. vec4 texMixed = vec4(1);
  759. #if MAT_TEXTURES > 0
  760. bool firstTex = true;
  761. if (MatTexVisible(0)) {
  762. vec4 texColor = texture(MatTexture[0], FragTexcoord * MatTexRepeat(0) + MatTexOffset(0));
  763. if (firstTex) {
  764. texMixed = texColor;
  765. firstTex = false;
  766. } else {
  767. texMixed = Blend(texMixed, texColor);
  768. }
  769. }
  770. #if MAT_TEXTURES > 1
  771. if (MatTexVisible(1)) {
  772. vec4 texColor = texture(MatTexture[1], FragTexcoord * MatTexRepeat(1) + MatTexOffset(1));
  773. if (firstTex) {
  774. texMixed = texColor;
  775. firstTex = false;
  776. } else {
  777. texMixed = Blend(texMixed, texColor);
  778. }
  779. }
  780. #if MAT_TEXTURES > 2
  781. if (MatTexVisible(2)) {
  782. vec4 texColor = texture(MatTexture[2], FragTexcoord * MatTexRepeat(2) + MatTexOffset(2));
  783. if (firstTex) {
  784. texMixed = texColor;
  785. firstTex = false;
  786. } else {
  787. texMixed = Blend(texMixed, texColor);
  788. }
  789. }
  790. #endif
  791. #endif
  792. #endif
  793. // Combine material with texture colors
  794. vec4 matDiffuse = vec4(MatDiffuseColor, MatOpacity) * texMixed;
  795. vec4 matAmbient = vec4(MatAmbientColor, MatOpacity) * texMixed;
  796. // Normalize interpolated normal as it may have shrinked
  797. vec3 fragNormal = normalize(Normal);
  798. // Calculate the direction vector from the fragment to the camera (origin)
  799. vec3 camDir = normalize(-Position.xyz);
  800. // Workaround for gl_FrontFacing
  801. vec3 fdx = dFdx(Position.xyz);
  802. vec3 fdy = dFdy(Position.xyz);
  803. vec3 faceNormal = normalize(cross(fdx,fdy));
  804. if (dot(fragNormal, faceNormal) < 0.0) { // Back-facing
  805. fragNormal = -fragNormal;
  806. }
  807. // Calculates the Ambient+Diffuse and Specular colors for this fragment using the Phong model.
  808. vec3 Ambdiff, Spec;
  809. phongModel(Position, fragNormal, camDir, vec3(matAmbient), vec3(matDiffuse), Ambdiff, Spec);
  810. // Final fragment color
  811. FragColor = min(vec4(Ambdiff + Spec, matDiffuse.a), vec4(1.0));
  812. }
  813. `
  814. const panel_vertex_source = `#include <attributes>
  815. // Model uniforms
  816. uniform mat4 ModelMatrix;
  817. // Outputs for fragment shader
  818. out vec2 FragTexcoord;
  819. void main() {
  820. // Always flip texture coordinates
  821. vec2 texcoord = VertexTexcoord;
  822. texcoord.y = 1.0 - texcoord.y;
  823. FragTexcoord = texcoord;
  824. // Set position
  825. vec4 pos = vec4(VertexPosition.xyz, 1);
  826. gl_Position = ModelMatrix * pos;
  827. }
  828. `
  829. const basic_fragment_source = `precision highp float;
  830. in vec3 Color;
  831. out vec4 FragColor;
  832. void main() {
  833. FragColor = vec4(Color, 1.0);
  834. }
  835. `
  836. const panel_fragment_source = `precision highp float;
  837. // Texture uniforms
  838. uniform sampler2D MatTexture;
  839. uniform vec2 MatTexinfo[3];
  840. // Macros to access elements inside the MatTexinfo array
  841. #define MatTexOffset MatTexinfo[0]
  842. #define MatTexRepeat MatTexinfo[1]
  843. #define MatTexFlipY bool(MatTexinfo[2].x) // not used
  844. #define MatTexVisible bool(MatTexinfo[2].y) // not used
  845. // Inputs from vertex shader
  846. in vec2 FragTexcoord;
  847. // Input uniform
  848. uniform vec4 Panel[8];
  849. #define Bounds Panel[0] // panel bounds in texture coordinates
  850. #define Border Panel[1] // panel border in texture coordinates
  851. #define Padding Panel[2] // panel padding in texture coordinates
  852. #define Content Panel[3] // panel content area in texture coordinates
  853. #define BorderColor Panel[4] // panel border color
  854. #define PaddingColor Panel[5] // panel padding color
  855. #define ContentColor Panel[6] // panel content color
  856. #define TextureValid bool(Panel[7].x) // texture valid flag
  857. // Output
  858. out vec4 FragColor;
  859. /***
  860. * Checks if current fragment texture coordinate is inside the
  861. * supplied rectangle in texture coordinates:
  862. * rect[0] - position x [0,1]
  863. * rect[1] - position y [0,1]
  864. * rect[2] - width [0,1]
  865. * rect[3] - height [0,1]
  866. */
  867. bool checkRect(vec4 rect) {
  868. if (FragTexcoord.x < rect[0]) {
  869. return false;
  870. }
  871. if (FragTexcoord.x > rect[0] + rect[2]) {
  872. return false;
  873. }
  874. if (FragTexcoord.y < rect[1]) {
  875. return false;
  876. }
  877. if (FragTexcoord.y > rect[1] + rect[3]) {
  878. return false;
  879. }
  880. return true;
  881. }
  882. void main() {
  883. // Discard fragment outside of received bounds
  884. // Bounds[0] - xmin
  885. // Bounds[1] - ymin
  886. // Bounds[2] - xmax
  887. // Bounds[3] - ymax
  888. if (FragTexcoord.x <= Bounds[0] || FragTexcoord.x >= Bounds[2]) {
  889. discard;
  890. }
  891. if (FragTexcoord.y <= Bounds[1] || FragTexcoord.y >= Bounds[3]) {
  892. discard;
  893. }
  894. // Check if fragment is inside content area
  895. if (checkRect(Content)) {
  896. // If no texture, the color will be the material color.
  897. vec4 color = ContentColor;
  898. if (TextureValid) {
  899. // Adjust texture coordinates to fit texture inside the content area
  900. vec2 offset = vec2(-Content[0], -Content[1]);
  901. vec2 factor = vec2(1.0/Content[2], 1.0/Content[3]);
  902. vec2 texcoord = (FragTexcoord + offset) * factor;
  903. vec4 texColor = texture(MatTexture, texcoord * MatTexRepeat + MatTexOffset);
  904. // Mix content color with texture color.
  905. // Note that doing a simple linear interpolation (e.g. using mix()) is not correct!
  906. // The right formula can be found here: https://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending
  907. // For a more in-depth discussion: http://apoorvaj.io/alpha-compositing-opengl-blending-and-premultiplied-alpha.html#toc4
  908. // Another great discussion here: https://ciechanow.ski/alpha-compositing/
  909. // Alpha premultiply the content color
  910. vec4 contentPre = ContentColor;
  911. contentPre.rgb *= contentPre.a;
  912. // Alpha premultiply the content color
  913. vec4 texPre = texColor;
  914. texPre.rgb *= texPre.a;
  915. // Combine colors to obtain the alpha premultiplied final color
  916. color = texPre + contentPre * (1.0 - texPre.a);
  917. // Un-alpha-premultiply
  918. color.rgb /= color.a;
  919. }
  920. FragColor = color;
  921. return;
  922. }
  923. // Checks if fragment is inside paddings area
  924. if (checkRect(Padding)) {
  925. FragColor = PaddingColor;
  926. return;
  927. }
  928. // Checks if fragment is inside borders area
  929. if (checkRect(Border)) {
  930. FragColor = BorderColor;
  931. return;
  932. }
  933. // Fragment is in margins area (always transparent)
  934. FragColor = vec4(1,1,1,0);
  935. }
  936. `
  937. // Maps include name with its source code
  938. var includeMap = map[string]string{
  939. "morphtarget_vertex2": include_morphtarget_vertex2_source,
  940. "morphtarget_vertex_declaration2": include_morphtarget_vertex_declaration2_source,
  941. "morphtarget_vertex": include_morphtarget_vertex_source,
  942. "morphtarget_vertex_declaration": include_morphtarget_vertex_declaration_source,
  943. "bones_vertex": include_bones_vertex_source,
  944. "phong_model": include_phong_model_source,
  945. "attributes": include_attributes_source,
  946. "material": include_material_source,
  947. "lights": include_lights_source,
  948. "bones_vertex_declaration": include_bones_vertex_declaration_source,
  949. }
  950. // Maps shader name with its source code
  951. var shaderMap = map[string]string{
  952. "point_fragment": point_fragment_source,
  953. "physical_vertex": physical_vertex_source,
  954. "physical_fragment": physical_fragment_source,
  955. "point_vertex": point_vertex_source,
  956. "standard_vertex": standard_vertex_source,
  957. "basic_vertex": basic_vertex_source,
  958. "standard_fragment": standard_fragment_source,
  959. "panel_vertex": panel_vertex_source,
  960. "basic_fragment": basic_fragment_source,
  961. "panel_fragment": panel_fragment_source,
  962. }
  963. // Maps program name with Proginfo struct with shaders names
  964. var programMap = map[string]ProgramInfo{
  965. "basic": {"basic_vertex", "basic_fragment", ""},
  966. "panel": {"panel_vertex", "panel_fragment", ""},
  967. "physical": {"physical_vertex", "physical_fragment", ""},
  968. "point": {"point_vertex", "point_fragment", ""},
  969. "standard": {"standard_vertex", "standard_fragment", ""},
  970. }