|
|
我写了一个Effect,框架如下:
- //一种运动方式,返回一个偏移量
- float4 Move_1(float4 pos)
- {
- return float4(……略)
- }
- //另一种运动方式,返回一个偏移量
- float4 Move_2(float4 pos)
- {
- return float4(……略)
- }
- //vertex shader output structs
- struct VS_OUTPUT
- {
- float4 Pos : POSITION;
- float4 Diff : COLOR0;
- float2 Text : TEXCOORD0;
- };
- VS_OUTPUT VS(
- float4 InPos : POSITION,
- float3 InNormal : NORMAL,
- float2 InTexture : TEXCOORD0,
- uniform int part)
- {
- VS_OUTPUT Out = (VS_OUTPUT)0;
-
- float4 pos;
-
- //********
- //想根据part参数的不同应用不同的运动方式
- if( 0 == part )
- {
- pos = InPos + Move_1(InPos);
- }
- else if( 1 == part )
- {
- pos = InPos + Move_2(InPos);
- }
-
- //以下可以不看
- float4x4 matViewProj = mul(g_View, g_Projection);
- float4x4 matTransform= mul(g_Transformation, matViewProj);
- float4x4 matPos = mul(g_World, matTransform);
-
- Out.Pos = mul(pos, matPos);
- Out.Diff.xyz = g_Ambient;
- Out.Diff.z = 1.0f;
- Out.Text = InTexture;
-
- return Out;
- }
- technique Render_body
- {
- pass P0
- {
- VertexShader = compile vs_1_1 VS(0);
- }
- }
- technique Render_weiqi
- {
- pass P0
- {
- VertexShader = compile vs_1_1 VS(1);
- }
- }
复制代码
我的目的是调用Render_body是让body以Move_1方式运动,调用Render_weiqi让weiqi以另一种方式运动,可是现在的效果是都是以Move_1方式运动
不知道为什么,大侠帮我看看,我想可能与 uniform 有关吧 [em24] |
|