Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

166 Neutral

About davepl1968

  • Rank
  1. davepl1968

    HDR Bloom Question

    Thanks!  On some systems the are "resolve" steps wherein you can apply the threshold bias in that resolve step; since I'm on DX9 my closest is StretchRect, but it cannot apply any biasing or adjustment during the copy.  Would it make sense to have my pixel shader apply the threshold division, since I cannot do it in a resolve step?
  2. 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?   Thanks! Dave
  3. Thanks, that's what I've been working on since I posted it (a 'Combine' shader that takes the two blur stages and combines their outputs to the screen).  I'm not familiar with the blend() function, so thanks!  I had just been adding them with a scale factor.
  4. 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?   Thanks!    
  5. 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;  
  6. My issue turned out to be a pretty basic one - not calling effect->Begin(...) on the effect itself, although I had called Begin on the scene and on the pass.
  7. 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!  
  8. 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! Dave   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.
  9. My solution was to compile them to .cso and then do this:   V_RETURN( D3DXCreateEffectFromFile(pd3dDevice, strPath.c_str(), 0, 0, D3DXSHADER_DEBUG, 0, &_ptrEffect, &pBuffer) ); V_RETURN( pd3dDevice->CreateVertexDeclaration(particleVertexDeclarations, &_ptrVertexDeclaration) );   // Get the technique, pass, and shaders we need   D3DXHANDLE hTechnique = _ptrEffect->GetTechniqueByName("ExplosionTechnique"); if (!hTechnique) return E_FAIL;   D3DXHANDLE hPass = _ptrEffect->GetPassByName(hTechnique, "Pass0"); if (!hPass) return E_FAIL;   // Get the vertex and pixel shaders    D3DXPASS_DESC desc; V_RETURN( _ptrEffect->GetPassDesc(hPass, &desc) ); V_RETURN( pd3dDevice->CreateVertexShader(desc.pVertexShaderFunction, &_ptrVertexShader) ); V_RETURN( pd3dDevice->CreatePixelShader (desc.pPixelShaderFunction,  &_ptrPixelShader) );
  10. I'll answer my own question since I've seen it asked a number of times but never answered:  this appears to work.       D3DXPASS_DESC desc; V_RETURN( _pEffect->GetPassDesc(hPass, &desc) ); V_RETURN( pd3dDevice->CreateVertexShader(desc.pVertexShaderFunction, &_pVertexShader) ); V_RETURN( pd3dDevice->CreatePixelShader (desc.pPixelShaderFunction, &_pPixelShader) );
  11. According to an MSDN page, I found this:   What is the correct way to get shaders from an Effect? Use D3DXCreateEffect to create an ID3DXEffect and then use GetPassDesc to retrieve a D3DXPASS_DESC. This structure contains pointers to vertex and pixel shaders So I wrote this code: D3DXPASS_DESC desc; V_RETURN( _pEffect->GetPassDesc(hPass, &desc) ); _pPixelShader  = (D3DPixelShader *)  desc.pPixelShaderFunction; _pVertexShader = (D3DVertexShader *) desc.pVertexShaderFunction;   However, while there are raw pointers available, they're certainly not IDirect3DPixelShader9 objects; you can see that the v-table of the IUnknown are garbage.  Am I perhaps supposed to treat them like opaque (DWORD *) values rather than proper objects?  If that were the case, then calling SetVertexShader on the device wouldn't be possible with them, since pd3d->SetVertexShader requires a true IDirect3DVertexShader9.   So, still hooped.
  12. davepl1968

    Get PixelShader from ID3DXEffect

      I'm in the same boat.  I've tried passing both the Technique and the Pass handle, but both generate the D3DERR_INVALIDCALL and the debug runtime says its an invalid handle.  Yet they're non-zero and the "GetPassByName" that I use to get the handle succeeds. Anyone come up with a solution to this yet?
  13. My code below is intended to do a few things in order: - Load the effect file  - Get the main technique in the FX file - Get the first pass of that technique - Get the vertex and pixel shaders from that pass   All works fine up until the GetVertexShader() call.  I wind up with hr=D3DERR_INVALIDCALL (0x8876086c).   I've verified that I'm getting back values for hTechnique and hPass.  For completeness I've included the relevant snippet from the .fx file as well.   So, my question boils down to:  give a handle to a shader pass, how do you get the vertex and pixel shaders from it? ID3DXBuffer * pBuffer = NULL; V_RETURN( D3DXCreateEffectFromFile(pd3dDevice, strPath.c_str(), 0, 0, D3DXSHADER_DEBUG, 0, &_pEffect, &pBuffer) ); V_RETURN( pd3dDevice->CreateVertexDeclaration(particleVertexDeclarations, &_pVertexDeclaration) ); // Get the technique, pass, and shaders we need D3DXHANDLE hTechnique = _pEffect->GetTechniqueByName("ExplosionTechnique"); if (!hTechnique) return E_FAIL; D3DXHANDLE hPass = _pEffect->GetPassByName(hTechnique, "Pass0"); if (!hPass) return E_FAIL; V_RETURN( _pEffect->GetVertexShader(hPass, &_pVertexShader) ); // FAILS! V_RETURN( _pEffect->GetPixelShader(hPass, &_pPixelShader) ); technique ExplosionTechnique { pass Pass0 { VertexShader = compile vs_3_0 ExplosionVertexShaderFunction( ); PixelShader  = compile ps_3_0 ExplosionPixelShaderFunction( ); } }  
  14. But how do you call release on it?  It's not a COM object or pointer, it's an opaque handle.  Is there a special release function for D3DXHANDLEs that I'm not seeing?   Thanks! Dave
  15. If I have a piece of code such as this:       D3DXHANDLE hTechnique = _pEffect->GetTechniqueByName("ExplosionTechnique");   When I'm done, or exiting, or an error occurs, what do I do with hTechnique?     I'm -guessing- that the handles don't increase a ref count on the effect and that it's just up to me to make sure i use the handles within the lifetime of the effect itself.  But I can't really find any docs on it, and no sample code shows them being released.   Still, I'm one of those folks who doesn't like my code to leak anything under any reasonable scenario, so I'd like to make sure I'm doing the right thing!   Thanks, Dave
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!