|
本人菜鸟,最近试着在max中写一个shadowmap的shader。知道基本原理,将一个灯光作为摄像机先对场景渲染深度缓存,然后再正常渲染,然后比较深度值。可是在试着写的时候实在不知道该怎么下手,我试着根据SAS文档中的描述将view矩阵与灯光绑定,可是不行,有知道的朋友能否帮忙提示一下吧:
string ParamID = "0x0001";//使用SAS进行编译
float4 lightpos : POSITION
<
string UIName = "Lightpos";
string Object = " ointLight";
string Space = "World";
int refID = 1;
>;
float4x4 w : world;
float4x4 v : View<string Object = "PointLight";>;//这里试着将灯光与view矩阵绑定,不成功
float4x4 p : projection;
struct a2v
{
float4 pos : POSITION;
};
struct v2f
{
float4 pos : POSITION;
};
v2f vs(a2v In)
{
v2f Out = (v2f)0;
Out.pos=mul(In.pos,w);
Out.pos=mul(Out.pos,v);
Out.pos=mul(Out.pos,p);
return Out;
}
float4 ps(v2f In) : COLOR
{
return float4 (0.8,0.5,0.5,1);//随便给个颜色值
}
technique test
{
pass one
{
vertexshader = compile vs_2_0 vs();
pixelshader = compile ps_2_0 ps();
}
} |
|