Browse Source

refactored shader building

Alexander Rose 5 years ago
parent
commit
0b346a580f

+ 0 - 3
package.json

@@ -93,9 +93,6 @@
     "css-loader": "^2.1.1",
     "extra-watch-webpack-plugin": "^1.0.3",
     "file-loader": "^3.0.1",
-    "glslify": "^7.0.0",
-    "glslify-import": "^3.1.0",
-    "glslify-loader": "^2.0.0",
     "graphql-code-generator": "^0.18.1",
     "graphql-codegen-time": "^0.18.1",
     "graphql-codegen-typescript-template": "^0.18.1",

+ 45 - 2
src/mol-gl/shader-code.ts

@@ -29,8 +29,51 @@ export interface ShaderCode {
     readonly extensions: ShaderExtensions
 }
 
+const ShaderChunks: { [k: string]: string } = {
+    'apply_fog': require('mol-gl/shader/chunks/apply-fog.glsl').default,
+    'apply_light_color': require('mol-gl/shader/chunks/apply-light-color.glsl').default,
+    'apply_marker_color': require('mol-gl/shader/chunks/apply-marker-color.glsl').default,
+    'assign_color_varying': require('mol-gl/shader/chunks/assign-color-varying.glsl').default,
+    'assign_group': require('mol-gl/shader/chunks/assign-group.glsl').default,
+    'assign_marker_varying': require('mol-gl/shader/chunks/assign-marker-varying.glsl').default,
+    'assign_material_color': require('mol-gl/shader/chunks/assign-material-color.glsl').default,
+    'assign_normal': require('mol-gl/shader/chunks/assign-normal.glsl').default,
+    'assign_position': require('mol-gl/shader/chunks/assign-position.glsl').default,
+    'assign_size': require('mol-gl/shader/chunks/assign-size.glsl').default,
+    'color_frag_params': require('mol-gl/shader/chunks/color-frag-params.glsl').default,
+    'color_vert_params': require('mol-gl/shader/chunks/color-vert-params.glsl').default,
+    'common_frag_params': require('mol-gl/shader/chunks/common-frag-params.glsl').default,
+    'common_vert_params': require('mol-gl/shader/chunks/common-vert-params.glsl').default,
+    'common': require('mol-gl/shader/chunks/common.glsl').default,
+    'light_frag_params': require('mol-gl/shader/chunks/light-frag-params.glsl').default,
+    'matrix_scale': require('mol-gl/shader/chunks/matrix-scale.glsl').default,
+    'normal_frag_params': require('mol-gl/shader/chunks/normal-frag-params.glsl').default,
+    'read_from_texture': require('mol-gl/shader/chunks/read-from-texture.glsl').default,
+    'size_vert_params': require('mol-gl/shader/chunks/size-vert-params.glsl').default,
+    'texture3d_from_2d_linear': require('mol-gl/shader/chunks/texture3d-from-2d-nearest.glsl').default,
+    'texture3d_from_2d_nearest': require('mol-gl/shader/chunks/texture3d-from-2d-nearest.glsl').default,
+}
+
+const reInclude = /^(?!\/\/)\s*#include\s+(\S+)/gmi
+const reSingleLineComment = /[ \t]*\/\/.*\n/g
+const reMultiLineComment = /[ \t]*\/\*[\s\S]*?\*\//g
+const reMultipleLinebreaks = /\n{2,}/g
+
+function addIncludes(text: string) {
+    return text
+        .replace(reInclude, (_, p1) => {
+            const chunk = ShaderChunks[p1]
+            if (!chunk) throw new Error(`empty chunk, '${p1}'`)
+            return chunk
+        })
+        .trim()
+        .replace(reSingleLineComment, '\n')
+        .replace(reMultiLineComment, '\n')
+        .replace(reMultipleLinebreaks, '\n')
+}
+
 export function ShaderCode(vert: string, frag: string, extensions: ShaderExtensions = {}): ShaderCode {
-    return { id: shaderCodeId(), vert, frag, extensions }
+    return { id: shaderCodeId(), vert: addIncludes(vert), frag: addIncludes(frag), extensions }
 }
 
 export const PointsShaderCode = ShaderCode(
@@ -67,7 +110,7 @@ export const DirectVolumeShaderCode = ShaderCode(
     { fragDepth: true }
 )
 
-
+//
 
 export type ShaderDefines = {
     [k: string]: ValueCell<DefineType>

+ 0 - 1
src/mol-gl/shader/chunks/color-vert-params.glsl

@@ -13,7 +13,6 @@
     #else
         flat out vec4 vColor;
     #endif
-    #pragma glslify: encodeFloatRGB = require(../utils/encode-float-rgb.glsl)
 #endif
 
 #ifdef dOverpaint

+ 1 - 3
src/mol-gl/shader/chunks/common-frag-params.glsl

@@ -14,6 +14,4 @@ uniform vec3 uFogColor;
 
 uniform float uAlpha;
 uniform float uPickingAlphaThreshold;
-uniform int uPickable;
-
-#pragma glslify: import('./common.glsl')
+uniform int uPickable;

+ 1 - 4
src/mol-gl/shader/chunks/common-vert-params.glsl

@@ -9,7 +9,4 @@ uniform vec2 uMarkerTexDim;
 uniform sampler2D tMarker;
 varying float vMarker;
 
-varying vec3 vViewPosition;
-
-#pragma glslify: import('./common.glsl')
-#pragma glslify: readFromTexture = require('../utils/read-from-texture.glsl', intMod=intMod, intDiv=intDiv, foo=foo) // foo=foo is a workaround for a bug in glslify
+varying vec3 vViewPosition;

+ 19 - 0
src/mol-gl/shader/chunks/common.glsl

@@ -9,6 +9,25 @@ float intMod(const in float a, const in float b) { return a - b * float(int(a) /
 
 float pow2(const in float x) { return x*x; }
 
+const float maxFloat = 10000.0; // NOTE constant also set in TypeScript
+const float floatLogFactor = log(maxFloat + 1.0);
+float encodeFloatLog(const in float value) { return log(value + 1.0) / floatLogFactor; }
+float decodeFloatLog(const in float value) { return exp(value * floatLogFactor) - 1.0; }
+
+vec3 encodeFloatRGB(in float value) {
+    value = clamp(value, 0.0, 16777216.0 - 1.0) + 1.0;
+    vec3 c = vec3(0.0);
+    c.b = mod(value, 256.0);
+    value = floor(value / 256.0);
+    c.g = mod(value, 256.0);
+    value = floor(value / 256.0);
+    c.r = mod(value, 256.0);
+    return c / 255.0;
+}
+float decodeFloatRGB(const in vec3 rgb) {
+    return (rgb.r * 256.0 * 256.0 * 255.0 + rgb.g * 256.0 * 255.0 + rgb.b * 255.0) - 1.0;
+}
+
 #if __VERSION__ != 300
     // transpose
 

+ 1 - 3
src/mol-gl/shader/utils/matrix-scale.glsl → src/mol-gl/shader/chunks/matrix-scale.glsl

@@ -7,6 +7,4 @@
 float matrixScale(in mat4 m){
     vec4 r = m[0];
     return sqrt(r[0] * r[0] + r[1] * r[1] + r[2] * r[2]);
-}
-
-#pragma glslify: export(matrixScale)
+}

+ 1 - 2
src/mol-gl/shader/utils/read-from-texture.glsl → src/mol-gl/shader/chunks/read-from-texture.glsl

@@ -9,5 +9,4 @@ vec4 readFromTexture (const in sampler2D tex, const in float i, const in vec2 di
     float y = floor(intDiv(i, dim.x));
     vec2 uv = (vec2(x, y) + 0.5) / dim;
     return texture2D(tex, uv);
-}
-#pragma glslify: export(readFromTexture)
+}

+ 0 - 1
src/mol-gl/shader/chunks/size-vert-params.glsl

@@ -5,7 +5,6 @@
 #elif defined(dSizeType_instance) || defined(dSizeType_group) || defined(dSizeType_groupInstance)
     uniform vec2 uSizeTexDim;
     uniform sampler2D tSize;
-    #pragma glslify: decodeFloatLog = require(../utils/decode-float-log.glsl)
 #endif
 
 uniform float uSizeFactor;

+ 1 - 3
src/mol-gl/shader/utils/texture3d-from-2d-linear.glsl → src/mol-gl/shader/chunks/texture3d-from-2d-linear.glsl

@@ -20,6 +20,4 @@ vec4 texture3dFrom2dLinear(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) {
 
     float delta0 = abs((pos.z * gridDim.z) - zSlice0);
     return mix(color0, color1, delta0);
-}
-
-#pragma glslify: export(texture3dFrom2dLinear)
+}

+ 1 - 3
src/mol-gl/shader/utils/texture3d-from-2d-nearest.glsl → src/mol-gl/shader/chunks/texture3d-from-2d-nearest.glsl

@@ -11,6 +11,4 @@ vec4 texture3dFrom2dNearest(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim)
     float row = floor(intDiv(zSlice * gridDim.x, texDim.x));
     vec2 coord = (vec2(column * gridDim.x, row * gridDim.y) + (pos.xy * gridDim.xy)) / texDim;
     return texture2D(tex, coord);
-}
-
-#pragma glslify: export(texture3dFrom2dNearest)
+}

