Comments (5)
Hi
Since I guess glslify is quite a common use-case and there wasn't really any other solution to clean interoperation with rollup-plugin-glslify, I went ahead and implemented basic support* for processing shader sources through glslify directly in this plugin.
If you set glslify: true
and install it to your dev dependencies with npm i -D glslify
you can give it a try.
Interested to hear how it goes!
* A possible future enhancement is meaningful glslangValidator/browser error messages referencing the right file glslify files and line numbers, like you already get via #include and this plugin alone. But that's a significant undertaking considering glslify itself won't emit #line directives.
from rollup-plugin-glsl-optimize.
I appreciate that! :) Thank you so much.
I'm having a bit of trouble getting it to work - currently I just run my code through rollup-plugin-glslify
with no additional parameters, and then my imports are more or less import VertexShader from './my-vert-shader.glsl'
.
However, replacing rollup-plugin-glslify
with rollup-plugin-glsl-optimize
followed by rollup-plugin-glsl
(as mentioned in the docs) results in the shaders still having the #pragma glslify
directives in there:
rollupGlslOptimize({
glslify: true
}),
rollupGlsl({
include: '**/*.glsl',
exclude: '**/*.js',
sourceMap: false
}),
Results in
// Snipped for brevity
var VERTEX = "... \n#pragma glslify: noise = require('glsl-noise/simplex/3d');\n...";
Any ideas on how to fix this? :)
As for the line directives I (personally) care much less about those as debugging shader syntax errors is more or less easy to deal with in this case. Just getting it to build right and optimize is the main goal :)
Thanks again, I really appreciate it!
from rollup-plugin-glsl-optimize.
That's strange - I added some tests in cab815c involving glsl-noise that confirm #pragma glslify is correctly processed. It's the example from the glslify readme - though I did wrap snoise3 in a vec3() due to the increased strictness of glslangValidator / GLSL ES 3.0 (but imo that's a good thing!)
You shouldn't need rollup-plugin-glsl
- could you try without it? Also confirm that you're definitely on v0.0.9 :)
from rollup-plugin-glsl-optimize.
Also another potential issue in your example is that my-vert-shader.glsl
will need to be my-vert-shader.vert.glsl
or the other options given in the shader stages table
This is because the Khronos binaries need to know the shader stage (though the error should be self explanatory)
from rollup-plugin-glsl-optimize.
Aha, okay - in the real project they were just called vert.glsl
and frag.glsl
- changing them to foo.vert.glsl
etc appears to be triggering SPIRV correctly. Previously there were no errors.
Also confirm that you're definitely on v0.0.9
Yep yep!
$ cat package.json | grep glsl-opt
"rollup-plugin-glsl-optimize": "0.0.9",
You shouldn't need
rollup-plugin-glsl
- could you try without it?
Yep you're right, works fine :)
All appears to be working now! I appreciate the help, this is great! Thank you so much :)
from rollup-plugin-glsl-optimize.
Related Issues (3)
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 rollup-plugin-glsl-optimize.