Scene lighting

Previous topic - Next topic

matty47

Hi,
please look at the project in the zip
//members.optusnet.com.au/~ingle.m/3droom.zip
When I run this I can see the model OK even though I have not made any lights. If I add a light nothing changes. I think I am missing something fundamental here. (Note I have added extra stuff to the T3DEntity file)
Any help appreciated
Matthew

matty47

No takers???
Matthew

Moru

Have you tried the examples that comes with GL-Basic? I think there is some with 3D and lighting in there.

matty47

In the light example I can see no difference in the "off", "ambient" ,"multitexture" and "spot" modes. The "bump" and "cartoon" modes do appear to have shadows but I can't say that there is any variation in the light (no attenuation). The shadows example likewise show a shadow but again the rest of the lighting is pretty uniformly lit. Am I expecting too much??
Thanks
MAtthew

matty47

Anyone tried the example? I just don't seem to be able to understand how to set up the lights. I assumed that if there were no lights then you should be unable to see anything. Is this a wrong assumption?

Anyone?
Thanks
Matthew

Moru

I'm not sure how it works in GL-Basic but if you have no lights it's supposed to work on the ambient light wich gives no shadows at least in Pov-Ray. Is there such a setting?

matty47

I am not working with shadows at the moment. I just don't know if the lights are working in 3D. I have made two small examples. The first just draws a plane and puts the camera 10 units away from it. No lighting commands. The plane shows in the 3d view when the program is run.
Code (glbasic) Select
// --------------------------------- //
// Project: lights2
// Start: Sunday, February 17, 2008
// IDE Version: 5.173

//create a plane to catch the light
MakePlane(1)

//Main loop
WHILE TRUE

X_MAKE3D 0.1,500,90
X_CAMERA 0,0,15,0,0,0
X_DRAWOBJ 1,0

SHOWSCREEN
WEND




FUNCTION MakePlane:pn
X_OBJSTART pn
X_OBJADDVERTEX -10,-10,0,0,1,RGB(128,128,128)
X_OBJADDVERTEX -10,10,0,0,0,RGB(128,128,128)
X_OBJADDVERTEX 10,10,0,1,0,RGB(128,128,128)
X_OBJADDVERTEX 10,-10,0,1,1,RGB(128,128,128)
X_OBJADDVERTEX -10,-10,0,0,1,RGB(128,128,128)
X_OBJEND
ENDFUNCTION
Now I add a spot light to the scene and you can turn it on and off, change the cutoff angle and move it forwards and back along the z axis. I can't see any difference here to the first program. So what is the light doing??
Code (glbasic) Select
// --------------------------------- //
// Project: Lights
// Start: Sunday, February 17, 2008
// IDE Version: 5.173
//create a plane to catch the light
MakePlane(1)
//create a varaible to alter the cutoff
LOCAL cutoff=90
//and one to hold the z value of the light
LOCAL lightz=20
//a toggle for the light
LOCAL On=1
LIMITFPS 12
//Main loop
WHILE TRUE

X_MAKE3D 0.1,500,90
X_CAMERA 0,0,15,0,0,0
X_DRAWOBJ 1,0
IF On =1 THEN X_SPOT_LT 0,RGB(255,255,255),0,0,lightz,0,0,-1,cutoff

IF KEY(45)=1 THEN On=ABS(On-1)
IF KEY(37)=1
cutoff=cutoff-1
IF cutoff<5 THEN cutoff=5
ENDIF
IF KEY(38)=1
cutoff=cutoff+1
IF cutoff>180 THEN cutoff=180
ENDIF
IF KEY(30)=1 THEN lightz=lightz-1
IF KEY(44)=1 THEN lightz=lightz+1

X_MAKE2D
PRINT "Use K and L to change the cutoff angle",0,10
PRINT "Use A and Z to move the light on the Z axis",0,20
PRINT "Use X to toggle the light on and off",0,30
PRINT "The light is pointing into the screen always",0,40
PRINT "On Value: "+On,0,80
PRINT "Cutoff Angle: "+cutoff,0,100
PRINT "Light at 0,0,"+lightz,0,120



SHOWSCREEN
WEND




FUNCTION MakePlane:pn
X_OBJSTART pn
X_OBJADDVERTEX -10,-10,0,0,1,RGB(128,128,128)
X_OBJADDVERTEX -10,10,0,0,0,RGB(128,128,128)
X_OBJADDVERTEX 10,10,0,1,0,RGB(128,128,128)
X_OBJADDVERTEX 10,-10,0,1,1,RGB(128,128,128)
X_OBJADDVERTEX -10,-10,0,0,1,RGB(128,128,128)
X_OBJEND
ENDFUNCTION
So my question really is - have I just missed out doing something or are the lights not working. Any help would be greatly appreciated
Matthew

Kitty Hello

uhm.. could you put the light before the X_DRAWOBJ, please?

matty47

I just tried that. It has made a difference. There is now a difference in turning the light on and off. I have tried varying the cutoff and the distance from the plane and the lighting does not seem tovary smoothly but rather "jumps" between finite states. Eg leave the light at its start point and vary the cutoff. You will see what I mean. Similarly leave the cutoff at the start value and move the light toward the plane. For me the light switshes state when it is closer to the plane than the camera. I was expecting (hopong) that the cutoff would show a shrinking ring of illumination . Sorry to be a pain.

matty47


Kitty Hello

Well, the cutoff is just an angle that decides if a vertex gets lit or not.
You're only drawing a 4 noded quad. Don't expect a circular ring on it. You must use a finer mesh for these effects, as the lighting is per vertex, not per pixel.
So, for lights, please use a sphere or a donut or whatever. Not just one polygon.

matty47

Thanks I will try this. As I said I probably missed something.
Thanks for your patience

moonmoon

I got the information.