什么是应用亮度和对比度的简单像素着色器脚本效果?
我找到了这个,但它似乎不正确:
sampler2D input : register(s0);
float brightness : register(c0);
float contrast : register(c1);
float4 main(float2 uv : TEXCOORD) : COLOR
{
float4 color = tex2D(input, uv);
float4 result = color;
result = color + brightness;
result = result * (1.0+contrast)/1.0;
return result;
}
谢谢!
答案 0 :(得分:24)
这是你在找什么?
float Brightness : register(C0);
float Contrast : register(C1);
sampler2D Texture1Sampler : register(S0);
float4 main(float2 uv : TEXCOORD) : COLOR
{
float4 pixelColor = tex2D(Texture1Sampler, uv);
pixelColor.rgb /= pixelColor.a;
// Apply contrast.
pixelColor.rgb = ((pixelColor.rgb - 0.5f) * max(Contrast, 0)) + 0.5f;
// Apply brightness.
pixelColor.rgb += Brightness;
// Return final pixel color.
pixelColor.rgb *= pixelColor.a;
return pixelColor;
}
---使用Shazzam Shader Editor进行测试 http://shazzam-tool.com