Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


unbird

Member Since 04 Jan 2010
Offline Last Active Private

#5213063 Assimp transformation matrices

Posted by unbird on 26 February 2015 - 05:13 AM

The decomposition is possible, but it is possible only if you got uniform scaling. If you got non-uniform scaling you better "bake" the transformations on your editor side, or alternatively bake them during import (i.e. pretransform your vertices). This is for the scene hierarchy of course, since Assimp's animation keys have quaternions. Are you aiming for a quaternion based rendering system ?




#5212872 Appending to an append buffer several times

Posted by unbird on 25 February 2015 - 03:12 AM

Why not just try it ?

 

And yes, it works.




#5212863 Determining rotation angles for Rotation System B that produce the same resul...

Posted by unbird on 25 February 2015 - 01:49 AM

I think you`re after this:

Euler Angle Formulas. Looks like a complete list of all possible factorizations. Eberly/Geometric Tools has also other useful papers and code, so I suggest browsing around.


#5212751 Max size of Matrix4x4 Array in HLSL

Posted by unbird on 24 February 2015 - 12:47 PM

You got the raw view enabled in your SRV description, this is not allowed with structured buffers:

[4452] D3D11: ERROR: ID3D11Device::CreateShaderResourceView: When the D3D11_RESOURCE_MISC_BUFFER_STRUCTURED BindFlag is specified, the SRV Flag D3D11_BUFFEREX_SRV_FLAG_RAW cannot be specified. [ STATE_CREATION ERROR #127: CREATESHADERRESOURCEVIEW_INVALIDFORMAT ]
 
If you want to use raw views you need to use D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS at buffer creation (this is for ByteAddressBuffer in hlsl, by the way).

Edit: The latter also needs DXGI_FORMAT_R32_TYPELESS in the SRV description. I honestly repeatedly forget about what works and what doesn't. For that reason I wrote some convenience functions/classes which take care of that. I recommend to do the same wink.png


#5212654 Max size of Matrix4x4 Array in HLSL

Posted by unbird on 24 February 2015 - 03:29 AM

@ProgrammerDX: Use ID3DXEffect::SetRawValue or ID3DXBaseEffect::SetFloatArray. Also, vertex texture fetch (need to use tex2dlod, by the way) is a SM3 feature.

@Tispe: Use structured buffers:
StructuredBuffer<matrix> Matrices : register(t4);
No more need to tell the array size wink.png. I also recommend 4x3 matrices. According to the D3D11 resource limits this should give you 128M elements. Plenty.

Also, why this manual decode ?
uint Bone0 = Input.BoneIndices & 255;
uint Bone1 = (Input.BoneIndices >> 8) & 255;
uint Bone2 = (Input.BoneIndices >> 16) & 255;
uint Bone3 = (Input.BoneIndices >> 24) & 255;
Use DXGI_FORMAT_R8G8B8A8_UINT in your input layout. Your VS signature can then look this way directly:

struct VSInput
{
	...
	uint4 BoneIndices : BONEINDICES;
	...
};



#5211278 Problem with D3DXMatrixOrthoLH, graphic glitch.

Posted by unbird on 17 February 2015 - 03:25 PM

The reason is Bilinear Texture Filtering. Unless you have the above mentioned pixel perfect match (one pixel samples exactly one texel) one pixel is an weighted average of four texels (or even eight if you have mipmaps and trilinear filtering).

Even when using nearest point sampling it can happen you sample the "wrong" texel , meaning a pixel from a neighbour tile. The solution is this gap/extrusion of tiles (you now sample texels with the same color, so the average is this color again).

You're using ID3DXSprite, a convenience interface which simplifies things. The downside of this is that's not obvious what underlying mechanisms are going. Nonetheless ID3DXSprite doesn't do anything magic (it just uses bare D3D functionality) so they still apply.

Welcome to low-level graphics programming: Lots of things are new, complicated and veeeery often counterintuitive. But it's also very rewarding if you get the hang of hit (e.g. performance, which was the whole point of atlassing your tiles). Have fun wink.png


#5210965 Problem with D3DXMatrixOrthoLH, graphic glitch.

Posted by unbird on 16 February 2015 - 06:05 AM

The -0.5f fix works only for "pixel perfect" rendering. Your tiles "bleed" to neighbours. Like I said you need to grant them a gap border, e.g. instead of 8x8 tiles you make 10x10 tiles and offset the source rectangles accordingly.




#5210840 Graphics Programming book?

Posted by unbird on 15 February 2015 - 09:19 AM

A lot of the D3DX stuff can now be found in a bunch of libraries:

DirectX Tool Kit (Sprite batch, texture loading, text rendering, some standard shaders and states, etc. )
Effects

Even some of the mesh stuff has found its way to an open source library
 




#5210832 Can't fix shadow acne with bias

Posted by unbird on 15 February 2015 - 09:03 AM

You don't use the  normal-offset approach at shadow map creation but when sampling the shadowmap.




#5210809 Problem with D3DXMatrixOrthoLH, graphic glitch.

Posted by unbird on 15 February 2015 - 06:37 AM

I also suspect this: Directly Mapping Texels to Pixels (Direct3D 9).

As a quick fix, try using the following in DXDraw::drawSprite:
    D3DXVECTOR3 position(x-0.5f, y-0.5f, 0);

Though, as soon as you have (non-integral) scaling, smooth scrolling and/or linear sampling things get more tricky. You then need to grant your tiles a gap border (duplicating the pixels). The gap needs the get bigger the deeper your mipchain is.


#5210730 Weird behavior when getting data from structured buffer

Posted by unbird on 14 February 2015 - 02:04 PM

Yeah, something's off with your buffer. Also that SRV doesn't look right. For a structured buffer you use D3D11_SRV_DIMENSION_BUFFEREX (and the corresponding D3D11_BUFFEREX_SRV).

Your shader on the other hand works, even with a float id (mockup pixel shader dumping texcoords):

Attached Thumbnails

  • migiParticles.png



#5210722 Weird behavior when getting data from structured buffer

Posted by unbird on 14 February 2015 - 01:26 PM

Ok, for one: VSOut.id should be uint. You can also drop SV_Position. You only need it at the last stage before the rasterizer (either VS, DS or GS).

 

Looking further...

 

Edit: That buffer creation is weird. A default resource can't be CPU write accessible.




#5210718 Weird behavior when getting data from structured buffer

Posted by unbird on 14 February 2015 - 01:13 PM

Should be fine (and the debugger buffer inspection shows the data is correct).

 

I cannot make much sense of it, I suspect something silly like binding the buffer to a wrong stage/slot or something. Can you show the whole shader (VS, GS) and your complete setup (input layout, if any, buffer update and binding and the draw call), please.

 

As an aside: Though the debuggers have improved, I wouldn't always believe what they are telling. It helps to setup some readback functionality and check the values yourself. In this case - though it will involve some work - setting up a stream out geo shader and read back the data with a staging buffer.




#5210312 Clip (mask out) child by parent bounds.

Posted by unbird on 12 February 2015 - 11:28 AM

Yeah, arbitrary geometry is probably not sensibly possible in a single pass. Same for intersecting regions. But if you're mainly aiming for round rectangles, you got me thinking. Here some food for thought doing the mask procedurally (i.e. without a texture).

Take a look at this page from Iñigo Quilez: distance functions (also search for signed distance functions). There's a formula for a rounded box. Transforming this to 2D and applying some anti-alias magic you could do parametrized round rectangles in the pixel shader:
 
// round rectangle distance function, taken from Iñigo Quilez. Here in 2D
float udRoundBox( float2 p, float2 b, float r )
{
    return length(max(abs(p)-b,0.0))-r;
}

float4 RoundBoxPS(float2 p: TEXCOORD) : SV_Target
{
    // parameters in texture space (0..1)
    float2 rectCenter = float2(0.5, 0.5);
    float2 rectHalfSize = float2(0.4, 0.2);
    float radius = 0.07;
    
    // take distance function (negative, we want the inside of the rect).
    float dist = - udRoundBox(p - rectCenter, rectHalfSize, radius);    

    // estimate transition for antialiasing
    float transition = length(fwidth(p));

    float mask = saturate(dist / transition);
    return float4(mask.xxx, 1);
}
Not sure if this is useful (I just like to play with 2D shaders wink.png)

Attached Thumbnails

  • RoundRectangle.Png



#5210241 Clip (mask out) child by parent bounds.

Posted by unbird on 12 February 2015 - 04:49 AM

This was really just a mockup to show the principle (search for full screen triangle, there was also a recent thread about this here).

 

For a GUI/text you will use an atlas or texture array. Nothing hinders you to do the same for the mask. Then you provide tex-coords for both of these with your vertices already (TEXCOORD0 and TEXCOORD1 in your input layout).






PARTNERS