   using D3DXCreateSphere with alpha?
  Hi all, I'm using D3DXCreateSphere to create a bounding sphere around an object.  I want to render the sphere with some sort of translucency?  Right now I’m just setting my world transform to position where to render, then calling DrawSubset.  Can someone suggest what might be the best way of enabling some transparency on the sphere?  I don’t know if createsphere sets texture coordinates, but I don’t want to render a texture, so I don’t think texture alpha would work.  Do I have to walk the triangle list and modify the color alpha for every vertex or is there a global setting I can use to do it?Thanks   
  I was writing about this in the FAQ last night [lol]If you're using fixed-function then its fairly simple:SetRenderState( D3DRS_TEXTUREFACTOR, D3DCOLOR_ARGB( a, r, g, b ) );SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TFACTOR );SetTextureStageState( 0, D3DRSS_COLOROP, D3DTA_SELECTARG1 );SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR );SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTA_SELECTARG1 );Thats off the top of my head, so if it doesn't work just have a dig around in the "Texture Blending" and "Alpha Blending" sections of the SDK's index (theres a fairly nice guide to various methods).Given its a sphere and that blending is draw-order dependent a nice trick is to do a 2-pass render. Render the same geometry in both passes but swap the culling mode (D3DRS_CULLMODE) so that the first pass renders the back-faces of the sphere and the second pass renders the front-faces of the sphere.hthJack   ;  Thanks, I kind of knew this, but I knew I was forgetting it.  I guess I've been doing more with shaders and forgot some of this basic stuff.   ;  If you're doing shaders then isn't the simplest way just to create a shader that emits a constant alpha/colour?Quote:Original post by QuadMVThanks, I kind of knew this, but I knew I was forgetting it.  I guess I've been doing more with shaders and forgot some of this basic stuff.I feel this might be relevant, if a little OT:Quote:Homer Simpson:every time I learn something new, it pushes some old stuff out of my brain. Remember when I took that home winemaking course, and I forgot how to drive?Cheers,Jack   ;  Here are the minor adjustments I had to make if anyone is interested, but it worked flawlessly:pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR , D3DCOLOR_ARGB( 0x0F, 0xFF, 0, 0 ) );pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TFACTOR );pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR );pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );I also used:pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ); so it would render the sphere on both sides;Quote:If you're doing shaders then isn't the simplest way just to create a shader that emits a constant alpha/colour?That's assuming I'm good a shaders ;-)Also though, it would require creating a file with the proper shader code, loading it, enabling it, debugging it, etc...  I think your suggestion is actually easier.;Quote:Original post by QuadMVI also used:pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ); so it would render the sphere on both sidesThat's rather dangerous, since alpha blending only works correctly when sorted from back to front. You should make sure that you render the sphere such that the back side is drawn first. (Which luckily should be possible with a sphere.)Edit: You're turning Z writing off when drawing that sphere, right?   ;  In this particular case the sphere is the very last thing to get rendered, so sorting isn't a problem nor is z write, but in general yes, you are absolutely right.  I draw my water and billboards with alpha sorted appropriately.   