Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 08 Mar 2013
Offline Last Active Sep 04 2013 11:28 AM

Topics I've Started

HDR Bloom Question

03 September 2013 - 07:44 PM

I'm doing the good old "HDR Bloom like an old Atari vector monitor" effect, and have a couple of questions:


1) For my initial draw surface, I am using D3DFMT_A16B16G16R16 and want to make sure that's an appropriate choice.


2) I'd like to confirm that my intermediate textures (where you step down to half size and gaussian blur) do not need extra bits; or do they?  For the set of 4 or 5 bloom textures, what pixel format should I use for them?


3) And perhaps most important, how do you actually -draw- at "higher than 1.0" intensities?  Do you really return RGB color components > 1.0, or do the extra HDR bits only get used from combined blending and so forth?




Blending a texture onto the render target with StretchRect

30 August 2013 - 12:48 PM

I have a scene that I render to a texture (works fine).  I keep a copy of that texture, which I use to create a blur in the X and Y direction so now I have:


a) The original texture of the scene

b) A blurred copy of the scene on the device's default rendertarget


I now want to draw the original texture on top, giving it the "blur" around the original scene data.  When I do this, however, it just completely replaces everything; my blurred scene is wiped out and the original replaces it entirely, as if StretchRect can do no combining or blending.


I turn on Alpha blending and set the blending mode to Additive (also tried AlphaAdditive):

pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
BlendMode::Set(pd3dDevice, BlendMode::Additive);
pd3dDevice->StretchRect(ptrDrawSurface, NULL, ptrOriginalDeviceRenderTarget, NULL, D3DTEXF_POINT);

So what am I missing?  How do I get the original version of the scene to be placed on top of the blurred version of the scene without it just completely replacing it?





What on earth is wrong with this really basic rotation?

14 August 2013 - 06:09 PM

I have a nice little fireworks demo running, and I thought for the heck of it I'd spin the "ball of particles" that comprises the fireworks.  To do this, I assumed that the steps were:


- Translate back to origin from where it lives in space

- Apply rotation matrices for X, Y, Z

- Translate back to where object lived in space

- Set that as the World matrix before drawing the object (leaving projection and view completely alone)


It does not work as I would expect (or at all, really).  It just jumps around a bunch but largely stays put (no rotation).  I'm placing that new world matrix into the shader before drawing the instance.  I know all that works, as it draws them without rotation exactly as I'd hoped.  It's just my application of rotation that has broken everything...


Either I've got a really ugly bug or a very poor grasp of how to compose such a matrix.  A prod in either direction would be very much appreciated!

D3DXMATRIX matrixTranslateBefore;
D3DXMATRIX matrixRotationX;
D3DXMATRIX matrixRotationY;
D3DXMATRIX matrixRotationZ;
D3DXMATRIX matrixTranslateAfter;

float rads = fElapsedTime * 50.0f;

D3DXMatrixTranslation(&matrixTranslateBefore,  -pExplosion->_centerPosition.x, 
                      -pExplosion->_centerPosition.y, -pExplosion->_centerPosition.z);
D3DXMatrixRotationX(&matrixRotationX, rads);
D3DXMatrixRotationY(&matrixRotationY, rads);
D3DXMatrixRotationZ(&matrixRotationZ, rads);
D3DXMatrixTranslation(&matrixTranslateAfter, pExplosion->_centerPosition.x,
pExplosion->_centerPosition.y, pExplosion->_centerPosition.z);

pCameraManager->_worldMatrix = matrixTranslateBefore * matrixRotationX * matrixRotationY * matrixRotationZ * matrixTranslateAfter; 


SetFloat, SetVector, SetMatrix have no effect

12 August 2013 - 12:35 PM

I'm having trouble setting shader variables, as in I'm unable to.  In the FX file, I have:


//cbuffer ExplosionData : register(b0) // BUGBUG consistent casing
float    secondsLifetime;
float    secondsRemaining;
float    explosionSpeed;
   float4x4 worldViewProjection;
   Texture  particleTexture;
float3   startPosition;


I get the D3DXHANDLEs to them by name, and they come back with valid handles.  As you can see I originally had them in a cbuffer but moved them out just to see if it made a difference, which it did not.  This is all vs3_0 and ps3_0 stuff.


_hSecondsLiftime       = _ptrEffect->GetParameterByName(0, "secondsLifetime");
_hSecondsRemaining     = _ptrEffect->GetParameterByName(0, "secondsRemaining");
_hExplosionSpeed       = _ptrEffect->GetParameterByName(0, "explosionSpeed");
_hWorldViewProjection  = _ptrEffect->GetParameterByName(0, "worldViewProjection");
_hParticleTexture      = _ptrEffect->GetParameterByName(0, "particleTexture");
_hStartPosition        = _ptrEffect->GetParameterByName(0, "startPosition");
In my render code I do BeginScene, SetTechnique, abd BeginPass.  Then I SetVertexDeclaration, SetVertexShader, SetPixel shader, all good so far.  Then I start to set my shader variables.
In PIX, however, I can see this:
IDIRECT3DDevice9::SetFloat(0xFEFE5B7B, 0.000f);
IDIRECT3DDevice9::SetFloat(0xFEFE5B23, 0.000f);
IDIRECT3DDevice9::SetMatrix(0xFEFE5A73, 0x3FE7C3B5)

The problem, as you can see, is that no matter values (and I've walked it and verified they are non-zero at the call) get passed through as zero, and my worldViewProjection winds up as an empty matrix.


The question, then, is:  "What could I be doing wrong based on the above to cause setting my shader variables to do nothing?"


I've stuck a RAR of the PIX file at the end, for what that's worth!  Many thanks for any tips!


Creating Matrices to map a flat world to the viewport

08 August 2013 - 07:52 PM

I'm working on a "2.5D" game where everything is still proper 3D but everything lives at 0 depth.  Think of any standard side-scroller, Geometry Wars, or so on.


If I know I'm running at 1024x768 (just for example) resolution and I know that my "world" is constrained to x {-1.0, 1.0} and y {-1.0, 1.0) how do I go about creating my perspective and transform matrices other than trial and error?


I probably have to pick a camera depth, and because I do not want a lot of distortion, let's say z=1000 for the camera.  But how do I go about getting my matrices so that the 1024x768 pixels I have map to a 4:3 region of game world?


Since the screen space in a side-scroller may be 1/20th or so of the actual 2D world, the camera will have to move horizontally as well.  And similarly, I need to know when to start and stop the camera so that you do not run off either end.


As I said, I could probably guess and fine-tune until I got it right, but I have to imagine there's a more rigorous way to go about it.  


Thanks for any tips!



PS: I'm not even entirely sure I'll need a projection matrix, but I would like to be able to zoom in and out.