Making a Lighting Engine
hi,
I''m making a 2D-3D game, isometric but using D3D-TL vertices to render my tiles. I also want to write a lighting engine.
I''ve got quite far - it does range/attenuation calculations for spotlights and looks real pretty.
Now I want to add in face orientation type shading. You know, when D3D lighting is used, faces that point away from the light aren''t lit, and faces not quite facing the light are slightly darker - how can I emulate this??
Say I have 4 points - the corners of a tile, in 3D space.
I have a point light at XYZ in 3D space with colour, range, attenuation etc...
How do I tell which way the tile is facing and alter the lighting it recieves accordingly.
I only really want a simple method - I have the feeling this could get stupidly complicated...
thanks in advance,
Jack,
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>
3 points define a plane, every plane has a normal
angle between ray cast from center of tile to the light source and the normal dictates the intensity of the light, clip at 0, so faces away from the light source don''t have the light sucked out of them or pay attention to the angle.
oooh, you don''t have normal vectors, so you don''t know which way its pointing.... hum
I think your hosed, your models need normals define for each face at least, if not each vertex like normal 3d models.
angle between ray cast from center of tile to the light source and the normal dictates the intensity of the light, clip at 0, so faces away from the light source don''t have the light sucked out of them or pay attention to the angle.
oooh, you don''t have normal vectors, so you don''t know which way its pointing.... hum
I think your hosed, your models need normals define for each face at least, if not each vertex like normal 3d models.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
My models dont have normals ''cos there aren''t any models
The landscape is basically like a grid of tiles - with each point having a height. They all use D3D-TL vertices, so whilst using d3D they''re technically 2D...
Jack,
The landscape is basically like a grid of tiles - with each point having a height. They all use D3D-TL vertices, so whilst using d3D they''re technically 2D...
Jack,
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>
well, the vertexes of the grid are nevertheless bound to have normals.
in your case they should all be (0,1,0), pointing up that is
rid
in your case they should all be (0,1,0), pointing up that is
rid
Go to www.mrgamemaker.com and check out the Beginners tutorials on 3D maths.
Use the cross product to generate a normal to a face. Then use the dot product to calculate the cos of the angle between the normal and your light ... et voila !
(I did that some years ago on a little program, but that was when my Maths where still fresh in my mind )
youpla :-P
Use the cross product to generate a normal to a face. Then use the dot product to calculate the cos of the angle between the normal and your light ... et voila !
(I did that some years ago on a little program, but that was when my Maths where still fresh in my mind )
youpla :-P
-----------------------------Sancte Isidore ora pro nobis !
All planes have normals
---------------------------
"Don't die for your country, make some other dumb bastard die for his" -General George S. Patton
---------------------------
"Don't die for your country, make some other dumb bastard die for his" -General George S. Patton
cheers;
All my map is is a 2D array [199][199] of isometric (diamond) tiles. I then just create a 4 vertex TL trianglestrip for each tile and render each one...
Jack,
All my map is is a 2D array [199][199] of isometric (diamond) tiles. I then just create a 4 vertex TL trianglestrip for each tile and render each one...
Jack,
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement