diff options
| author | Mica White <botahamec@outlook.com> | 2025-12-08 19:50:10 -0500 |
|---|---|---|
| committer | Mica White <botahamec@outlook.com> | 2025-12-08 19:50:10 -0500 |
| commit | 19d831c5b1d56070c193d0c8310272f34ad3160d (patch) | |
| tree | e3886c715fbd0f63930d4a43f964ea1e575785ba /shader.hlsl | |
| parent | ea5db5846bc700f0da912225ddcb4be372359044 (diff) | |
Diffstat (limited to 'shader.hlsl')
| -rw-r--r-- | shader.hlsl | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/shader.hlsl b/shader.hlsl new file mode 100644 index 0000000..00bed12 --- /dev/null +++ b/shader.hlsl @@ -0,0 +1,125 @@ +struct VertexInput { + float2 position : LOC0; + float2 curve_uv : LOC1; + float2 color_uv : LOC2; + float4 color1_ : LOC3; + float4 color2_ : LOC4; + float4 color3_ : LOC5; + float4 color4_ : LOC6; + float2 normal_uv : LOC7; + float3 normal1_ : LOC8; + float3 normal2_ : LOC9; + float3 normal3_ : LOC10; + float3 normal4_ : LOC11; +}; + +struct VertexOutput { + float4 position : SV_Position; + float2 curve_uv : LOC0; + float2 color_uv : LOC1; + float4 color1_ : LOC2; + float4 color2_ : LOC3; + float4 color3_ : LOC4; + float4 color4_ : LOC5; + float2 normal_uv : LOC6; + float3 normal1_ : LOC7; + float3 normal2_ : LOC8; + float3 normal3_ : LOC9; + float3 normal4_ : LOC10; +}; + +static const float SQRT_2_ = 0.70710677; + +struct VertexOutput_vs_main { + float2 curve_uv : LOC0; + float2 color_uv : LOC1; + float4 color1_ : LOC2; + float4 color2_ : LOC3; + float4 color3_ : LOC4; + float4 color4_ : LOC5; + float2 normal_uv : LOC6; + float3 normal1_ : LOC7; + float3 normal2_ : LOC8; + float3 normal3_ : LOC9; + float3 normal4_ : LOC10; + float4 position : SV_Position; +}; + +struct FragmentInput_fs_main { + float2 curve_uv_1 : LOC0; + float2 color_uv_1 : LOC1; + float4 color1_1 : LOC2; + float4 color2_1 : LOC3; + float4 color3_1 : LOC4; + float4 color4_1 : LOC5; + float2 normal_uv_1 : LOC6; + float3 normal1_1 : LOC7; + float3 normal2_1 : LOC8; + float3 normal3_1 : LOC9; + float3 normal4_1 : LOC10; + float4 position_1 : SV_Position; +}; + +float square(float in_) +{ + return (in_ * in_); +} + +float cube(float in_1) +{ + return ((in_1 * in_1) * in_1); +} + +float3 lerp_(float3 a, float3 b, float t) +{ + return (((b - a) * t) + a); +} + +float3 oklab_to_linear_srgb(float3 color) +{ + const float _e10 = cube(((color.x + (0.39633778 * color.y)) + (0.21580376 * color.z))); + const float _e20 = cube(((color.x - (0.105561346 * color.y)) - (0.06385417 * color.z))); + const float _e30 = cube(((color.x - (0.08948418 * color.y)) - (1.2914855 * color.z))); + return float3((((4.0767417 * _e10) - (3.3077116 * _e20)) + (0.23096994 * _e30)), (((-1.268438 * _e10) + (2.6097574 * _e20)) - (0.34131938 * _e30)), (((-0.0041960864 * _e10) - (0.7034186 * _e20)) + (1.7076147 * _e30))); +} + +VertexOutput_vs_main vs_main(VertexInput vertex) +{ + VertexOutput out_ = (VertexOutput)0; + + out_.position = float4(vertex.position, 1.0, 1.0); + out_.curve_uv = vertex.curve_uv; + out_.color_uv = vertex.color_uv; + out_.color1_ = vertex.color1_; + out_.color2_ = vertex.color2_; + out_.color3_ = vertex.color3_; + out_.color4_ = vertex.color4_; + out_.normal_uv = vertex.normal_uv; + out_.normal1_ = vertex.normal1_; + out_.normal2_ = vertex.normal2_; + out_.normal3_ = vertex.normal3_; + out_.normal4_ = vertex.normal4_; + VertexOutput _e29 = out_; + const VertexOutput vertexoutput = _e29; + const VertexOutput_vs_main vertexoutput_1 = { vertexoutput.curve_uv, vertexoutput.color_uv, vertexoutput.color1_, vertexoutput.color2_, vertexoutput.color3_, vertexoutput.color4_, vertexoutput.normal_uv, vertexoutput.normal1_, vertexoutput.normal2_, vertexoutput.normal3_, vertexoutput.normal4_, vertexoutput.position }; + return vertexoutput_1; +} + +float4 fs_main(FragmentInput_fs_main fragmentinput_fs_main) : SV_Target0 +{ + VertexOutput vertex_1 = { fragmentinput_fs_main.position_1, fragmentinput_fs_main.curve_uv_1, fragmentinput_fs_main.color_uv_1, fragmentinput_fs_main.color1_1, fragmentinput_fs_main.color2_1, fragmentinput_fs_main.color3_1, fragmentinput_fs_main.color4_1, fragmentinput_fs_main.normal_uv_1, fragmentinput_fs_main.normal1_1, fragmentinput_fs_main.normal2_1, fragmentinput_fs_main.normal3_1, fragmentinput_fs_main.normal4_1 }; + float radius = length(vertex_1.curve_uv); + float _e3 = ddx_fine(radius); + float _e4 = ddy_fine(radius); + float afwidth = (length(float2(_e3, _e4)) * SQRT_2_); + float in_circle = (1.0 - smoothstep((1.0 - afwidth), (1.0 + afwidth), radius)); + const float3 _e22 = lerp_(vertex_1.color1_.xyz, vertex_1.color2_.xyz, length(vertex_1.color_uv)); + const float3 _e23 = oklab_to_linear_srgb(_e22); + const float3 _e32 = lerp_(vertex_1.color3_.xyz, vertex_1.color4_.xyz, (1.0 - length(vertex_1.color_uv))); + const float3 _e33 = oklab_to_linear_srgb(_e32); + const float3 _e34 = lerp_(_e33, _e23, in_circle); + const float3 _e39 = lerp_(vertex_1.normal1_, vertex_1.normal2_, length(vertex_1.normal_uv)); + const float3 _e46 = lerp_(vertex_1.normal3_, vertex_1.normal4_, (1.0 - length(vertex_1.normal_uv))); + const float3 _e47 = lerp_(_e46, _e39, in_circle); + return float4(_e34, in_circle); +} |
