Lights and skyboxes
Blitz3D Forums/Blitz3D Beginners Area/Lights and skyboxes
| ||
Dear all, In my ongoing quest to understand the basics of B3D, I have now come up against skyboxes. I think I understand the basics, but I'm not sure I know how to handle the lighting. No matter what value I use for the createlight(#) command, I always seem to get dimmer/brighter sides of the skybox when I move about. I have searched the forums, and there appear to be about a million posts on skyboxes, but they're either all beyond me, or refer peeps to the grass/castle demo that comes with B3D; that too is beyond me. Not for long I hope. Is there a basic way around this? Here's my code. Graphics3D 800,600,32,2 SetBuffer BackBuffer() ;sky texture skytex=CreateTexture(64,64) SetBuffer TextureBuffer(skytex) ClsColor 100,100,255 Cls For f=0 To 30 Oval Rnd(34)+15,Rnd(34)+15,10,10,1 Next grasstex=CreateTexture(64,64) SetBuffer TextureBuffer(grasstex) ClsColor 0,150,0 Cls Color 0,255,0 For f=0 To 30 Oval Rnd(60),Rnd(60),3,3 Next SetBuffer BackBuffer() light=CreateLight() cam=CreateCamera() plane=CreatePlane() EntityTexture plane,grasstex PositionEntity plane,0,-5,0 cube=CreateCube() ScaleEntity cube,100,100,100 FlipMesh cube EntityTexture cube,skytex ScaleTexture skytex,.5,.5 While Not KeyDown(1) If KeyDown(205) TurnEntity cam,0,-1,0 If KeyDown(203) TurnEntity cam,0,1,0 If KeyDown(200) MoveEntity cam,0,0,-1 If KeyDown(208) MoveEntity cam,0,0,1 PositionEntity cube,EntityX(cam),EntityY(cam),EntityZ(cam) RenderWorld Flip Wend End Many thanks. Tobo |
| ||
Try EntityFx cube,1 |
| ||
Try EntityFx cube,1 That'll do it. Flag 1 sets the entity to Fullbright mode. All the faces are evenly lit so they won't be affected by lights any more. You can also use a small cube (say, 5x5x5 so camera clipping won't leave out the corners, as it would if it was 2x2x2), then use EntityOrder cube,99 to force the sky to always be drawn before anything else. |
| ||
Thanks for explaning that. Could you also explain your second paragraph please, I'm not sure I follow. T. |
| ||
Well, if you have a sky cube that's 100 units across, and a ship that is 500 units away, you won't see the ship because its outside of the box. If you apply EntityOrder cube,99, this forces the cube to always be drawn first. In other words, you will still be able to see the ship 200 units away. Why use a cube 5x5x5? No reason. It just doesn't need to be any bigger as it will look the same to the camera (assuming it is parented to the camera, as I'd expect it to be). Why 99? Again, no particular reason. Could be 98, or 1. All you've done is prioritise the drawing order of the entities. Objects with a higher "entity order" are drawn before ones with a lower value. Make sense? |