ComputeSharp icon indicating copy to clipboard operation
ComputeSharp copied to clipboard

Support for GLSL-style operators

Open ahmed605 opened this issue 2 years ago • 1 comments

Adding support for GLSL-style operators such as * operator between matrices like float2x2 and vectors like float2 (which would work like that: float2x2 * float2 = new float2(float2x2.M11 * float2.X + float2x2.M12 * float2.Y, float2x2.M21 * float2.X + float2x2.M22 * float2.Y);) would make it easier to port GLSL shaders to ComputeSharp (HLSL)

ahmed605 avatar Nov 10 '21 08:11 ahmed605

Yeah, I had similar issues with Line 46 here https://www.shadertoy.com/view/7lc3R4 with *= as well:

vec2 tuv;
...
tuv *= Rot(radians((degree-.5)*720.+180.));

and changed it in ComputeSharp to:

float2 tuv;
...
tuv.XY = Hlsl.Mul(tuv.XY, Rotate(Hlsl.Radians((degree - 0.5f) * 720.0f + 180.0f)));

So it'd be nice to at least have it be able to do instead:

tuv.XY *= Rotate(Hlsl.Radians((degree - 0.5f) * 720.0f + 180.0f));

hawkerm avatar Nov 10 '21 09:11 hawkerm

Yeah I second this, would be nice to have it. Hlsl.Mul() can be used in place of *, but it's more natural to use *, especially when porting over shader code.

I suspect porting GLSL shaders to CS.D2D1 shaders for use in PDN v5 effects will be a thing once these things all go live. Having these operators will really simplify that.

rickbrew avatar Aug 28 '22 03:08 rickbrew

Alright, @rickbrew convinced me, here's a sneak-peek 😄

image

Sergio0694 avatar Aug 28 '22 17:08 Sergio0694