sources.go 39 KB

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