Skip to main content
GameDev.net gamedev.net
🔒 Locked

Lighting etc

Started by Hog Jan 10, 2004 at 1:42 PM 2 replies 300+ views
Original Post
Hog
Hog
OK I''ve been reading up on texture and materials etc but cannot get a nice finished rendered view of my mesh. I create a sphere using anim8or and set a material to blue. When I view this is scene view or render to jpg file the sphere has a nice shiney surface to it with light reflecting off it. So in my code I load the mesh file and the matrial but when I set fillmode to solid that''s all I get, a solid non reflective colour. I have found some good tutorials at http://www.directx4.net and have searched the web for others but the answer eludes me Please do you DX gurus wish to help?
(Visual Basic .NET) www.elpuerco.co.uk
aker_jus
aker_jus
You are comparing static rendered images using a raytracer (anim8or) against realtime applications. The things you say (reflection, shiny surface), can be done in realtime 3D using shaders, or u can add specular highlights to a material, but it wont show up nice unless the model has a decent vertex count.
GraphicsWare|RenderTechhttp://www.graphicsware.com3D Graphics & Solutions
Supernat02
Supernat02
Also, don't forget to make the ambient light a low level:

lpD3DDevice->SetRenderState(D3DRS_AMBIENT, RGB(55,55,55));

and to turn lights on:
lpD3DDevice->SetRenderState(D3DRS_LIGHTING, TRUE);

and to create a light:
D3DLIGHT9 light;
ZeroMemory( &light, sizeof(light) );
light.Type = D3DLIGHT_DIRECTIONAL;

light.Diffuse.r = 1.0f;
light.Diffuse.g = 1.0f;
light.Diffuse.b = 1.0f;
light.Range = 1000.0f;
light.Direction = D3DVECTOR3(0.0f, -1.0f, 0.0f);
lpD3DDevice->SetLight( 0, &light );

and to turn it on:
lpD3DDevice->LightEnable( 0, TRUE);

Good luck,
Chris

EDIT: Can't make direction 0 length, oops! I changed it to y of -1, so that the light is coming straight down on the x-z plane.

[edited by - Supernat02 on January 11, 2004 12:36:50 AM]
Chris ByersMicrosoft DirectX MVP - 2005
Hog
Hog
Fantastic response....thnx

aker_jus, I get what you mean about a decent vertex count, but if for example you open any single model mesh in MeshView, even a simple cube, it will appear with a nice grey shiney surface. This is what I am trying to achieve

Supernat02, wicked! I shall try this out
(Visual Basic .NET) www.elpuerco.co.uk

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.