diff --git a/src/d3/shaders/fragmentShaderCombineTextures.js b/shaders/fragmentShaderCombineTextures.glsl similarity index 96% rename from src/d3/shaders/fragmentShaderCombineTextures.js rename to shaders/fragmentShaderCombineTextures.glsl index 8e18b5e..6bded1a 100644 --- a/src/d3/shaders/fragmentShaderCombineTextures.js +++ b/shaders/fragmentShaderCombineTextures.glsl @@ -1,4 +1,3 @@ -export default ` uniform sampler2D tDiffuse; uniform sampler2D tNormal; uniform sampler2D tDepth; @@ -15,4 +14,3 @@ void main() { gl_FragColor = mix(max(colorDiffuse - colorDepth - colorNormal, 0.0), colorUI, colorUI.w); } -`; diff --git a/src/d3/shaders/fragmentShaderDepth.js b/shaders/fragmentShaderDepth.glsl similarity index 94% rename from src/d3/shaders/fragmentShaderDepth.js rename to shaders/fragmentShaderDepth.glsl index c70f668..4d2df5c 100644 --- a/src/d3/shaders/fragmentShaderDepth.js +++ b/shaders/fragmentShaderDepth.glsl @@ -1,4 +1,3 @@ -export default ` uniform float mNear; uniform float mFar; uniform float opacity; @@ -13,4 +12,3 @@ void main() { float color = 1.0 - smoothstep( mNear, mFar, depth ); gl_FragColor = vec4( vec3( color ), opacity ); } -`; diff --git a/src/d3/shaders/fragmentShaderSobel.js b/shaders/fragmentShaderSobel.glsl similarity index 98% rename from src/d3/shaders/fragmentShaderSobel.js rename to shaders/fragmentShaderSobel.glsl index ded9341..fadc444 100644 --- a/src/d3/shaders/fragmentShaderSobel.js +++ b/shaders/fragmentShaderSobel.glsl @@ -1,4 +1,3 @@ -export default ` uniform sampler2D tDiffuse; uniform float threshold; uniform vec2 aspect; @@ -25,4 +24,3 @@ void main() { gl_FragColor = (length(sobel) > threshold) ? vec4(vec3(1.0), 0.0) : vec4(0.0); } -`; diff --git a/src/d3/shaders/fragmentShaderSobelDepth.js b/shaders/fragmentShaderSobelDepth.glsl similarity index 97% rename from src/d3/shaders/fragmentShaderSobelDepth.js rename to shaders/fragmentShaderSobelDepth.glsl index 76520ba..6853ab0 100644 --- a/src/d3/shaders/fragmentShaderSobelDepth.js +++ b/shaders/fragmentShaderSobelDepth.glsl @@ -1,4 +1,3 @@ -export default ` // edge detection based on http://williamchyr.com/tag/unity/page/2/ uniform sampler2D tDiffuse; uniform float threshold; @@ -20,4 +19,3 @@ void main() { gl_FragColor = difference > threshold ? vec4(vec3(1.0), 0.0) : vec4(0.0); } -`; diff --git a/src/d3/shaders/fragmentShaderSobelNormal.js b/shaders/fragmentShaderSobelNormal.glsl similarity index 96% rename from src/d3/shaders/fragmentShaderSobelNormal.js rename to shaders/fragmentShaderSobelNormal.glsl index 4a07304..4fdeaf1 100644 --- a/src/d3/shaders/fragmentShaderSobelNormal.js +++ b/shaders/fragmentShaderSobelNormal.glsl @@ -1,4 +1,3 @@ -export default ` // edge detection based on http://williamchyr.com/tag/unity/page/2/ uniform sampler2D tDiffuse; uniform float threshold; @@ -19,4 +18,3 @@ void main() { gl_FragColor = difference > threshold ? vec4(vec3(1.0), 0.0) : vec4(0.0); } -`; diff --git a/src/d3/shaders/vertexShaderDepth.js b/shaders/vertexShaderDepth.glsl similarity index 94% rename from src/d3/shaders/vertexShaderDepth.js rename to shaders/vertexShaderDepth.glsl index 0a3cd87..be87361 100644 --- a/src/d3/shaders/vertexShaderDepth.js +++ b/shaders/vertexShaderDepth.glsl @@ -1,4 +1,3 @@ -export default ` varying float vFragDepth; uniform float logDepthBufFC; @@ -13,4 +12,3 @@ void main() { // gl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC; vFragDepth = 1.0 + gl_Position.w; } -`; diff --git a/src/d3/shaders/vertexShaderPostprocessing.js b/shaders/vertexShaderPostprocessing.glsl similarity index 85% rename from src/d3/shaders/vertexShaderPostprocessing.js rename to shaders/vertexShaderPostprocessing.glsl index 1835020..6abb4ab 100644 --- a/src/d3/shaders/vertexShaderPostprocessing.js +++ b/shaders/vertexShaderPostprocessing.glsl @@ -1,8 +1,6 @@ -export default ` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); } -`; diff --git a/src/d3/ToonShaderRenderChain.js b/src/d3/ToonShaderRenderChain.js index 9a63903..e63a5c7 100644 --- a/src/d3/ToonShaderRenderChain.js +++ b/src/d3/ToonShaderRenderChain.js @@ -3,12 +3,12 @@ import 'three/examples/js/postprocessing/EffectComposer.js'; import 'three/examples/js/postprocessing/RenderPass.js'; import 'three/examples/js/postprocessing/ShaderPass.js'; import 'three/examples/js/shaders/CopyShader.js'; -import vertexShaderPostprocessing from './shaders/vertexShaderPostprocessing.js'; -import fragmentShaderSobelDepth from './shaders/fragmentShaderSobelDepth.js'; -import fragmentShaderSobelNormal from './shaders/fragmentShaderSobelNormal.js'; -import fragmentShaderCombineTextures from './shaders/fragmentShaderCombineTextures.js'; -import fragmentShaderDepth from './shaders/fragmentShaderDepth.js'; -import vertexShaderDepth from './shaders/vertexShaderDepth.js'; +import vertexShaderPostprocessing from '../../shaders/vertexShaderPostprocessing.glsl'; +import fragmentShaderSobelDepth from '../../shaders/fragmentShaderSobelDepth.glsl'; +import fragmentShaderSobelNormal from '../../shaders/fragmentShaderSobelNormal.glsl'; +import fragmentShaderCombineTextures from '../../shaders/fragmentShaderCombineTextures.glsl'; +import fragmentShaderDepth from '../../shaders/fragmentShaderDepth.glsl'; +import vertexShaderDepth from '../../shaders/vertexShaderDepth.glsl'; // Based on Doodle3D/Toon-Shader diff --git a/webpack.config.js b/webpack.config.js index 9eb2160..5b697b0 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -63,7 +63,7 @@ module.exports = { } } }, { - test: /\.svg$/, + test: /\.(svg|glsl)$/, use: { loader: 'raw-loader' }