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