Last active
May 26, 2023 16:18
Windows Terminal 1.6pre ピクセルシェーダ+Rubyスクリプトでアニメーション
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Texture2D shaderTexture; | |
SamplerState samplerState; | |
cbuffer PixelShaderSettings { | |
float Time; | |
float Scale; | |
float2 Resolution; | |
float4 Background; | |
}; | |
float3 hsv2rgb(float3 hsv) | |
{ | |
// ref. https://gist.github.com/iUltimateLP/5129149bf82757b31542 | |
float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); | |
float3 p = abs(frac(hsv.xxx + K.xyz) * 6.0 - K.www); | |
return hsv.z * lerp(K.xxx, clamp(p - K.xxx, 0.0, 1.0), hsv.y); | |
} | |
float4 main(float4 pos : SV_POSITION, float2 tex : TEXCOORD) : SV_TARGET | |
{ | |
float4 t = shaderTexture.Sample(samplerState, float2(0.0, 0.0)); | |
float4 color = shaderTexture.Sample(samplerState, tex); | |
if (tex.x * Resolution.x % 20 < 1.0 || tex.y * Resolution.y % 20 < 1.0) | |
{ | |
color.xyz += hsv2rgb(float3(t.x * 8 + (tex.x + tex.y) / 4, 1.0, 0.6)); | |
} | |
return color; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
i = 0 | |
while true | |
print "\e[0;0H\e[48;2;#{i};#{i};#{i}m " | |
sleep 0.03 | |
i = (i + 1) & 0xff | |
end | |
rescue Interrupt | |
puts "\e[0m\e[2J" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment