Comments (5)
Hi @uctakeoff and thanks for using this plugin!
I'm not 100% sure I'm understanding your request though. Currently a custom compress
callback can be used at build time (it makes more sense in production environments, but it's totally valid in development as well) to save some space and it will output a compressed shader when importing it in a .js
file.
It is possible to add a custom decompress
callback, but I need your help to figure out a use case for this: I guess it won't make sense decompressing it before passing to JS 'cause it will mean - compress a shader and immediately after decompress it so it will have the original shape when importing into .js
file..?
Or the logic behind that is to allow using already compressed shaders before even parsing them via vite-plugin-glsl
so you can import them decompressed into JavaScript..?
Both options are possible, I just cannot quite understand the purpose of having such functionality.
If on the other hand, you want to call a custom decompress
function (originally passed as an option to this plugin) right from a .js
file, even though this also might be possible if I save it in some "static" method in order to expose it later, you will need to import this plugin at least twice: once in your vite.config
file and then again in a .js
file that will call this decompress
callback.
Honestly sounds weird to me 'cause I thought vite
plugins should be used only in a vite.config
file.
from vite-plugin-glsl.
Perhaps I have misunderstood the usage.
I thought glsl's compression feature was to reduce the package size after build. (This is what is called "minify".)
The smaller the package size, the better.
If this is the case, I thought that the compressed code does not necessarily have to be readable. You can use gzip if it is effective in compression.
Also, for some products, it makes sense to make the source code less readable.
It has the effect of making it difficult for others to reverse engineer the code. (Of course, it is not perfect.)
For such applications, I thought it would make sense to use a compression algorithm or encryption process in the glsl plugin's compression function.
When I thought of such a device, I thought it would be nice to have a decompression function.
Am I misinterpreting something?
from vite-plugin-glsl.
Yeah, I think we've misunderstood each other. 😅
I thought glsl's compression feature was to reduce the package size after build.
vite-plugin-glsl
's compression is actually a minifier which might use a default algorithm (with compress: true
) or a custom callback passed to the same compress
option. What it's aimed to do at the and of the day, is to strip away whitespaces from your shaders in order to reduce bundle size and load them a bit faster.
For such applications, I thought it would make sense to use a compression algorithm or encryption process in the glsl plugin's compression function.
Yeah, I agree, but I think at that point it would make more sense apply the same compression algorithm to the whole bundle and not only to your shaders. At the end of the day, those are just strings in your .js
files.
I've found these compression plugins that might do just what you need, but I'm not sure about decompression. Maybe that could be something to develop from scratch...
- https://github.com/vbenjs/vite-plugin-compression
- https://github.com/alloc/vite-plugin-compress
- https://github.com/nonzzz/vite-plugin-compression
Hope this helps, cheers!
from vite-plugin-glsl.
Unfortunately, the plug-ins you mentioned do not seem to have any obfuscation effect.
The general compress/minify algorithm does not allow modification of the string content without permission.
In short, I was hoping for the effect that the string would not look glsl at first glance.
It would have been nice to have decompress: boolean|((s: string) => string)
as well as the compress
option.
Thank you for your consideration.
from vite-plugin-glsl.
In short, I was hoping for the effect that the string would not look glsl at first glance.
Got it. Yeah, unfortunately that's out of scope of this plugin too.
No problem, thanks for using it. Please consider smashing a star button if you've found it any useful, thanks!
from vite-plugin-glsl.
Related Issues (20)
- Import other NPM packages i.e. glsl-noise HOT 3
- Watcher crashes when using the plugin with Astro HOT 7
- Typscript Support for Importing Shaders HOT 8
- Watch, hot reload, server restart on 1.1.0 HOT 8
- Failed to resolve entry for package "vite-plugin-glsl" in vanilla TypeScript project. HOT 3
- [Question] Unexpected identifier HOT 7
- can't 'go to definition' to source file HOT 8
- Unable to import glsl file properly HOT 5
- Error while importing shader HOT 1
- Seeking Help: Manual Refresh Required for GLSL Code Updates in Vite/React-Three-Fiber HOT 2
- 'include' : invalid directive name HOT 13
- Tips for making this work with GLSL Lint HOT 3
- how can i remove comments like // or /* */ HOT 3
- Add Bun Support HOT 2
- Compress erros on Three with chunks and imports HOT 3
- I facing an issue while using a package which uses .glsl files (sheryjs) HOT 3
- Does it support the react WGSL apps build with vite? HOT 1
- compact goes wrong with this code HOT 4
- HMR in vuejs working weirdly HOT 10
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 vite-plugin-glsl.