+ 7 - 9
src/mol-gl/shader/direct-volume.frag

@@ -45,14 +45,12 @@ uniform int uPickable;
     uniform sampler2D tColor;
 #endif
 
-#pragma glslify: import('./chunks/common.glsl')
-#pragma glslify: import('./chunks/light-frag-params.glsl')
+#include common
+#include light_frag_params
 
-#pragma glslify: readFromTexture = require(./utils/read-from-texture.glsl, intMod=intMod, intDiv=intDiv, foo=foo) // foo=foo is a workaround for a bug in glslify
-#pragma glslify: encodeFloatRGB = require(./utils/encode-float-rgb.glsl)
-#pragma glslify: decodeFloatRGB = require(./utils/decode-float-rgb.glsl)
-#pragma glslify: texture3dFrom2dNearest = require(./utils/texture3d-from-2d-nearest.glsl, intMod=intMod, intDiv=intDiv, foo=foo) // foo=foo is a workaround for a bug in glslify
-#pragma glslify: texture3dFrom2dLinear = require(./utils/texture3d-from-2d-linear.glsl, intMod=intMod, intDiv=intDiv, foo=foo) // foo=foo is a workaround for a bug in glslify
+#include read_from_texture
+#include texture3d_from_2d_nearest
+#include texture3d_from_2d_linear
 
 #if defined(dGridTexType_2d)
     vec4 textureVal(vec3 pos) {
@@ -151,10 +149,10 @@ vec4 raymarch(vec3 startLoc, vec3 step, vec3 viewDir) {
                     vec3 normal = normalize(gradient);
                     vec3 vViewPosition = normalize(viewDir);
                     vec4 material = vec4(color, uAlpha);
-                    #pragma glslify: import('./chunks/apply-light-color.glsl')
+                    #include apply_light_color
 
                     float vMarker = readFromTexture(tMarker, instance * float(uGroupCount) + group, uMarkerTexDim).a;
-                    #pragma glslify: import('./chunks/apply-marker-color.glsl')
+                    #include apply_marker_color
 
                     src.rgb = gl_FragColor.rgb;
                     src.a = gl_FragColor.a;

+ 1 - 5
src/mol-gl/shader/gaussian-density.frag

@@ -16,10 +16,7 @@ varying float vRadiusSqInv;
     varying float vGroup;
 #endif
 
-#pragma glslify: import('./chunks/common.glsl')
-// #pragma glslify: encodeFloatLog = require(./utils/encode-float-log.glsl)
-// #pragma glslify: decodeFloatLog = require(./utils/decode-float-log.glsl)
-#pragma glslify: encodeFloatRGB = require(./utils/encode-float-rgb.glsl)
+#include common
 
 uniform vec3 uGridDim;
 uniform vec2 uGridTexScale;
@@ -39,7 +36,6 @@ void main() {
         gl_FragColor.a = density;
     #elif defined(dCalcType_minDistance)
         gl_FragColor.a = 10000.0 - dist;
-        // gl_FragColor.a = 1.0 - encodeFloatLog(dist);
     #elif defined(dCalcType_groupId)
         float minDistance = 10000.0 - texture2D(tMinDistanceTex, (gl_FragCoord.xy) / (uGridTexDim.xy / uGridTexScale)).a;
         if (dist > minDistance + uResolution * 0.05)

+ 1 - 1
src/mol-gl/shader/histogram-pyramid/sum.frag

@@ -9,7 +9,7 @@ precision highp sampler2D;
 
 uniform sampler2D tTexture;
 
-#pragma glslify: encodeFloatRGB = require(../utils/encode-float-rgb.glsl)
+#include common
 
 void main(void) {
     gl_FragColor = vec4(encodeFloatRGB(texture2D(tTexture, vec2(0.5)).r), 1.0);

+ 6 - 5
src/mol-gl/shader/lines.frag

@@ -7,11 +7,12 @@
 precision highp float;
 precision highp int;
 
-#pragma glslify: import('./chunks/common-frag-params.glsl')
-#pragma glslify: import('./chunks/color-frag-params.glsl')
+#include common
+#include common_frag_params
+#include color_frag_params
 
 void main(){
-    #pragma glslify: import('./chunks/assign-material-color.glsl')
+    #include assign_material_color
 
     #if defined(dColorType_objectPicking) || defined(dColorType_instancePicking) || defined(dColorType_groupPicking)
         if (uAlpha < uPickingAlphaThreshold)
@@ -20,7 +21,7 @@ void main(){
     #else
         gl_FragColor = material;
 
-        #pragma glslify: import('./chunks/apply-marker-color.glsl')
-        #pragma glslify: import('./chunks/apply-fog.glsl')
+        #include apply_marker_color
+        #include apply_fog
     #endif
 }

+ 9 - 7
src/mol-gl/shader/lines.vert

@@ -9,9 +9,11 @@
 precision highp float;
 precision highp int;
 
-#pragma glslify: import('./chunks/common-vert-params.glsl')
-#pragma glslify: import('./chunks/color-vert-params.glsl')
-#pragma glslify: import('./chunks/size-vert-params.glsl')
+#include common
+#include read_from_texture
+#include common_vert_params
+#include color_vert_params
+#include size_vert_params
 
 uniform float uPixelRatio;
 uniform float uViewportHeight;
@@ -36,10 +38,10 @@ void trimSegment(const in vec4 start, inout vec4 end) {
 }
 
 void main(){
-    #pragma glslify: import('./chunks/assign-group.glsl')
-    #pragma glslify: import('./chunks/assign-color-varying.glsl')
-    #pragma glslify: import('./chunks/assign-marker-varying.glsl')
-    #pragma glslify: import('./chunks/assign-size.glsl')
+    #include assign_group
+    #include assign_color_varying
+    #include assign_marker_varying
+    #include assign_size
 
     mat4 modelView = uView * uModel * aTransform;
 

+ 1 - 2
src/mol-gl/shader/marching-cubes/isosurface.frag

@@ -20,8 +20,7 @@ uniform vec2 uScale;
 
 // varying vec2 vCoordinate;
 
-#pragma glslify: import('../chunks/common.glsl')
-#pragma glslify: decodeFloatRGB = require(../utils/decode-float-rgb.glsl)
+#include common
 
 // cube corners
 const vec3 c0 = vec3(0., 0., 0.);

+ 10 - 10
src/mol-gl/shader/mesh.frag

@@ -7,23 +7,23 @@
 precision highp float;
 precision highp int;
 
-#pragma glslify: import('./chunks/common-frag-params.glsl')
-#pragma glslify: import('./chunks/color-frag-params.glsl')
-#pragma glslify: import('./chunks/light-frag-params.glsl')
-#pragma glslify: import('./chunks/normal-frag-params.glsl')
+#include common
+#include common_frag_params
+#include color_frag_params
+#include light_frag_params
+#include normal_frag_params
 
 void main() {
-    // material color
-    #pragma glslify: import('./chunks/assign-material-color.glsl')
+    #include assign_material_color
 
     #if defined(dColorType_objectPicking) || defined(dColorType_instancePicking) || defined(dColorType_groupPicking)
         if (uAlpha < uPickingAlphaThreshold)
             discard; // ignore so the element below can be picked
         gl_FragColor = material;
     #else
-        #pragma glslify: import('./chunks/assign-normal.glsl')
-        #pragma glslify: import('./chunks/apply-light-color.glsl')
-        #pragma glslify: import('./chunks/apply-marker-color.glsl')
-        #pragma glslify: import('./chunks/apply-fog.glsl')
+        #include assign_normal
+        #include apply_light_color
+        #include apply_marker_color
+        #include apply_fog
     #endif
 }

+ 8 - 6
src/mol-gl/shader/mesh.vert

@@ -7,8 +7,10 @@
 precision highp float;
 precision highp int;
 
-#pragma glslify: import('./chunks/common-vert-params.glsl')
-#pragma glslify: import('./chunks/color-vert-params.glsl')
+#include common
+#include read_from_texture
+#include common_vert_params
+#include color_vert_params
 
 #ifdef dGeoTexture
     uniform vec2 uGeoTexDim;
@@ -30,10 +32,10 @@ attribute float aGroup;
 #endif
 
 void main(){
-    #pragma glslify: import('./chunks/assign-group.glsl')
-    #pragma glslify: import('./chunks/assign-color-varying.glsl')
-    #pragma glslify: import('./chunks/assign-marker-varying.glsl')
-    #pragma glslify: import('./chunks/assign-position.glsl')
+    #include assign_group
+    #include assign_color_varying
+    #include assign_marker_varying
+    #include assign_position
 
     #ifndef dFlatShaded
         #ifdef dGeoTexture

+ 6 - 5
src/mol-gl/shader/points.frag

@@ -7,8 +7,9 @@
 precision highp float;
 precision highp int;
 
-#pragma glslify: import('./chunks/common-frag-params.glsl')
-#pragma glslify: import('./chunks/color-frag-params.glsl')
+#include common
+#include common_frag_params
+#include color_frag_params
 
 #ifdef dPointFilledCircle
     uniform float uPointEdgeBleach;
@@ -18,7 +19,7 @@ const vec2 center = vec2(0.5);
 const float radius = 0.5;
 
 void main(){
-    #pragma glslify: import('./chunks/assign-material-color.glsl')
+    #include assign_material_color
 
     #if defined(dColorType_objectPicking) || defined(dColorType_instancePicking) || defined(dColorType_groupPicking)
         if (uAlpha < uPickingAlphaThreshold)
@@ -34,7 +35,7 @@ void main(){
             gl_FragColor.a *= alpha;
         #endif
 
-        #pragma glslify: import('./chunks/apply-marker-color.glsl')
-        #pragma glslify: import('./chunks/apply-fog.glsl')
+        #include apply_marker_color
+        #include apply_fog
     #endif
 }

+ 10 - 8
src/mol-gl/shader/points.vert

@@ -7,9 +7,11 @@
 precision highp float;
 precision highp int;
 
-#pragma glslify: import('./chunks/common-vert-params.glsl')
-#pragma glslify: import('./chunks/color-vert-params.glsl')
-#pragma glslify: import('./chunks/size-vert-params.glsl')
+#include common
+#include read_from_texture
+#include common_vert_params
+#include color_vert_params
+#include size_vert_params
 
 uniform float uPixelRatio;
 uniform float uViewportHeight;
@@ -20,11 +22,11 @@ attribute float aInstance;
 attribute float aGroup;
 
 void main(){
-    #pragma glslify: import('./chunks/assign-group.glsl')
-    #pragma glslify: import('./chunks/assign-color-varying.glsl')
-    #pragma glslify: import('./chunks/assign-marker-varying.glsl')
-    #pragma glslify: import('./chunks/assign-position.glsl')
-    #pragma glslify: import('./chunks/assign-size.glsl')
+    #include assign_group
+    #include assign_color_varying
+    #include assign_marker_varying
+    #include assign_position
+    #include assign_size
 
     #ifdef dPointSizeAttenuation
         gl_PointSize = size * uPixelRatio * ((uViewportHeight / 2.0) / -mvPosition.z) * 5.0;

+ 8 - 8
src/mol-gl/shader/spheres.frag

@@ -7,9 +7,10 @@
 precision highp float;
 precision highp int;
 
-#pragma glslify: import('./chunks/common-frag-params.glsl')
-#pragma glslify: import('./chunks/color-frag-params.glsl')
-#pragma glslify: import('./chunks/light-frag-params.glsl')
+#include common
+#include common_frag_params
+#include color_frag_params
+#include light_frag_params
 
 uniform mat4 uProjection;
 // uniform vec3 uInteriorColor;
@@ -117,8 +118,7 @@ void main(void){
     if (gl_FragDepthEXT > 1.0)
         discard;
 
-    // material color
-    #pragma glslify: import('./chunks/assign-material-color.glsl')
+    #include assign_material_color
 
     #if defined(dColorType_objectPicking) || defined(dColorType_instancePicking) || defined(dColorType_groupPicking)
         if (uAlpha < uPickingAlphaThreshold)
@@ -127,7 +127,7 @@ void main(void){
     #else
         vec3 normal = cameraNormal;
         vec3 vViewPosition = -cameraPos;
-        #pragma glslify: import('./chunks/apply-light-color.glsl')
+        #include apply_light_color
 
         if(interior){
             #ifdef USE_INTERIOR_COLOR
@@ -136,7 +136,7 @@ void main(void){
             gl_FragColor.rgb *= 1.0 - uInteriorDarkening;
         }
 
-        #pragma glslify: import('./chunks/apply-marker-color.glsl')
-        #pragma glslify: import('./chunks/apply-fog.glsl')
+        #include apply_marker_color
+        #include apply_fog
     #endif
 }

+ 10 - 8
src/mol-gl/shader/spheres.vert

@@ -7,9 +7,11 @@
 precision highp float;
 precision highp int;
 
-#pragma glslify: import('./chunks/common-vert-params.glsl')
-#pragma glslify: import('./chunks/color-vert-params.glsl')
-#pragma glslify: import('./chunks/size-vert-params.glsl')
+#include common
+#include read_from_texture
+#include common_vert_params
+#include color_vert_params
+#include size_vert_params
 
 uniform mat4 uModelView;
 uniform mat4 uInvProjection;
@@ -25,7 +27,7 @@ varying float vRadiusSq;
 varying vec3 vPoint;
 varying vec3 vPointViewPosition;
 
-#pragma glslify: matrixScale = require(./utils/matrix-scale.glsl)
+#include matrix_scale
 
 const mat4 D = mat4(
     1.0, 0.0, 0.0, 0.0,
@@ -71,10 +73,10 @@ void quadraticProjection(const in float radius, const in vec3 position){
 
 
 void main(void){
-    #pragma glslify: import('./chunks/assign-group.glsl')
-    #pragma glslify: import('./chunks/assign-color-varying.glsl')
-    #pragma glslify: import('./chunks/assign-marker-varying.glsl')
-    #pragma glslify: import('./chunks/assign-size.glsl')
+    #include assign_group
+    #include assign_color_varying
+    #include assign_marker_varying
+    #include assign_size
 
     vRadius = size * matrixScale(uModelView);
 

+ 6 - 5
src/mol-gl/shader/text.frag

@@ -7,8 +7,9 @@
 precision highp float;
 precision highp int;
 
-#pragma glslify: import('./chunks/common-frag-params.glsl')
-#pragma glslify: import('./chunks/color-frag-params.glsl')
+#include common
+#include common_frag_params
+#include color_frag_params
 
 uniform sampler2D tFont;
 
@@ -27,7 +28,7 @@ void main2(){
 }
 
 void main(){
-    #pragma glslify: import('./chunks/assign-material-color.glsl')
+    #include assign_material_color
 
     if (vTexCoord.x > 1.0) {
         gl_FragColor = vec4(uBackgroundColor, uBackgroundOpacity);
@@ -58,7 +59,7 @@ void main(){
         if (uAlpha < uPickingAlphaThreshold)
             discard; // ignore so the element below can be picked
     #else
-        #pragma glslify: import('./chunks/apply-marker-color.glsl')
-        #pragma glslify: import('./chunks/apply-fog.glsl')
+        #include apply_marker_color
+        #include apply_fog
     #endif
 }

+ 10 - 8
src/mol-gl/shader/text.vert

@@ -7,9 +7,11 @@
 precision highp float;
 precision highp int;
 
-#pragma glslify: import('./chunks/common-vert-params.glsl')
-#pragma glslify: import('./chunks/color-vert-params.glsl')
-#pragma glslify: import('./chunks/size-vert-params.glsl')
+#include common
+#include read_from_texture
+#include common_vert_params
+#include color_vert_params
+#include size_vert_params
 
 uniform mat4 uModelView;
 
@@ -31,13 +33,13 @@ uniform float uViewportHeight;
 
 varying vec2 vTexCoord;
 
-#pragma glslify: matrixScale = require(./utils/matrix-scale.glsl)
+#include matrix_scale
 
 void main(void){
-    #pragma glslify: import('./chunks/assign-group.glsl')
-    #pragma glslify: import('./chunks/assign-color-varying.glsl')
-    #pragma glslify: import('./chunks/assign-marker-varying.glsl')
-    #pragma glslify: import('./chunks/assign-size.glsl')
+    #include assign_group
+    #include assign_color_varying
+    #include assign_marker_varying
+    #include assign_size
 
     vTexCoord = aTexCoord;
 

+ 0 - 11
src/mol-gl/shader/utils/decode-float-log.glsl

@@ -1,11 +0,0 @@
-/**
- * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
- *
- * @author Alexander Rose <alexander.rose@weirdbyte.de>
- */
-
-const float maxFloat = 10000.0; // NOTE constant also set in in encodeFloatLog and in TypeScript
-const float floatLogFactor = log(maxFloat + 1.0);
-float decodeFloatLog(in float value) { return exp(value * floatLogFactor) - 1.0; }
-
-#pragma glslify: export(decodeFloatLog)

+ 0 - 11
src/mol-gl/shader/utils/decode-float-rgb.glsl

@@ -1,11 +0,0 @@
-/**
- * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
- *
- * @author Alexander Rose <alexander.rose@weirdbyte.de>
- */
-
-float decodeFloatRGB(const in vec3 rgb) {
-    return (rgb.r * 256.0 * 256.0 * 255.0 + rgb.g * 256.0 * 255.0 + rgb.b * 255.0) - 1.0;
-}
-
-#pragma glslify: export(decodeFloatRGB)

+ 0 - 11
src/mol-gl/shader/utils/encode-float-log.glsl

@@ -1,11 +0,0 @@
-/**
- * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
- *
- * @author Alexander Rose <alexander.rose@weirdbyte.de>
- */
-
-const float maxFloat = 10000.0; // NOTE constant also set in in decodeFloatLog and in TypeScript
-const float floatLogFactor = log(maxFloat + 1.0);
-float encodeFloatLog(in float value) { return log(value + 1.0) / floatLogFactor; }
-
-#pragma glslify: export(encodeFloatLog)

+ 0 - 18
src/mol-gl/shader/utils/encode-float-rgb.glsl

@@ -1,18 +0,0 @@
-/**
- * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
- *
- * @author Alexander Rose <alexander.rose@weirdbyte.de>
- */
-
-vec3 encodeFloatRGB(in float value) {
-    value = clamp(value, 0.0, 16777216.0 - 1.0) + 1.0;
-    vec3 c = vec3(0.0);
-    c.b = mod(value, 256.0);
-    value = floor(value / 256.0);
-    c.g = mod(value, 256.0);
-    value = floor(value / 256.0);
-    c.r = mod(value, 256.0);
-    return c / 255.0;
-}
-
-#pragma glslify: export(encodeFloatRGB)

+ 0 - 5
webpack.config.js

@@ -12,11 +12,6 @@ const sharedConfig = {
                 test: /\.(glsl|frag|vert)$/,
                 include: [path.resolve(__dirname, 'build/src/')],
             },
-            {
-                loader: 'glslify-loader',
-                test: /\.(glsl|frag|vert)$/,
-                include: [path.resolve(__dirname, 'build/src/')]
-            },
 
             {
                 loader: 'file-loader',