Sign in to follow this  
agisler

models transparent

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.

[code]

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,
}
[/code]

Many thanks

agisler

Share this post


Link to post
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 [url="http://archive.gamedev.net/community/forums/mod/journal/journal.asp?jn=300672&reply_id=3123284"]the Debug Runtime[/url] 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 this post


Link to post
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:
[code]

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
[/code]
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 this post


Link to post
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 this post


Link to post
Share on other sites
[quote name='Buckeye' timestamp='1298345997' post='4777365']
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.
[/quote]

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 this post


Link to post
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.

[url="http://www.toymaker.info/Games/html/z_buffer.html"]http://www.toymaker.info/Games/html/z_buffer.html[/url]


Many thanks

agisler

Share this post


Link to post
Share on other sites
[quote]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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this