Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/TheNuSan/BonzomaticToShadertoy
Script to convert bonzomatic glsl fragment shaders to shadertoy
https://github.com/TheNuSan/BonzomaticToShadertoy
Last synced: 28 days ago
JSON representation
Script to convert bonzomatic glsl fragment shaders to shadertoy
- Host: GitHub
- URL: https://github.com/TheNuSan/BonzomaticToShadertoy
- Owner: TheNuSan
- Created: 2022-11-29T10:02:34.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-29T10:47:35.000Z (about 2 years ago)
- Last Synced: 2024-08-04T02:07:47.293Z (4 months ago)
- Language: Python
- Size: 2.19 MB
- Stars: 13
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-demoscene - Bonzomatic To Shadertoy - Python script to convert bonzomatic glsl fragment shaders to use them on shadertoy.com (Demomaking / Tools)
README
# Bonzomatic To Shadertoy
Python script to convert bonzomatic glsl fragment shaders to use them on shadertoy.com## Usage
- Place your shader.glsl file in the folder
- Execute BonzomaticToShadertoy.bat
- In a command line, you can also specify the name of the shader file: "BonzomaticToShadertoy.bat filename.glsl"
- Open the shader.webgl file that has been created in a text editor
- Copy-paste the code into a new shader on shadertoy.com## Limitations
- As Bonzomatic textures are not present in Shadertoy, the tool just give each a different channels and you have to assign textures in shadertoy yourself
- FFT textures are currently assigned to a different channel each
- Using previous frame texture will just be assigned to a texture channel, in Shadertoy you need to put your shader in "Buffer A" instead of Image so you can sample the previous frame
- float numbers are rounded to 4 digits, because otherwise the tool would output weird numbers like 0.199999998
- intermediary variables are often inserted before function calls
- if you use "half" as a variable name, it will cause issues## Todo
- Better FFT handling
- Option to generate a json for importing with "Shadertoy unofficial plugin"
- replace texNoise with a call to a perlin noise function
- maybe replacing python by an exe tool so it can be autonomous
- fixing weird float numbers inside glslangValidator/spirv-cross source code instead of afterward
- fixing intermediary variables inserted before function calls## How it works
- Use glslangValidator (github.com/KhronosGroup/glslang) to convert glsl to a spirv shader
- Use spriv-cross (github.com/KhronosGroup/SPIRV-Cross) to convert the spirv shader back to webgl-ready code
- Use python to replace part of the code to adapt the Bonzomatic shader to Shadertoy
- replace input variables (pixel coordinates, resolution, time, main function name)
- remove useless lines (texture definitions, version, highp)
- round floats to 4 digits (glslangValidator/spirv-cross generate weird numbers)
- assign textures to shadertoy channels