?? vertexlight4.cg
字號(hào):
//
// subroutine call example
//
// vertex shader with per-vertex diffuse lighting for a 4 directional
// lights + ambient
//
// written assuming that the lightcolor has been premultiplied by the
// diffuse coefficient and that the ambientcolor has been premultiplied
// by the ambient coefficient
struct appdata {
float4 position : ATTRIB0;
float3 normal : ATTRIB1;
float4 color : ATTRIB2;
};
struct vf20 {
float4 HPOS : POSITION;
float4 COL0 : COLOR0;
float4 TEX0 : TEXCOORD0;
};
float3 diffuse(float3 normal, float3 lightv, float3 color)
{
return max(dot(normal, lightv), 0) * color;
}
vf20 main(appdata I,
uniform float3x3 object_matrix,
uniform float4x4 objviewproj_matrix,
uniform float3 lightdir[4],
uniform float3 lightcolor[4],
uniform float3 ambientcolor)
{
vf20 O;
float3 norm;
// transform vertices into projection space using the pre-multiplied matrix
O.HPOS = mul(objviewproj_matrix, I.position);
norm = mul(object_matrix, I.normal); // transform normal to world space
O.COL0.rgb = I.color.rgb *
diffuse(norm, lightdir[0], lightcolor[0]) *
diffuse(norm, lightdir[1], lightcolor[1]) *
diffuse(norm, lightdir[2], lightcolor[2]) *
diffuse(norm, lightdir[3], lightcolor[3]) + ambientcolor;
O.COL0.a = I.color.a;
return O;
} // main
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -