Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 27 Jul 2013
Offline Last Active Feb 15 2014 09:36 AM

Topics I've Started

particles and depth testing

06 January 2014 - 10:55 AM

First question:


My particle systems currently supports a few blend modes. For example: Additive, multiplicative or alpha blending.


Everything works fine so far, yet I am struggling with the actual understanding.


Lets take additive blending as an example and assume we are drawing two particles. Either Particle 1 (P1) or Particle 2 (P2) is drawn first. Which leads to one of the images shown below:




On the right side is how it should look. The left side is how it shouldn't. The problem here is even though I use additive blending, which is for itself order independent, the output merger does some depth testing magic which results in the image shown on the left. The area T overlaps P2 and all fragments of P2 being removed (or never drawn). 


My question is why or how the output merger exactly performs that depth test. And how that error on the left side of the image can occur. I mean it is clear that it is the drawing order that causes the problem but how the rasterizer does the depth test per fragment is a mystery. 


I also know that if I disable depth write for my particles everything works fine since no fragments getting rejected.



Second question:


So far I have disabled depth writing for all blend modes but alpha blending. Since they are order independent blend modes. But now I am wondering if I even need depth writing for alpha blending. In fact I wonder if I ever need depth writing for any blend mode? Maybe it has some performance advantages?

Compute Shader: ThreadGroupSize and Performance

21 December 2013 - 05:44 PM

Hi Guys,


I have a few questions regarding ThreadGroupSize and performance.


1. No matter how many threads are in one thread group, it will always be executed by one SIMD / SMX (split in wavefronts / warps)? So lets say if I only need 1024 threads to process something and I start this in one group only, I have wasted performance since I could split it in smaller parts and have multiple SIMDs / SMXs working on it?


2. In case the above assumption is correct: If I dispatch only one thread group, will the other SIMD / SMX are blocked? Or do they work on other stuff like pixel processing, vector operations etc.? In other words... do all of them have to work on the same stuff or will the mix different things to keep them occupied?


3. Someone was writing this: 


Maintaining performance and correctness across devices becomes harder:
- Code hardwired to 32 threads per warp when run on AMD hardware 64 threads will waste execution resources
- Code hardwired to 64 threads per warp when run on Nvidia hardware can lead to races and affects the local memory budget



The first Statement makes perfectly sense. But the second... well I don't get it. Local memory is the main memory on the graphics card I guess not the thread shared memory? And could anyone explain what exactly happens that these races occur?


Thanks already!


Billboard WVP + rotation problem

26 October 2013 - 12:10 PM

I have particles which are processed to a billboard in the geometry shader.


These particles emit from a source point. This source point is attached to a placement. One can position, rotate and scale this placement.



What I would like to have is, that if I rotate the placement (which rotates the emitter) the emission direction is also rotated. So i.e. if my particles follow the y-axsis and I rotate it by 90° it would then follow the x-axis. Sounds more complicated than it is. Check these images to imagine it:




Basicly I am getting the WVP matrix from that placement(emitter). So all I need to do is project my particle with that matrix.


Here is what I tried:


float3 g_positions[4] =
        float3( fHalfBillboardSizeX, fHalfBillboardSizeY, 0 ),
        float3( -fHalfBillboardSizeX, fHalfBillboardSizeY, 0 ),
        float3( fHalfBillboardSizeX, -fHalfBillboardSizeY, 0 ),
        float3( -fHalfBillboardSizeX, -fHalfBillboardSizeY, 0 ),

// for all 4 billboard edge points (g_positions[4] )  do:

float3 position =  g_positions[i];
float3 vInputPos = input[0].position; // that is the center point of the billboard. the actual particle position.
output.position = float4(vInputPos, 1.0);
output.position = mul(output.position, World);
output.position = mul(float4(position, 1.0f), (float4x4)ViewInv ) + output.position;
output.position = mul(output.position, View);
output.position = mul(output.position, Projection);

This does nearly work. It's just that my depth buffer seems to be broken with this. I see my particles through other objects for example. Any ideas why that is and how I could fix it?


Random point on and in a conical frustum

25 October 2013 - 10:49 AM

Hey guys,


I am looking for two formulas to pick evenly distributed random points ON and IN a conical frustum. (I mean the first formula should find a random point ON the frustum and the second formula should give me random points IN that frustum.)




I had no success with Google so far. Does anyone have any useful links or knowledge about this?



Blending black area invisible

20 October 2013 - 04:13 AM

I am currently stuck with a blending problem.


Basically I am having a lot of billboards each with an image and some black space around that image. All I want is to replace that black color with whatever is in the background so that it becomes invisible.


Original billboard image:






Expected result:



Yet I have tried everything I could imagine with my BlendStateDescription, DepthStencil and BlendFactor. Nothing bringt me to my expected result.


Without blending I get the following result: (As expected)




With :

blendStateDescription.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
blendStateDescription.RenderTarget[0].DestBlend = D3D11_BLEND_ONE;
blendStateDescription.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
blendStateDescription.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
blendStateDescription.RenderTarget[0].DestBlend = D3D11_BLEND_ONE;
blendStateDescription.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
I get:
As stated earlier I have tried a hundred other combinations. Nothing successful yet. 
Also I thought when I set my BlendFactor to {0.0f, 0.0f, 0.0f, 0.0f) it would handle the black color as my alpha channel. But it aparently does not. Actually nothing I do with SrcBlendAlpha, DestBlendAlpha and BlendOpAlpha has ANY effect.