I use Sprite to draw some texture and want the texture fade out after
some time. Should I set the "device.RenderState" before
drawing the texture to do fade in/out
What should I do if I want the whole screen fade in/out
Thank you
Hi, I also want to do fade in/out, but I do not quite understand what you mean. I use Sprite to draw 2D textures and no Light is needed. I don't know how to use Light to change the appearance of those 2D texture.
I can fade in/out the texture by setting the last parameter in Sprite.Draw(). But I don't know how to fade in/out the whole screen. Setting Light cannot change the appearance of the textures. Can you give me some examples on doing the fade in/out
In order to influence all your screen you need all your element in the screen to be influence by the Ambient light, and then you play with that ambient light value to fade in or out
You create a light, and then Open it, and then you put the Ligthing state On You can also create a material
The Light will affect all Vertex depending on the light in the scene and the material of your vertex
For the Texture to be affected by the light you modulate it with Diffuse This way each vertex of your textured object will be affected by it's diffuse value
I'm still not sure if you need to modulate with diffuse or not to get the fade But it give you other way to fade the texture object by modifying the diffuse component of your vertex
You will need to do some test, with light, material, and ambient value Their is many combination possible to get your Fade
I know I have a total Fade In and Fade out in my Program...(at home) All the screen go dark at once...and go back to full light When I modify the Ambient value (including textured object)
It may because Lightning state is on and because ambient value work on all Object , or maybe it's because I modulate my texture with diffuse I'm still not sure which one make it work...maybe someone else can tell us :-)
Fade in/out
kulkarni
I also want to do fade in/out, but I do not quite understand what you mean.
I use Sprite to draw 2D textures and no Light is needed. I don't know how to use Light to change the appearance of those 2D texture.
I can fade in/out the texture by setting the last parameter in Sprite.Draw(). But I don't know how to fade in/out the whole screen. Setting Light cannot change the appearance of the textures. Can you give me some examples on doing the fade in/out
Thank you
juanchoc
In order to influence all your screen you need all your element in the screen
to be influence by the Ambient light, and then you play with that ambient light value
to fade in or out
You create a light, and then Open it, and then you put the Ligthing state On
You can also create a material
The Light will affect all Vertex depending on the light in the scene
and the material of your vertex
For the Texture to be affected by the light you modulate it with Diffuse
This way each vertex of your textured object will be affected by it's diffuse value
I'm still not sure if you need to modulate with diffuse or not to get the fade
But it give you other way to fade the texture object by modifying the
diffuse component of your vertex
You will need to do some test, with light, material, and ambient value
Their is many combination possible to get your Fade
I know I have a total Fade In and Fade out in my Program...(at home)
All the screen go dark at once...and go back to full light
When I modify the Ambient value (including textured object)
It may because Lightning state is on and because ambient value work on all Object
, or maybe it's because I modulate my texture with diffuse
I'm still not sure which one make it work...maybe someone else can tell us :-)
//Set ambient light level
m_pD3DDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(32, 32, 32));
device->SetTextureStageState(0, D3DTSS_COLOROP,D3DTOP_MODULATE);
device->SetTextureStageState(0, D3DTSS_COLORARG1,D3DTA_TEXTURE);
device->SetTextureStageState(0, D3DTSS_COLORARG2,D3DTA_DIFFUSE);
(your FVF must have a Diffuse part that you can modify with the fade you need)
http://www.toymaker.info/Games/html/texture_states.html
http://andypike.com/tutorials/DirectX8/007.asp
D3DLIGHT8 d3dLight;
//Initialize the light structure.
ZeroMemory(&d3dLight, sizeof(D3DLIGHT8));
//Set up a white point light at (0, 0, -10).
d3dLight.Type = D3DLIGHT_POINT;
d3dLight.Diffuse.r = 1.0f;
d3dLight.Diffuse.g = 1.0f;
d3dLight.Diffuse.b = 1.0f;
d3dLight.Ambient.r = 0.0f;
d3dLight.Ambient.g = 0.0f;
d3dLight.Ambient.b = 0.0f;
d3dLight.Specular.r = 0.0f;
d3dLight.Specular.g = 0.0f;
d3dLight.Specular.b = 0.0f;
d3dLight.Position.x = 0.0f;
d3dLight.Position.y = 0.0f;
d3dLight.Position.z = -10.0f;
d3dLight.Attenuation0 = 1.0f;
d3dLight.Attenuation1 = 0.0f;
d3dLight.Attenuation2 = 0.0f;
d3dLight.Range = 100.0f;
//Assign the point light to our device in poisition (index) 0
m_pD3DDevice->SetLight(0, &d3dLight);
//Enable our point light in position (index) 0
m_pD3DDevice->LightEnable(0, TRUE);
//Turn on lighting
m_pD3DDevice->SetRenderState(D3DRS_LIGHTING, TRUE);
//Set ambient light level
m_pD3DDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(32, 32, 32));
Wenlong.Dong
Set Ambient Light State to a decreasing or increasing value
would be good if it's all the screen you want to fade out...
Set the Texture Arg1 to Texture
and Diffuse for Arg2
Operation to Modulate...
this way your texture will fade out with the light