sources.go 39 KB

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