emerald icon indicating copy to clipboard operation
emerald copied to clipboard

User Level Shaders

Open Bombfuse opened this issue 1 year ago • 3 comments

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).

Bombfuse avatar Aug 10 '22 17:08 Bombfuse

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.

ThatOneBro avatar Aug 13 '22 17:08 ThatOneBro

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

Bombfuse avatar Sep 11 '22 19:09 Bombfuse

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.

ThatOneBro avatar Sep 12 '22 19:09 ThatOneBro