Jump to content

  • Log In with Google      Sign In   
  • Create Account

CppPerson

Member Since 17 Jul 2012
Offline Last Active Mar 09 2013 04:35 PM

Posts I've Made

In Topic: Writing to the Stencil Buffer

08 February 2013 - 06:08 AM

Thanks for the idea but this doesn't seem to work.

 

My first attempt was to use D3D11_BIND_DEPTH_STENCIL on the depth/stencil texture but this gives:

 


D3D11: ERROR: ID3D11Device::CreateTexture2D:
       The BindFlags D3D11_BIND_UNORDERED_ACCESS and D3D11_BIND_DEPTH_STENCIL can't both be specified.
       [ STATE_CREATION ERROR #99: CREATETEXTURE2D_INVALIDBINDFLAGS ]
 
D3D11: ERROR: ID3D11Device::CreateTexture2D:
       The format (0x2d, D24_UNORM_S8_UINT) cannot be bound as an UnorderedAccessView, or cast to a format that could be bound as an UnorderedAccessView.
       Therefore this format does not support D3D11_BIND_UNORDERED_ACCESS.
       [ STATE_CREATION ERROR #92: CREATETEXTURE2D_UNSUPPORTEDFORMAT ]

In the vein hope that the last message might have been inaccurate, I also tried creating a DXGI_FORMAT_X24_TYPELESS_G8_UINT texture to that I could at least Resolve to a D24S8:

 

 D3D11: ERROR: ID3D11Device::CreateTexture2D:
       The format (0x2f, X24_TYPELESS_G8_UINT) cannot be bound as an UnorderedAccessView, or cast to a format that could be bound as an UnorderedAccessView.
       Therefore this format does not support D3D11_BIND_UNORDERED_ACCESS. [ STATE_CREATION ERROR #92: CREATETEXTURE2D_UNSUPPORTEDFORMAT ]

 

So it looks like this is not possible! Which is really confusing, because I can do this on an 8 year old console, but not the latest, expensive gaming PC. sad.png

In Topic: [SOLVED] Dual Quaternion Skinning failing on blend

18 July 2012 - 04:32 AM

For anybody who might have similar problems in the future, this is where I started on the optimisations:

float4 MultiplyPure(float3 a, float4 b)
{
   // lhs is a pure quaternion, rhs is a quaternion, so a.w=0
   return float4(b.w * a + cross(a, b.xyz), -dot(a, b.xyz));
}
float3 MultiplyConjugate3(float4 a, float4 b)
{
   // perform conjugate on lhs before multiplying, discard result.w
   return a.w * b.xyz - b.w * a.xyz + cross(-a.xyz, b.xyz);
}
float3 DQTransformPoint(float4 Qr, float4 Qd, float3 pt)
{
   // Vector transform pt by rotation Qr (pvp')
   float3 p = MultiplyConjugate3(Qr, MultiplyPure(pt, Qr));
   // t = 2QdQr*
   float3 t = 2 * MultiplyConjugate3(Qr, Qd);
   return p + t;
}

which reduces to:

float3 DQTransformPoint(float4 Qr, float4 Qd, float3 pt)
{
   float3 p = pt + 2 * cross(-Qr.xyz, Qr.w * pt + cross(pt, Qr.xyz));
   float3 t = 2 * (Qr.w * Qd.xyz - Qd.w * Qr.xyz + cross(-Qr.xyz, Qd.xyz));
   return p + t;
}

This is a subtle re-arrangement of the source paper's results which could have been achieved through guesswork. It was more fun this way Posted Image

In Topic: [SOLVED] Dual Quaternion Skinning failing on blend

18 July 2012 - 03:57 AM

Oops! Typo: float4(p,1) should be float4(p,0)

In Topic: [SOLVED] Dual Quaternion Skinning failing on blend

18 July 2012 - 03:28 AM

So I've gone back to basics and reduced my input and output to un-optimised representations of the equations in this brilliant paper: http://wscg.zcu.cz/w...rt/A29-full.pdf (A beginner's guide to dual quaternions).

The DQ generation code is simply:

void iUQTtoUDQ(math::quat* dual, const math::quat& q, const math::vec3& p)
{
   // Qr = r
   dual[0] = q;
   // Qd = 0.5(0,t)r
   math::quat qp = { p.x, p.y, p.z, 0 };
   dual[1] = qScale(qMultiply(qp, q), 0.5f);
}


And the shader transform code is:

float3 Transform(float4 q, float3 p)
{
   return Multiply(Conjugate(q), Multiply(float4(p, 1), q)).xyz;
}
float3 DQTransformPoint(float4 Qr, float4 Qd, float3 pt)
{
   // r = Qr
   // t = 2QdQr*
   float3 p = Transform(Qr, pt);
   float4 t = 2 * Multiply(Qd, Conjugate(Qr));
   return p + t.xyz;
}


This produced the same artefacts. By swapping the Multiply parameters used to generate dual[1] and also for generating t everything is now working as expected. My multiplies concatenate right-to-left and hence didn't match any of the available source code out there for me to compare with. I guess that will teach me to test my stuff with a basic idle animation.

Now to optimise...

PARTNERS