Diffuse Color + Texture problems...
Well, what can I say... I've been at this for hours and I can't nail it down.
Here is my Vertex Format
#define D3DFVF_TERRAIN (D3DFVF_DIFFUSE|D3DFVF_NORMAL|D3DFVF_TEX1|D3DFVF_XYZ)
struct TERRAINVERT
{
D3DXVECTOR3 vPosition; // position
D3DXVECTOR3 vNormal; // normal
D3DCOLOR Diffuse; // diffuse color
float tu, tv; // texture coordinates
};
My texture is just greyscale... I would like it to blend it with the diffuse colors of the vertices.
I am mainly confused about the render states...
As it stands now, if the r, g, or b values of the Diffuse color are greater than 0, they act as if they are 100 percent.
Example: 0x00ff0000 == 0x00010000 (as it appears on the screen)
I think I just need to set my render states properly to blend diffuse vertex colors with the texture.
Thanks very much for the help.
To blend the texture and the vertices diffuse color, all you need to do is set the texturestagestate operation to modulate between the two.
SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE );SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TEXTURE );
Hmm.. I implemented those render states... and I thought that would fix my problem.. but it didn't make any difference.
--------------------------------------------------------------
When I set the diffuse colors of my terrain vertices to:
pVertList[(short) counter].Diffuse = 0x00ff0001;
The result is my greyscale texture blended with a VERY PINKISH-PURPLE color ... But we know it should be a VERY RED color instead.
Note:
0x00ff0000; results in a Solid red blend
Note:
0x00010000; results in exactly the same solid red blend (very dark)
It seems like my colors are all or nothing... It seems that I can either have 100 percent redness, or none at all... and that goes for green & blue as well.
Thanks for the help... I'm so confused.
--------------------------------------------------------------
When I set the diffuse colors of my terrain vertices to:
pVertList[(short) counter].Diffuse = 0x00ff0001;
The result is my greyscale texture blended with a VERY PINKISH-PURPLE color ... But we know it should be a VERY RED color instead.
Note:
0x00ff0000; results in a Solid red blend
Note:
0x00010000; results in exactly the same solid red blend (very dark)
It seems like my colors are all or nothing... It seems that I can either have 100 percent redness, or none at all... and that goes for green & blue as well.
Thanks for the help... I'm so confused.
By the way, if this is of any help to anybody...
I have 1 light (2 if you count the ambient light)
I have 1 light (2 if you count the ambient light)
VOID SetupLighting(){ if(!LightCreated) { // Setup Light ZeroMemory( &light, sizeof(D3DLIGHT9) ); light.Type = D3DLIGHT_POINT; light.Diffuse.r = 1.0f; light.Diffuse.g = 1.0f; light.Diffuse.b = 1.0f; light.Attenuation0 = 0.0f; light.Attenuation1 = 0.0f; light.Attenuation2 = 0.0f; light.Direction = D3DXVECTOR3(0,-1,0); light.Range = 2000.0f; light.Position = D3DXVECTOR3(0, 500, 0); } g_pd3dDevice->SetLight( 0, &light ); g_pd3dDevice->LightEnable(0, TRUE);//Turn on lightingg_pd3dDevice->SetRenderState(D3DRS_LIGHTING, TRUE);//Set ambient light levelg_pd3dDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(32, 32, 32));g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE );g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TEXTURE ); g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA); g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA); g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);}
You know... It's funny that I just posted that lighting business... I went back in and started playing with my lights again.
I discovered a fix to my problem.
IT is a GOOD thing to have greater-than-0 attenuation on your lights!
I had 0 attenuation on my lights and it was causing very little diffuse color to become a LOT of diffuse color.
Sorry for the trouble, thanks again.
I discovered a fix to my problem.
IT is a GOOD thing to have greater-than-0 attenuation on your lights!
I had 0 attenuation on my lights and it was causing very little diffuse color to become a LOT of diffuse color.
Sorry for the trouble, thanks again.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement