sources.go 39 KB

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