Bombfuse / emerald

A 2D rust game engine focused on portability.
MIT License
560 stars 16 forks source link

User Level Shaders #183

Open Bombfuse opened 2 years ago

Bombfuse commented 2 years ago

After discussion on the rust gamedev discord, it sounds like WGSL is the best user-facing shader language to use.

I think we should use naga as middleware to convert the users WGSL to Emerald's current shader langauge (GLSL).

ThatOneBro commented 2 years ago

From a pure design perspective I think WGSL is nice. It feels almost Rust-like, which is cool.

However I was hesitant to say whether WGSL would be the best choice or not, given many publicly available shaders have already been written in GLSL and HLSL and WGSL being so new... But considering the Rust gamedev community being pioneered by Bevy and their using WebGPU, I think WGSL may be a good choice, especially given the work naga has done to make sure there is a translation between the 3 and SPIR-V. WebGPU will (hopefully) be a powerful cross-platform standard soon, so if WebGPU ever becomes widely available, it should be less work for projects using emerald to upgrade to the theoretical wgpu version of emerald if we adopt WGSL now.

Overall I think WGSL is probably the way to go.

Bombfuse commented 2 years ago

Yah I agree, I think WGSL is the way to go as well. I need to start working on prototyping it for user level shaders. Also need to consider how shaders are used by the user.

Do we add a shader to a sprite? Do we let the user run a shader on the final screen texture? I think those 2 should be enough for most shader use cases

ThatOneBro commented 2 years ago

Yeah I think both of those cases should cover most things in 2D. I was thinking about a bunch of other stuff but it really only applies to 3D. I haven't done much complex shader work in 2D, so from my limited perspective those 2 things should be a good baseline.