toji / rosetta

Comparisons of shaders across multiple APIs
https://toji.github.io/rosetta/
Other
22 stars 0 forks source link

Thoughts of having a rendering framework that can sorta"proves" each shader compiles correctly have the expected result #1

Open shrekshao opened 1 year ago

shrekshao commented 1 year ago

Great to see you put this up so quickly!

From my past learning experience, I really prefer copying code from src with live working demo to just code snippets. As a beginner I feel lost when pasting a piece of code but getting compiled error (when not understanding the language)

So I thought it could be great if some render framework exists that actually uses these shaders and prove they can run.

Some immediate concerns:

But if I put aside these concerns and set my mind free for a while, I can think of using webgpu for wgsl, webgl for glsl, unity (webgl build) for hlsl (syntax). As mentioned above, having some shadertoy style shaders and rewrite them in wgsl, hlsl and have them working might be a good starting point. The different backend renderer can be in a different standalone page, and takes url of the shader snippet as an input, with some link in rosetta [try this shader live]().

toji commented 1 year ago

I agree that this would be very nice, and agree that it would be very hard to implement well. There's so much external data that needs to be fed into any shader, usually in a very specific way, that it would be difficult to create a generalized environment that can effectively demonstrate them. (Might actually be a bit easier for compute shaders?) Don't want to dismiss the idea outright, because it would still be cool, but it's difficult to see how we'd do it effectively.

Additionally, I'd like to allow the page to store shaders for non-web APIs as well, like HLSL and MSL, for comparisons' sake. Obviously we won't be able to run those.

Taking a step back, though, it would be feasible to at least have the WGSL and GLSL shaders run through the compile step of their respective APIs so that we can catch errors in the submitted shaders. That would be most useful as a presubmit step, which makes it trickier, but it's something to consider.