Skip to content

Instantly share code, notes, and snippets.

@youz
Last active May 26, 2023 16:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save youz/24f7d343ac30b3ffc6147f01e6e60642 to your computer and use it in GitHub Desktop.
Save youz/24f7d343ac30b3ffc6147f01e6e60642 to your computer and use it in GitHub Desktop.
shaders for Windows Terminal
Texture2D shaderTexture;
SamplerState samplerState;
cbuffer PixelShaderSettings {
float Time;
float Scale;
float2 Resolution;
float4 Background;
};
float4 main(float4 pos : SV_POSITION, float2 tex : TEXCOORD) : SV_TARGET
{
float4 color = shaderTexture.Sample(samplerState, tex);
if (tex.x * Resolution.x % 25 < 1.0 || tex.y * Resolution.y % 25 < 1.0)
{
color.xyz += float3(0.1, 0.2, 0.15);
}
return color;
}
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 color = shaderTexture.Sample(samplerState, tex);
// Timeは今の所0固定っぽい
// https://github.com/microsoft/terminal/blob/37cbcc3e2bf150cd6878690225f4c5b51704ccd8/src/renderer/dx/DxRenderer.cpp#L459
// float3 bgcolor = hsv2rgb(float3(Time % 1000 / 1000.0, 1.0, 1.0));
// 仕方がないのでウィンドウサイズを変えると色が変わるようにしてみる
float3 c = hsv2rgb(float3(Resolution.x * Resolution.y % 2000 / 2000.0, 1.0, 1.0));
color.xyz += c * 0.3;
return color;
}
Texture2D shaderTexture;
SamplerState samplerState;
cbuffer PixelShaderSettings {
float Time;
float Scale;
float2 Resolution;
float4 Background;
};
float4 main(float4 pos : SV_POSITION, float2 tex : TEXCOORD) : SV_TARGET
{
return shaderTexture.Sample(samplerState, float2(tex.x * 4 % 1.0, tex.y * 4 % 1.0));
}
@youz
Copy link
Author

youz commented Jan 29, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment