Comments (7)
Sketchfab's OSGjs does it this way https://github.com/cedricpinson/osgjs/blob/master/sources/osgShader/shaderLib.js
code:
import shader from 'osgShader/node/shader.glsl';
...
shaderSource: shader
webpack.config.js:
module: {
loaders: [{
test: /\.(frag|vert|glsl)$/,
loader: 'raw-loader'
}]
}
from threeify.
The problem with the glsl files is that our builder, tsconfig, doesn't package up glsl files. Thus I had to format them similarly to how Three.js currently does it. As a big string in a *.js file. It sucks because they are just a big string, thus no syntax highlighting, nor linting, nor auto-formatting (because it is not legal to reformat a JS string.)
I am not an expert on tsconfig-based building, but I know that webpack supports bundling of glsl files correctly. Thus it is likely best to switch back to webpack? I had initially gone with webpack, but @justinfagnani removed it: #1
from threeify.
GLSL is not an importable module type (yet, I've been working with standards to add CSS and HTML modules, GLSL might be another good target). I would probably recommend wrapping it into .js files with a build step - which doesn't have to be a bundler, it can be a per-file wrapping operation - or using a tagged template literal to hint to tools that they can highlight and format the glsl.
See this VS Code extension that highlights code in glsl``
tags: https://marketplace.visualstudio.com/items?itemName=boyswan.glsl-literal
from threeify.
I just had a look at BabylonJS, where the glsl files are on their own and imported as is. But their setup looks a bit more tricky and I don't understand it all. They are on webpack + file-loader. https://github.com/BabylonJS/Babylon.js/blob/master/materialsLibrary/src/fire/fireMaterial.ts#L20
from threeify.
I posted on twitter to get more input.... https://twitter.com/BenHouston3D/status/1269386322323607558
from threeify.
I think with the raw *.glsl files as they are right now, we could add a GLSL linter on them. It will likely not be able to follow the include structure, but at least it will catch the obvious errors.
from threeify.
I think most of this is now done.
from threeify.
Related Issues (20)
- Use a promise to allow for one to wait for the resolution of an async Image Decode HOT 1
- Enable decoding of ImageBitmap on background threads with a promise HOT 1
- Allow fetchImage to read a blob and use createImageBitmap rather than HTMLImageElement HOT 1
- MacOS Safari vs Ubuntu Chrome alpha compositing differences HOT 3
- Premultipled alpha blend state difference: None and Add
- Ensure that published npm module contained compiled JS files from TS.
- copy some of the cool formatting in this readme.
- Ensure that ContextLost extension is not initialized.
- Add a logging system with different levels to allow for easy tracing of behaviour.
- Replace linux-specific command line tools in hooks with node.js scripts HOT 1
- Switch from WebGL1 to WebGL2. HOT 1
- WebGL2 features to make use of HOT 1
- Speedup optimization: In scene cache compiler: write directly into UniformBuffer.
- Support loading glTFs via gltf-transform library. HOT 1
- Recreate a react-based demo site HOT 2
- Switch to a mono-repository structure HOT 1
- Add a "tsc --build" mode to shader-transpiler to allow it to watch multiple threeify.json locations at once.
- A reusable guassian blur pass. HOT 1
- When transparency query misses opaque objects, query IBL.
- NaNs are in the background mipmaps.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from threeify.