• 13
• 18
• 19
• 27
• 9

# models transparent

This topic is 2581 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello,

For some strange reason all my models are transparent. I have looked all over my code and from what i can tell they should not be transparent. My alpha channel appears to be correct. I do not have any high level shaders either if that makes any difference. Any input would be very helpful.

The code below is where i set my alpha channel and render states.

 void CBase::InitProjection() { CCamera *pActiveCam = CCameraManager::GetActiveCamera(); D3DXMATRIX viewMatrix; D3DXMatrixLookAtLH(&viewMatrix, (D3DXVECTOR3*)&pActiveCam->GetEye(), (D3DXVECTOR3*)&pActiveCam->GetLookAt(), (D3DXVECTOR3*)&pActiveCam->GetUp()); c_pGraphics->GetDevice()->SetTransform(D3DTS_VIEW, &viewMatrix); D3DXMATRIXA16 projection; D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/3.0f,pActiveCam->GetAspect(),0.1f,1000.0f); c_pGraphics->GetDevice()->SetTransform(D3DTS_PROJECTION,&projection); //set render states c_pGraphics->GetDevice()->SetRenderState(D3DRS_FILLMODE, c_pBase->GetFillMode()); c_pGraphics->GetDevice()->SetRenderState(D3DRS_SHADEMODE,D3DSHADE_GOURAUD); c_pGraphics->GetDevice()->SetRenderState(D3DRS_LIGHTING,TRUE); c_pGraphics->GetDevice()->SetRenderState(D3DRS_AMBIENT,D3DCOLOR_XRGB(80,80,80)); c_pGraphics->GetDevice()->LightEnable(0,TRUE); //c_pGraphics->GetDevice()->SetLight(0, } 

Many thanks

agisler

##### Share on other sites
First, it doesn't appear you check for any errors. Every DirectX and Win32 API function call gives some indication of success or failure. Take a look at the documentation for each function, paying particular attention to return values and other information regarding error conditions and consider making good use of the SUCCEEDED and FAILED macros. Also, take a look at the Debug Runtime as that will provide information about error conditions when you run your code.

Second, there are examples in the SDK (such as tutorial Tut_04, I think) which demonstrate how to use lights. For instance, you enable light 0 but it doesn't appear you setup parameters for light 0.

##### Share on other sites
I have already checked all that. Everything comes back ok.

I am aware that my lighting is not complete yet. My thinking was that the lighting does not have anything to do with models being transparent? is this correct?

The only thing my debug runtime says besides the loaded information is:
 Direct3D9: (INFO) :Using FF to VS converter Direct3D9: (INFO) :Using FF to PS converter Direct3D9: (INFO) :Enabling multi-processor optimizations Direct3D9: (INFO) :DDI threading started Direct3D9: (WARN) :Ignoring redundant SetRenderState - 8 Direct3D9: (WARN) :Ignoring redundant SetRenderState - 9 Direct3D9: (WARN) :Ignoring redundant SetRenderState - 137 
I have tried looking up what this all means many times but can't seem to get anywhere. The lines "using FF to VS converter" are outputted when I create my graphics device

The "ignoring redundant SetRenderState" happens for the first 3 lines of when i set my render states.

Thanks

agisler

##### Share on other sites
Have you enabled the blending renderstate in another part of your code?

##### Share on other sites
You probably should see something. However, at this point you're asking help in debugging poorly written and incomplete code. That being said, your problem is likely elsewhere in your program. You might try rendering a simple triangle and get that working properly.

FYI, you get warnings setting redundant render states because those render states are already in the state you're requesting.

##### Share on other sites

You probably should see something. However, at this point you're asking help in debugging poorly written and incomplete code. That being said, your problem is likely elsewhere in your program. You might try rendering a simple triangle and get that working properly.

FYI, you get warnings setting redundant render states because those render states are already in the state you're requesting.

I do see something. You can see the objects fully. I have attached a print screen. If you look at the front right foot you can notice that you can see the tigers back left foot when it should not be visible.

I understand why i get these render state warnings. I assumed its because Directx sets these states by default and i am just resetting the states?

Also, I take offence when you say that I have poorly written code. You have seen one small method. Its not constructive criticism.

@Hodgman
All my render states are in this part of the code. I have played around a bit with the alpha blending states but with no luck. I am not sure if this is what you mean by blending renderstates.

Something that I thought could be the problem is the order of which my object is being rendered. So for example the front being rendered and then the back being rendered over the front. Thats just an idea.

Thanks for the help

agisler

##### Share on other sites
To me it rather looks like the depth test isn't working.

##### Share on other sites
Thank you so much!! It was my z buffer. I had not enabled and created my z buffer. I used this web page to check my z buffer settings and add some of the code I had missed.

http://www.toymaker.info/Games/html/z_buffer.html

Many thanks

agisler

##### Share on other sites
I take offence when you say that I have poorly written code. You have seen one small method. Its not constructive criticism.[/quote]
The code you posted has no error checking and you provided no indication that you'd checked for valid values, etc. If, in general, you don't consider checking for errors a constructive way to write code, then just consider it my personal opinion on an approach to coding.