为什么使用pixelshader之后alpha无效了?

corganhejijun 2011-11-16 11:19:58
没有贴图,只指定颜色的三角形都变成了黑色,贴图的透明度无效,求解

shader如下


/// <summary>The brightness offset.</summary>
/// <minValue>-1</minValue>
/// <maxValue>1</maxValue>
/// <defaultValue>0</defaultValue>
float Brightness : register(c1);

/// <summary>The contrast multiplier.</summary>
/// <minValue>0</minValue>
/// <maxValue>2</maxValue>
/// <defaultValue>1.5</defaultValue>
float Contrast : register(c2);

float top : register(c4);
float left : register(c5);
float bottom : register(c6);
float right : register(c7);

struct PS_INPUT
{
float4 Position : POSITION;
float2 Texture : TEXCOORD;
};

sampler2D Samp : register(S0);

float4 ApplyAdjustments(float4 color)
{
color.rgb /= color.a;

// Apply contrast.
color.rgb =((color.rgb - 0.5f) * max(Contrast, 0)) + 0.5f;

// Apply brightness.
color.rgb += Brightness;

// Return final pixel color.
color.rgb *= color.a;

return color;
}

//float4 main(float2 uv : TEXCOORD) : COLOR
float4 ps_main( in PS_INPUT In ) : COLOR0
{
float2 samplePoint;
samplePoint = In.Texture.xy;

float4 color = tex2D(Samp, samplePoint);

if (samplePoint.y < top)
{
return color;
}
if (samplePoint.x < left)
{
return color;
}
if (samplePoint.y > bottom)
{
return color;
}
if (samplePoint.x > right)
{
return color;
}

color = ApplyAdjustments(color);

return color;
}
...全文
102 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
corganhejijun 2011-11-16
  • 打赏
  • 举报
回复
搞定,原来是再次绘制的时候shader忘记设为NULL了。
result = m_pd3dDevice->SetPixelShader(NULL);

8,303

社区成员

发帖
与我相关
我的任务
社区描述
游戏开发相关内容讨论专区
社区管理员
  • 游戏开发
  • 呆呆敲代码的小Y
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