smkplus / ShaderMan

Convert ShaderToy to Unity HLSL/CG
https://smkplus.github.io/ShaderMan.io
MIT License
1.42k stars 197 forks source link

Direct2D Support #27

Open WindowsNT opened 3 years ago

WindowsNT commented 3 years ago

I found the tool after I have already converted lots of shaders in HLSL. It seems interesting, it could be nice if you can add Direct2D pixel shader support.

Direct2D HLSL has a factor passed as uw in the coordinates main function so the coordinates passed to the main can be converted to [0,1].

In Turbo Play I use this set of wrappers:


float2 FindSpace(float2 MV)
{
    float2 LastSample = float2(0, 0) + float2(center.x*2,center.y * 2)* MV;
    return LastSample;
}

float2 GetNormalized(float2 UV,float2 MV)
{
    float2 s = FindSpace(MV);
    return UV / s;
}

float2 FromNormalized(float2 UV, float2 MV)
{
    float2 s = FindSpace(MV);
    return UV * s;
}

See more at https://docs.microsoft.com/en-us/windows/win32/direct2d/custom-effects