Comments (1)
Hey. Just letting you know, that I've had a go at doing this with const generics and it's working great for me but my implementation probably isn't ergonomic enough for general use.
Basically I added a const PARAMS: usize
everywhere and you set that to highest number of params you need for any of your sdf/fill combinations. I also added a ShaderParamUsage
argument which controls which params are sent to the sdf and which to the fill. It does what I need it to do but is a bit of a pain to use and it probably isn't optimal performance wise so I'm definitely not suggesting this be merged or that this approach is even the right one, just wanted to share in case this was useful to anyone.
Just some notes:
- I couldn't find a way to pass an array of f32 to the Vertex shader so I passed all the params individually. I'm not sure if this affects performance, but it does make passing an arbitrary subset of the params to each function much easier.
- I had to write some unsafe code (empty impls of
Pod
andZeroable
forShapeVertex
since the derive macros don't with with const generics). I think this is fine but I'm not 100% sure. - I actually would like a way to pass in
u32
params as well asf32
. I'm getting away with it by usingfrom_bits
on the rust side andbitcast<u32>
on the other but I have to be careful of NaNs and can't use the full range of possible values. It might actually be better to go the other way round and pass in everything as au32
. - I started passing in the position argument to the fill functions. It let me make some nice gradients
from bevy_smud.
Related Issues (9)
- Shader compilation errors on "fwidth" on wasm HOT 2
- Shaders that make use of `time.seconds_since_startup` don't work on wasm
- Upgrade to Bevy 0.8
- Allow supplying a dynamic number of positions HOT 1
- Gray borders around shapes HOT 1
- Add time uniform
- Error on entity despawn
- fix broken links in readme HOT 2
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 bevy_smud.