Need a hint about lights

Hi guys,
Here’s a screenshot of a sketch I am currently working on.
On the upper left corner is a minimap of the dungeon (only tiles that have been seen are shown). The little green arrow there represents the player (technically, the camera).
In the middle of the screen there is a black spot: Processing seems to stop rendering anything more distant than (in my calculations) about 20000 pixels away from the screen.
(The calculation is as follows: each tile in the dungeon is 256×256 pixels; the minimap’s tile size is 4×4 pixels, and the ray seems to partly touch that distant wall which is seen through the open door) (I hope I make myself clear enough, just make sure to take a thorough look at the picture)

So here is my 1st question: can anyone tell the exact distance that Processing considers too far to render?

And the 2nd questions (the main one) is this: how can I make up lights so that anything so far (or maybe a little less than that) would dissolve into darkness?

I tried to arrange a pointLight() in the same place where the camera() is but it doesn’t seem to make it the way I’d like.

Any hint would be appreciated!

1 Like

Maybe this helps

General purpose of this is that things very close to the camera don’t get cut off

To avoid clipping call this function

void avoidClipping() {
// avoid clipping :
// https : //
// forum.processing.org/two/discussion/4128/quick-q-how-close-is-too-close-why-when-do-3d-objects-disappear
perspective(PI/3.0, (float) width/height, 1, 1000000);
}//func

2 Likes

Thank you, Chrisir

The perspective() solved the distanse clipping problem.

Any ideas about as how to add lights to it? I want it to be lit near the camera and the farther the darker. pointLight() doesn’t seem to do it (or I fail to arrange it in a proper way)

I just use lights(); after background() always in a 3D sketch

But that won’t do the trick for you?

Besides, other FPS like Wolfenstein 3D don’t have that light effect that you want iirc.

The corridors are just filled with electric light throughout

So maybe skip the idea for the moment…

I don’t know, I can’t tell which one looks better. But both don’t look the way I have in mind…

In general I prefer with lights ()

Slower but better shadows and change of color of surfaces

still not solving your main question

You had a question about lights

Maybe this (or quark) can help you:

see 3D shape with a bad seam

2 Likes

You might look at lightFalloff

I would probably avoid lights() because it doesn’t give you a lot of control.

1 Like

Thank you, guys! Chrisir quark
I tried to play with the lightFalloff() but didn’t get the numbers right to do the task.

Actually I think the problem might be in the way I display my dungeon. Follow this: the lights colorify everything according to the normals to the surfaces. My guess is I somehow arrange my surfaces that their normals look outside the light, so they are always in the shadow… but without lights() they are shown in their natural color :slight_smile:

I guess I’ll have to rewrite my visualization routine for the dungeon. the tutorials say I must declare vertices inside beginShape()…endShape() in a proper way so that when the normals are calculated they look in the proper direction (outside off the walls towards the empty space).

1 Like