Jump to content

Lights for my horror corridor


meteoritool
 Share

Recommended Posts

Hi !

I've tried to create a sort of long scary corridor, with a variable called "numberOfThings" which sets the number of corridor sections.

http://www.orbis-somnium.com/interdit/

I've come to problems now trying to display numerous pointLights (with a short range).

In my code you will see the "neonLightContainer" is only repeated 3 times, but it should display on each "section".
I'm aware of the "4 lights maximum per material" and I've tried many things but I really don't manage to do it ...

Some help would be highly appreciated ^_^ !

Link to comment
Share on other sites

Hiya met!

     I'm not really qualified to advise on this, but I'll try it anyway.  :)

Take a look at this beast, if you please:  http://playground.babylonjs.com/#KVRKS#6

Who says "Only 4 lights per material?", eh?  haha.  But this is all "fake".  The light circles on the roadway... they are textures... placed onto a small piece of ground that is actually part of each light pole.  I am far from a textures pro, but I just played with all sorts of texture settings and crap... til it worked.  :)  (bad policy).  I think many of the texture/material settings that I have used... aren't needed, but I'll leave that to you or other texturing experts... to clean-up, as wanted.

The green box (tbox) has a single spotlight that is told to turn-ON/OFF when the tbox is at certain positions during its animation along the roadway.  There are only 2 lights in that playground demo.

Let's think about your corridor.  I could not get your demo to run in FF or IE, so I will imagine it.  :)  At each "fake light" along your corridor, you could put one of my flare01.png images on the wall texture.  It would look like the glow was coming from the light/torch, but it's not.  As the player walked past the light location, you gently raise and lower a spotlight.intensity... on a single spotlight that is parented to the player.  He/she carries it with them, just like the spotlight carried on my tbox.

And, you could even put these "glows" onto the wall texture itself... in your 2D paint program.  I THINK that is called... "baking a lightMap"... but I'm not sure.

Let's say you DID "bake" all the light glows onto the wall texture with your paint program.  This has one disadvantage.  It is difficult to make them "flicker" if your lights are candles or torches.  But if you make each "glow" be a separate little plane that is alpha-blended into the wall texture (like I did with my demo)... then you have some options to make it flicker... by randomly setting the glow's texture.level.

Ok, I'm way outside my of expertise, here, but perhaps this will give you some more ideas that could help with your scary corridor.  Good luck, be well, keep us posted! 

Link to comment
Share on other sites

Thx for your guidance !!!

I had thought about a "static lighting" method but didn't know how to do it, the demo you linked is a very good reference, kudos !!!

Now appart from the flickering effect, I thought shadows would have been great, and static method doesn't allow that :-/

I have created many clones of a wall, and then also created clones of the wall-material, so that evey clone of the mesh has a unique material. 
I thought that would make many lights possible, but that doesn't seem to work :/

Link to comment
Share on other sites

Hey !

Thx for all you advice  ! I love this community !!!

12 hours ago, gryff said:

Have you tried using the includedOnlyMeshes and excludedMeshes. See doc here

My walls/grounds/ceilings/lightEmitters are supposed to be instances rather than clones, thus sharing each a single material.
Then I tried to use clones instead, and also created clones of the materials, and the includeOnlyMeshes, but couldn't make it work alas :/ Maybe it's my mistake with a code that starts to get a bit too complicated ...
The thing is, I realized the 4 lights limitation makes sense, because dynamic lighting does indeed use A LOT of power ...
Too bad because those dynamic lights produce a much BEAUTIFUL effect ! 

Now I'm gonna turn to a "static" lighting method, but the way to go is still a bit obscure ...
I have tried to use an opacityTexture as mask to simulate the lighting, but since you can't apply an Alpha parameter to a single texture, I couldn't find how to gradually make the opacity texture fade out ...

I've made more researches and maybe I'm gonna try to pile up meshes with different versions of the texture, and the zOffset parameter to avoid flickering.
But the thing is, in a corridor with walls, grounds, ceilings, that's gonna double the number of meshes and materials ! Plus, having to place flare and design lighting manually is gonna be quite difficult design-wise, the result won't even get close to what dynamic lighting is capable of :-/

Thx for all your answers ! The PacMan like demo is dope BTW >_< !!!

Link to comment
Share on other sites

Holy crap, DK... that is GENIUS!  What a great trick!  hahaha.  I love it.

When we did MOO's (muds/mushes)... every text-described "room"... was actually virtual, of course.  But, because command/chat-line entries like go east, go west, n, s, se, etc... were active... you would get a mental-sense of geography.  Think Infocom... such as Zork.

