Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actual~Helgon

Posted 12 December 2012 - 12:07 PM

UPS!!:

Title wrong - should be: Compute Normal of partial derivates

Hey, I've created a bezier surface and want to compute the normal of each vertex. To solve the problem I've read that I have to compute the cross product of the partial derivatesbut the partial derivates in this case are a float4 vector and the normal is a float3 vector. If i calculate just with the .xyz components i have a kinda leaking result, or?

This is my approach:

[domain("quad")]
DomainOut DS(
             PatchTess patchTess,
			 float2 uv : SV_DomainLocation,
			 const OutputPatch<HullOut, 16> bezPatch)
{

DomainOut dout;

float4 basisU = BernsteinBasis(uv.x);
float4 basisV = BernsteinBasis(uv.y);
float3 p  = CubicBezierSum(bezPatch, basisU, basisV);

dout.PosH = mul(float4(p, 1.0f), gWorldViewProj);
dout.PosW = mul(float4(p, 1.0f), gWorld).xyz;
float3 NormalL = cross(basisU.xyz, basisV.xyz);
dout.NormalW = mul(float4(NormalL, 1.0f), gWorldInvTranspose);
return dout;

}

Can u give me a hint how it's done correctly?

Thanks

#1~Helgon

Posted 12 December 2012 - 12:06 PM

Hey, I've created a bezier surface and want to compute the normal of each vertex. To solve the problem I've read that I have to compute the cross product of the partial derivatesbut the partial derivates in this case are a float4 vector and the normal is a float3 vector. If i calculate just with the .xyz components i have a kinda leaking result, or?

This is my approach:

[domain("quad")]
DomainOut DS(
             PatchTess patchTess,
			 float2 uv : SV_DomainLocation,
			 const OutputPatch<HullOut, 16> bezPatch)
{

DomainOut dout;

float4 basisU = BernsteinBasis(uv.x);
float4 basisV = BernsteinBasis(uv.y);
float3 p  = CubicBezierSum(bezPatch, basisU, basisV);

dout.PosH = mul(float4(p, 1.0f), gWorldViewProj);
dout.PosW = mul(float4(p, 1.0f), gWorld).xyz;
float3 NormalL = cross(basisU.xyz, basisV.xyz);
dout.NormalW = mul(float4(NormalL, 1.0f), gWorldInvTranspose);
return dout;

}

Can u give me a hint how it's done correctly?

Thanks

PARTNERS