sources.go 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147
  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
  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. // Inputs from vertex shader
  750. in vec3 Color;
  751. flat in mat2 Rotation;
  752. // Output
  753. out vec4 FragColor;
  754. void main() {
  755. // Compute final texture color
  756. vec4 texMixed = vec4(1);
  757. #if MAT_TEXTURES > 0
  758. vec2 pointCoord = Rotation * gl_PointCoord - vec2(0.5) + vec2(0.5);
  759. bool firstTex = true;
  760. if (MatTexVisible(0)) {
  761. vec4 texColor = texture(MatTexture[0], pointCoord * MatTexRepeat(0) + MatTexOffset(0));
  762. if (firstTex) {
  763. texMixed = texColor;
  764. firstTex = false;
  765. } else {
  766. texMixed = Blend(texMixed, texColor);
  767. }
  768. }
  769. #if MAT_TEXTURES > 1
  770. if (MatTexVisible(1)) {
  771. vec4 texColor = texture(MatTexture[1], pointCoord * MatTexRepeat(1) + MatTexOffset(1));
  772. if (firstTex) {
  773. texMixed = texColor;
  774. firstTex = false;
  775. } else {
  776. texMixed = Blend(texMixed, texColor);
  777. }
  778. }
  779. #if MAT_TEXTURES > 2
  780. if (MatTexVisible(2)) {
  781. vec4 texColor = texture(MatTexture[2], pointCoord * MatTexRepeat(2) + MatTexOffset(2));
  782. if (firstTex) {
  783. texMixed = texColor;
  784. firstTex = false;
  785. } else {
  786. texMixed = Blend(texMixed, texColor);
  787. }
  788. }
  789. #endif
  790. #endif
  791. #endif
  792. // Generates final color
  793. FragColor = min(vec4(Color, MatOpacity) * texMixed, vec4(1));
  794. }
  795. `
  796. const point_vertex_source = `#include <attributes>
  797. // Model uniforms
  798. uniform mat4 MVP;
  799. uniform mat4 MV;
  800. // Material uniforms
  801. #include <material>
  802. // Outputs for fragment shader
  803. out vec3 Color;
  804. flat out mat2 Rotation;
  805. void main() {
  806. // Rotation matrix for fragment shader
  807. float rotSin = sin(MatPointRotationZ);
  808. float rotCos = cos(MatPointRotationZ);
  809. Rotation = mat2(rotCos, rotSin, - rotSin, rotCos);
  810. // Sets the vertex position
  811. vec4 pos = MVP * vec4(VertexPosition, 1.0);
  812. gl_Position = pos;
  813. // Sets the size of the rasterized point decreasing with distance
  814. vec4 posMV = MV * vec4(VertexPosition, 1.0);
  815. gl_PointSize = MatPointSize / -posMV.z;
  816. // Outputs color
  817. Color = MatEmissiveColor;
  818. }
  819. `
  820. const standard_fragment_source = `precision highp float;
  821. // Inputs from vertex shader
  822. in vec4 Position; // Fragment position in camera coordinates
  823. in vec3 Normal; // Fragment normal in camera coordinates
  824. in vec2 FragTexcoord; // Fragment texture coordinates
  825. #include <lights>
  826. #include <material>
  827. #include <phong_model>
  828. // Final fragment color
  829. out vec4 FragColor;
  830. void main() {
  831. // Compute final texture color
  832. vec4 texMixed = vec4(1);
  833. #if MAT_TEXTURES > 0
  834. bool firstTex = true;
  835. if (MatTexVisible(0)) {
  836. vec4 texColor = texture(MatTexture[0], FragTexcoord * MatTexRepeat(0) + MatTexOffset(0));
  837. if (firstTex) {
  838. texMixed = texColor;
  839. firstTex = false;
  840. } else {
  841. texMixed = Blend(texMixed, texColor);
  842. }
  843. }
  844. #if MAT_TEXTURES > 1
  845. if (MatTexVisible(1)) {
  846. vec4 texColor = texture(MatTexture[1], FragTexcoord * MatTexRepeat(1) + MatTexOffset(1));
  847. if (firstTex) {
  848. texMixed = texColor;
  849. firstTex = false;
  850. } else {
  851. texMixed = Blend(texMixed, texColor);
  852. }
  853. }
  854. #if MAT_TEXTURES > 2
  855. if (MatTexVisible(2)) {
  856. vec4 texColor = texture(MatTexture[2], FragTexcoord * MatTexRepeat(2) + MatTexOffset(2));
  857. if (firstTex) {
  858. texMixed = texColor;
  859. firstTex = false;
  860. } else {
  861. texMixed = Blend(texMixed, texColor);
  862. }
  863. }
  864. #endif
  865. #endif
  866. #endif
  867. // Combine material with texture colors
  868. vec4 matDiffuse = vec4(MatDiffuseColor, MatOpacity) * texMixed;
  869. vec4 matAmbient = vec4(MatAmbientColor, MatOpacity) * texMixed;
  870. // Normalize interpolated normal as it may have shrinked
  871. vec3 fragNormal = normalize(Normal);
  872. // Calculate the direction vector from the fragment to the camera (origin)
  873. vec3 camDir = normalize(-Position.xyz);
  874. // Workaround for gl_FrontFacing
  875. vec3 fdx = dFdx(Position.xyz);
  876. vec3 fdy = dFdy(Position.xyz);
  877. vec3 faceNormal = normalize(cross(fdx,fdy));
  878. if (dot(fragNormal, faceNormal) < 0.0) { // Back-facing
  879. fragNormal = -fragNormal;
  880. }
  881. // Calculates the Ambient+Diffuse and Specular colors for this fragment using the Phong model.
  882. vec3 Ambdiff, Spec;
  883. phongModel(Position, fragNormal, camDir, vec3(matAmbient), vec3(matDiffuse), Ambdiff, Spec);
  884. // Final fragment color
  885. FragColor = min(vec4(Ambdiff + Spec, matDiffuse.a), vec4(1.0));
  886. }
  887. `
  888. const standard_vertex_source = `#include <attributes>
  889. // Model uniforms
  890. uniform mat4 ModelViewMatrix;
  891. uniform mat3 NormalMatrix;
  892. uniform mat4 MVP;
  893. #include <material>
  894. #include <morphtarget_vertex_declaration>
  895. #include <bones_vertex_declaration>
  896. // Output variables for Fragment shader
  897. out vec4 Position;
  898. out vec3 Normal;
  899. out vec2 FragTexcoord;
  900. void main() {
  901. // Transform vertex position to camera coordinates
  902. Position = ModelViewMatrix * vec4(VertexPosition, 1.0);
  903. // Transform vertex normal to camera coordinates
  904. Normal = normalize(NormalMatrix * VertexNormal);
  905. vec2 texcoord = VertexTexcoord;
  906. #if MAT_TEXTURES > 0
  907. // Flip texture coordinate Y if requested.
  908. if (MatTexFlipY(0)) {
  909. texcoord.y = 1.0 - texcoord.y;
  910. }
  911. #endif
  912. FragTexcoord = texcoord;
  913. vec3 vPosition = VertexPosition;
  914. mat4 finalWorld = mat4(1.0);
  915. #include <morphtarget_vertex>
  916. #include <bones_vertex>
  917. // Output projected and transformed vertex position
  918. gl_Position = MVP * finalWorld * vec4(vPosition, 1.0);
  919. }
  920. `
  921. // Maps include name with its source code
  922. var includeMap = map[string]string{
  923. "attributes": include_attributes_source,
  924. "bones_vertex": include_bones_vertex_source,
  925. "bones_vertex_declaration": include_bones_vertex_declaration_source,
  926. "lights": include_lights_source,
  927. "material": include_material_source,
  928. "morphtarget_vertex": include_morphtarget_vertex_source,
  929. "morphtarget_vertex2": include_morphtarget_vertex2_source,
  930. "morphtarget_vertex_declaration": include_morphtarget_vertex_declaration_source,
  931. "morphtarget_vertex_declaration2": include_morphtarget_vertex_declaration2_source,
  932. "phong_model": include_phong_model_source,
  933. }
  934. // Maps shader name with its source code
  935. var shaderMap = map[string]string{
  936. "basic_fragment": basic_fragment_source,
  937. "basic_vertex": basic_vertex_source,
  938. "panel_fragment": panel_fragment_source,
  939. "panel_vertex": panel_vertex_source,
  940. "physical_fragment": physical_fragment_source,
  941. "physical_vertex": physical_vertex_source,
  942. "point_fragment": point_fragment_source,
  943. "point_vertex": point_vertex_source,
  944. "standard_fragment": standard_fragment_source,
  945. "standard_vertex": standard_vertex_source,
  946. }
  947. // Maps program name with Proginfo struct with shaders names
  948. var programMap = map[string]ProgramInfo{
  949. "basic": {"basic_vertex", "basic_fragment", ""},
  950. "panel": {"panel_vertex", "panel_fragment", ""},
  951. "physical": {"physical_vertex", "physical_fragment", ""},
  952. "point": {"point_vertex", "point_fragment", ""},
  953. "standard": {"standard_vertex", "standard_fragment", ""},
  954. }