【发布时间】:2014-02-19 15:30:54
【问题描述】:
我的第一个问题是,_Object2World 矩阵是正交的吗?我的意思是,_Object2World 的反转置是否等于_Object2World 矩阵? :
_Object2World = Inverse Transpose (_Object2World ) //is orthogonal ?
因为我已经测试了最后两行的正常转换,我得到了相同的结果:
V2F vertexProgram(vertexInput input)
{
V2F output;
float4x4 modelMatrix = _Object2World;
float4x4 modelMatrixInverse = _World2Object;
float4x4 modelMatrixInverseTranspose = transpose(modelMatrixInverse);
output.viewDir = float3(mul(modelMatrix, input.vertex) -
float4(_WorldSpaceCameraPos, 1.0));
//output.normalDir = mul(_Object2World,float4(input.normal,0));
output.normalDir = mul(modelMatrixInverseTranspose,float4(input.normal,0));
}
最后一个问题,我想从着色器中获取一个值,所以我为着色器定义了一个统一属性,如下所示:
Properties{
_MyCustom ("Custome",Float)=0;
}
SubShader{
Pass{
V2F vertexProgram(APPINPUT input){
.
.
.
//I want to debug this Condition and watch it's result.//
if(Condition1==Condition2) _MyCustom=-1;
}
}
}
但下面的代码不会更新属性。如何查看条件是否满足?
【问题讨论】:
-
Condition11=Condition2 是一个赋值。
-
如果我把条件扔掉,也不工作
-
如果您有多个问题,请分别提出。这让只能回答一个问题的人更容易回答,也让以后更容易找到问题。
标签: unity3d glsl shader hlsl cg