Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Should a matrix be illuminated by lights?

Author
Message
Soyuz
23
Years of Service
User Offline
Joined: 17th Dec 2002
Location:
Posted: 30th Mar 2003 19:14
Dear Earthlings,

My lights seem to have no effect on the matrix - is this normal? I see no mention of lighting a matrix in the manual.

Yours sincerely.

Miss China (1932)
Superbeest
23
Years of Service
User Offline
Joined: 9th Mar 2003
Location: Netherlands
Posted: 30th Mar 2003 19:42
That's because you should use the set matrix normal function. Use this sample:



Change the MatrixSlicesX(andY) and the MatrixSizeX(andY) to the size of your matrix and fill in the coordinates of your light source. Then just update the matrix and you have a realistic light source on your matrix.

By steel will thy flesh divide
EddieRay
23
Years of Service
User Offline
Joined: 28th Feb 2003
Location: USA
Posted: 30th Mar 2003 20:07
So the normals of a matrix don't automatically get set based on the average height of the matrix grid-points (the true normal of the surface)? That's odd.

It's nice to be able to make the matrix normals be whatever you want, at least.

Where did the hard-coded numbers for the normals come from... i.e. <.4,.4,.4> and <0,1,0>...??? They don't seem to be based on anything in the geometry of the scene... except possibly the ground height (but then only to select between the two hard-coded values).

Could you provide a detailed explanation of the logic of your code?

Superbeest
23
Years of Service
User Offline
Joined: 9th Mar 2003
Location: Netherlands
Posted: 30th Mar 2003 21:30
0,1,0 is the standard value. So all normals in a matrix are set to this.
.4,.4,.4 creates a dark area. You can also try .3,.3,.3 or .5,.5,.5. It's just what you like better. But I think 4 is the best.
I must admit it isn't my code. Got is from an example and tried to modifie it a bit.
But it works for me.

By steel will thy flesh divide
Soyuz
23
Years of Service
User Offline
Joined: 17th Dec 2002
Location:
Posted: 31st Mar 2003 01:14
Thanks I got some odd results but I guess I'll need to play with this to my own liking.
EddieRay
23
Years of Service
User Offline
Joined: 28th Feb 2003
Location: USA
Posted: 31st Mar 2003 05:38
So what is the root of the problem here? Are you sure you have light sources set up the way you want? My problem has always been that either light 0 or ambient light (I used to think they were one and the same, but I'm not sure) seem to flood the scene with non-directional light. So unless you set ambient light to 0, and hide light 0, it's hard to really see what's going on with the lights you create on your own (light 1 or higher). Also, it seems like light ranges in DBPro do make as much sense as they do in DBC. I'm still playing around with lighting, but I can't say I've really gotten anything to look the way I want.

So back to the original question, if we make a matrix, and then do something drastic like "randomize matrix 1,300", we'd expect to see a bunch of "peaks" and "valleys" in our matrix. So, if we have a point light on one side of the matrix, maybe at y=100, then the other side of peaks should theoretically be unlit since the are facing away from the light (their normals don't aim towards the light). This is different that say a "valley" in the matrix that has a normal facing towards the light, but is so "deep" that other parts of the matrix "block" the light (which I don't think DBPro handles, but maybe it should? maybe T&L hardware takes this into account? maybe not...). Of course, this all assumes that when you use "set matrix height..." or "randomize matrix..." that DBPro automatically fills in the proper values for the normals based of the average height at the tile. The docs could answer these questions I guess... what docs?

The Wendigo
23
Years of Service
User Offline
Joined: 13th Sep 2002
Location: A hole near the base of a tree in the US
Posted: 1st Apr 2003 23:21
simply try this:

for z = 1 to 50
for x = 1 to 50
set matrix normal matnum, x,z,0,1,0
next x
next z

after that i had no problems with the display of pointlights on a matrix...

oh and one more thing that is unrelated: when working with lights alot I noticed that point lights make light on objects REALLY far away from them sometimes. Use set light range lightnumber, 60. 60 to 100 might work best then. I had some interesting bright blue, green and red skyscrapers before i did this .

Superbeast's code actually generates raycasted shadows that look really cool! I did something similar! If anyone wants code for doing that with objects on a matrix, I can do that to, so just ask!

Ed: you are correct (from what I've seen) that light zero and ambient light are different. IF you want a directional light from the default lights you can simply turn light 0 into a directional light.

Set Directional Light 0, 1,-1,1. (try flipping the -1 to 1 if you have problems with it).

1.00 GHZ processor, 256 MB RAM, GeForce 3 64MB, SB Live!, 8 cans of soda per day
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 2nd Apr 2003 00:17
aye don't hide light 0 and then use light 1 - just make light 0 into whatever you where going to make with light 1....

Set Ambient Light is the intensity of light to be placed on total shadow areas of your view, and Colour Ambient Light is the colour of that light.

So if you want your shadowed areas to be pitch black Set Ambient Light 0. If you want your lightsources to simply amplify light or apply a colour hue, set ambient light to a mid-range number, 50 or so...

Pneumatic Dryll, Outrageous epic cleric of EQ/Xev
God made the world in 7 days, but we're still waiting for the patch.
Superbeest
23
Years of Service
User Offline
Joined: 9th Mar 2003
Location: Netherlands
Posted: 2nd Apr 2003 20:06
Thanx TheWendigo for the compiment, but it is SuperBEEST, not Superbeast. It's Dutch, but it means the same But no hard feelings

By steel will thy flesh divide
EddieRay
23
Years of Service
User Offline
Joined: 28th Feb 2003
Location: USA
Posted: 3rd Apr 2003 07:36
Okay, the SET MATRIX NORMAL matnum, x,y,0,1,0 didn't really make a noticeable difference on my flat matrix. My guess is that the normals are initialized to 0,1,0 for a matrix on creation.

I played around with light 0, and setting ambient light to 0 and I'm starting to get more "expected" results. The scale of the ambient light seems to be whacked compared to DBC tho'. If I turn it up to anything above 10 or so, my box objects that are colored say, rgb(50,0,0) start to look milky pink to white pretty quickly. I found that if you don't do a SET NORMALIZATION ON it's even more "whacked"...

TrenteTrois
23
Years of Service
User Offline
Joined: 3rd Apr 2003
Location:
Posted: 3rd Apr 2003 18:25
I didn't read all the comments on this thread but I wanted to ask this question. Is it possible to set a diffusion level on a light when I want it to lighten my surface? Is that hard to program?

Login to post a reply

Server time is: 2026-07-11 08:46:36
Your offset time is: 2026-07-11 08:46:36