⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thresholdshadertwochannel.fx

📁 游戏编程精粹6的光盘源代码
💻 FX
字号:
struct VertexOutput
{
	float4 position  : POSITION;
	float2 uv : TEXCOORD0;
};

struct PixelOutput
{
	float4 color : COLOR0;
};

texture myTexture
<
	string ResourceName = "noSmokingBlackAndRedChannel.dds";
>;

sampler mySampler = sampler_state 
{
    texture = <myTexture>;
    AddressU  = CLAMP;        
    AddressV  = CLAMP;
    MIPFILTER = LINEAR;
    MINFILTER = LINEAR;
    MAGFILTER = LINEAR;
};

PixelOutput ThresholdShader(VertexOutput IN)
{
	PixelOutput OUT;
	half4 t = tex2D(mySampler, IN.uv);
	float2 uvScaled = IN.uv*float2(64, 64); // width & height of texture
	float2 ef = ddx(uvScaled);
	float2 gh = ddy(uvScaled);
	half sInv = length(float4(ef, gh));
    half a = max(1.0, (3*1.4)/sInv);
	half4 c = clamp(0.5 + a*(t-0.5), 0.0, 1.0);
	OUT.color = half4(1.0-(1.0-c.r)*c.a, c.r*c.a, c.r*c.a, 1.0);
	return OUT;
}

technique threshold
{
	pass p0 
	{
		VertexShader = NULL;
		PixelShader = compile ps_2_a ThresholdShader();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -