mellinoe / ShaderGen

Proof-of-concept library for generating HLSL, GLSL, and Metal shader code from C#,
MIT License
497 stars 56 forks source link

Added missing builtin functions #83

Closed thargy closed 6 years ago

thargy commented 6 years ago

I had a few minutes so I added the remaining missing common built-in functions to ShaderBuiltins, they all turned out to be somewhat trivial, and the auto-generated tests made it incredibly quick to do!

I've left each function in their own commits, as I couldn't test on Metal, however, I did check the functions existed on Metal and were equivalent according to the spec. so there should be no problems and you should feel free to squash the commits once tested on Metal.

The added functions are Degrees, Radians, Exp2, RSqrt, Step and Sign.

mellinoe commented 6 years ago

Degrees and Radians don't seem to have direct Metal functions for them, so we'll have to add manual implementations, unless I'm missing them somewhere.

thargy commented 6 years ago

You can see the code in the ShaderBuiltins implementations, it’s pretty trivial (multiply/divide by a constant). I’ll implement in the morning if I get time. I won’t be able to test though, but should be easy enough.

mellinoe commented 6 years ago

Thanks for pushing the extra fix. Everything passes on my Mac now, so I'll go ahead and merge.