В настоящее время я работаю над простым шейдером в hlsl. Я пытаюсь добиться эффекта «подсветки», когда курсор помещается на объект на моем экране. Моя проблема в том, что пиксельный шейдер работает неправильно:
На картинке №1 есть объект без применения каких-либо эффектов. На картинке №2 показан объект с эффектом.
Как видите, края больше не видны. Как улучшить мой пиксельный шейдер? Код пиксельного шейдера:
sampler cubeSampler : register (s0);
struct VertexShaderOutput
{
float4 Position : POSITION;
float2 UV : TEXCOORD;
};
float4 main(VertexShaderOutput vertex) : COLOR
{
float4 color = tex2D(cubeSampler, vertex.UV.xy);
float value = 0.3f * color.r + 0.59f * color.g + 0.11f * color.b; //Desaturated hue
float3 tint = float3(0.26f, 0.37f, 0.67f); //Filter color (R: 68, G: 95, B: 173)
float tintMix = 0.8f;
float OutputR = tintMix * value * tint.r + (1 - tintMix) * color.r;
float OutputG = tintMix * value * tint.g + (1 - tintMix) * color.g;
float OutputB = tintMix * value * tint.b + (1 - tintMix) * color.b;
return float4(OutputR, OutputG, OutputB, 255);
}