To get to the point, there were two "hot" sub-classes for $container...  $room, and $virtualroom.  Virtual rooms were...  more fake than standard rooms.  The user never changed "geo" locations.  Attachments from $room-class objects... to $exit's... was irrelevant and ignored.  Instead, $vroom's just kept changing the .description of the SAME room, as users command east, north, look, up, etc.

heh.  Instead of taking the user to the room, you take the room to the user.  Essentially, you send the user on a hallucination... of an entire dungeon, world, city, you name it.  The city might have NO objects... no programmatic structure.  You just paint the user's screen to make them think they have entered a new world full of objects/scenes.

DK's idea took me back to that, to then, and I had to laugh and thank him for the fun memory.

Link to comment
Share on other sites

@Wingnut moving the world rather than the character has been in question, but, in my humble opinion, this is all relative, thus result should be the same !
I have already advanced too much into this scene to rewrite the whole code ... But if I was to create a sorta "endless fall" game, I would probably move the "world" rather than the camera for sure ^_^ !!!

@Deltakosh 

On 4 mars 2016 at 6:16 PM, Deltakosh said:

if you like dynamic lighting, you can also think about moving the list with the player. As you don't need to light rooms outside of the screen :)

I have let the lighting problem aside and advanced a bit on other topics, such as animation, learnt a bit more how Blender works ...
Now I have a thing on my mind that I'd like to understand :
About the lights : I had thought about a "dynamic" array list with "includedOnlyMeshes", but at very first, I thought the "light.range" parameter would do all this automatically ... My lights repeat, but their range is quite short ... Am I wrong or right in thinking the light.distance does the "list" automatically ???

Link to comment
Share on other sites

Oooh, we're talking...  light.frustumOfEffect here.  Cooooool.  Good question/thinking, Met!  I want to learn about .range, too.  Maybe we need some testing playgrounds.  This is exciting.  Not enough users do torture-testing of lights.  I'll make the popcorn, somebody light the fire... this is going to be a FUN gathering.  :)

An automated includedOnlyMesh list adjuster, based upon .range?  Yeah!  Mad scientists on the prowl!  Hide the kids and pets, this might get ugly.  heh.

Link to comment
Share on other sites

Hi everyone !

Coming up with another question : so in my corridor, the walls, ground, and pretty much everything, is an Instance. I have lights placed here and there and a shadowGenerator.
Everything works perfect, but there is a problem when a wall, for example, gets out of screen, its shadow is no more rendered ...
I've attached a small video to show you how it's doing, thx in advance for your answers =)

 

 

 

 

IMG_1694.3gp

Link to comment
Share on other sites

2 hours ago, Deltakosh said:

Interesting!

You will have to force meshes to be rendered even when out of sight with: mesh.alwaysSelectAsActiveMesh = true when, for instance, a mesh is in a certain range from  your camera

Mmm I have tried that piece of code applied to the original mesh but that doesn't solve it, the shadow still disappears :-/ 
The problem doesn't occur when using clones instead of instances though ... Is it a normal behavior for instanced meshes ?

Link to comment
Share on other sites

Ok there I did something quick ...

http://playground.babylonjs.com/#1NLCOZ#0

this scene is weird I admit >_< I started from the shadows tutorial PG. I add a wall, then add it to the shadowmap, then create instances. The result has the same problem : shadow disappear when instanced mesh is off-screen.

Then, if I simply replace "createInstance" by "clone" ;
http://playground.babylonjs.com/#1NLCOZ#1
the behavior seems different : the shadows doesn't disappear when cloned mesh is off-screen, somehow another problem comes : cloned walls don't cast shadow properly where instances worked great for that ...

Link to comment
Share on other sites

Awesome ! :D

But this breaks my code >_< !!!
... I get an error in my browser:
babylon.js:13 Uncaught TypeError: a._preActivate is not a function
i.render @ babylon.js:13
t.render @ babylon.js:10
(anonymous function) @ index.js:149
o._renderLoop @ babylon.js:4

Look what happens if I just remove the instances from the shadowmap, the instances themselves don't show anymore :
http://playground.babylonjs.com/#1NLCOZ#4

In my humble opinion, instances should inherit the 'shadowing' of their original mesh. For example, LOD (Level Of Detail) is inherited, and that's very convenient not to have to rewrite each time. I believe it is also the case for the WaterMaterial, which doesn't require each instance to be added to to renderList, if I'm correct...

Or should I write each parameter for the first Instance, and then clone the instance itself to get inheritance of all that jazz (waterMaterial renderList, ShowMap, etc ...)

Anyway thx a lot for your work ! I hope for another fix coming soon though, because I can't play my scene anymore :/

Good Day ;-)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...