# Need a hint about lights

**URL:** <https://discourse.processing.org/t/need-a-hint-about-lights/13073>\
**Category:** Coding Questions\
**Created:** [July 30, 2019, 10:09pm UTC](https://discourse.processing.org/t/need-a-hint-about-lights/13073 "2019-07-30T22:09:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![LuckSmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lucksmith/32/5805_2.png) [@LuckSmith](https://discourse.processing.org/u/LuckSmith)\
**Post date:** [July 30, 2019, 10:09pm UTC](https://discourse.processing.org/t/need-a-hint-about-lights/13073/1 "2019-07-30T22:09:17Z")

</div>

![2019730233541](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/de97cf27dc92fa622dfc68bf512f5cf76538b0b1.jpeg)

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!

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [July 31, 2019, 11:48am UTC](https://discourse.processing.org/t/need-a-hint-about-lights/13073/2 "2019-07-31T11:48:23Z")

</div>

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](http://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

---

<div class="post-metadata">

**Author:** ![LuckSmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lucksmith/32/5805_2.png) [@LuckSmith](https://discourse.processing.org/u/LuckSmith)\
**Post date:** [July 31, 2019, 6:57pm UTC](https://discourse.processing.org/t/need-a-hint-about-lights/13073/3 "2019-07-31T18:57:28Z")

</div>

Thank you, [Chrisir](https://discourse.processing.org/u/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)

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [July 31, 2019, 7:31pm UTC](https://discourse.processing.org/t/need-a-hint-about-lights/13073/4 "2019-07-31T19:31:43Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![LuckSmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lucksmith/32/5805_2.png) [@LuckSmith](https://discourse.processing.org/u/LuckSmith)\
**Post date:** [July 31, 2019, 8:24pm UTC](https://discourse.processing.org/t/need-a-hint-about-lights/13073/5 "2019-07-31T20:24:20Z")

</div>

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

 ![201973122557-l-nl](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/2821b9778e440ca6f012ec4df364733e9c78ed4c.jpeg)

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [August 6, 2019, 11:33am UTC](https://discourse.processing.org/t/need-a-hint-about-lights/13073/6 "2019-08-06T11:33:33Z")

</div>

In general I prefer with lights ()

Slower but better shadows and change of color of surfaces

still not solving your main question

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [August 11, 2019, 4:23pm UTC](https://discourse.processing.org/t/need-a-hint-about-lights/13073/7 "2019-08-11T16:23:27Z")

</div>

You had a question about lights

Maybe this (or quark) can help you:

see [3D shape with a bad seam](https://discourse.processing.org/t/3d-shape-with-a-bad-seam/13218/16)

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [August 11, 2019, 5:35pm UTC](https://discourse.processing.org/t/need-a-hint-about-lights/13073/8 "2019-08-11T17:35:30Z")

</div>

> [@LuckSmith](#):
>
> 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?

You might look at [lightFalloff](https://processing.org/reference/lightFalloff_.html)

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

---

<div class="post-metadata">

**Author:** ![LuckSmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lucksmith/32/5805_2.png) [@LuckSmith](https://discourse.processing.org/u/LuckSmith)\
**Post date:** [August 11, 2019, 10:55pm UTC](https://discourse.processing.org/t/need-a-hint-about-lights/13073/9 "2019-08-11T22:55:12Z")

</div>

Thank you, guys! [Chrisir](https://discourse.processing.org/u/Chrisir) [quark](https://discourse.processing.org/u/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 🙂

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).
