Light mesh up from the inside

Hi team,
I’m currently working on a torch mesh with a pointLight light source attached near the top…
Is there any setting / possible to light up a mesh from the inside? (mesh using PBR material)

Do i have to use the unlit setting?
While this would be possible, it will not look good when taking into consideration:
Changes in PointLight intensity and color (flickering),
and especially external light sources that should also be able to affect the mesh.

Hello,

Is the effect you want to achieve something like this torch? A central emissive area (highlighted in red) that affects the rest of the mesh?

This effect would be more directly translated into an area light

which is not available in Babylon as of now. But you could try a variety of methods to “emulate” this area light effect, like baking lightmaps into the torch mesh, and maybe some volumetric light? Volumetric Light Scattering Post Process | Babylon.js Documentation (babylonjs.com)

1 Like

@PatrickRyan might also have some good tips

Hi @carolhmj !
Apologies, I just realized i should have specified that it’s a medieval style torch :smiley:
It has to be dynamic lighting, it can move around and the plan is to also cast shadows.

This is the progress right now (turning on & off the light) with unlit material while animating the intensity of the light together with material albedoColor (white to black)…
but it’s not very good :smiley:
About (slightly before) 4/5 into the video you can clearly see the torch go completely black as it’s turned off before the unlit property is set to false and then the external light is applied

Maybe you can use an emissive texture and use the emissive color to simulate the flickering?

1 Like

@Evgeni_Popov
Emissive looked promising, but unfortunately it won’t recieve light from external sources very well when turned off, and it’ll be too dark.

Do you recall if there is a list/array of lights currently affecting a mesh?
Edit; i found it mesh.lightSources;

I’m thinking if i could, by some kind of magic, work out a limit for the turn-off animation on the albedoColor, so if within range of an external light source, it won’t go completely black

@aWeirdo, if you want to simulate the torch always being lit, you would want to be using emissive texture and emissive color like @Evgeni_Popov mentioned. While this isn’t a torch, this demo shows blending both lit and emissive color in the same material. When the emissive strength is set to 0, it still receives light from the rest of the scene, but when the emissive is set above 0, the emissive color renders as unaffected by the scene light. Using emissive also unlocks the potential to use the glow post process which is driven by emissive color. This example uses a node material, but you can get the same effect with StandardMaterial or PBRMaterial.

The thing to remember is that albedoColor should not change based on the level of emission on your torch. Leave albedoColor alone as it will render any light which hits it normally and your torch won’t disappear. Emissive color will be a separate texture with just the light that should be mixed in with the albedo to imply the light source is coming from the flame. If you are ramping value, do it with your emissive color, not albedo.

2 Likes

To extend on @PatrickRyan reply, with regards to

I believe this is what I did for the rear and front lights of my motorcycle demo.
Press kb 1 to 4 to change the light state (from off to full on, park or dip).
Search for node ‘lamp_f0’ and children to see the assembly (with a reflector, a bulb and a glass)
As guru :wink: patrick says, emissive is key and I’m actually ‘exploding’ the texture with a level of 2 for full lights. However, since this is a PBR (metallic) material, I’m also adding directIntensity, also going way above the value of 1 (30 on full lights if I remember correctly). Finally, to complete the effect on park or dip (half lights) I also pushed the albedo level a little (1.3 or 1.4).


2 Likes

@PatrickRyan I appreciate the advice!
So far it looks like emissiveIntensity (i assume it’s the same as emissiveStrength) was the link i was missing before

The “Flickering” i mentioned earlier would more be something like this; first draft at least,

Apologies for the slow updates, been battling light settings trying to get a decent area of good light without having a too large falloff area, while also not creating a sun in the center :joy:

Update;
Let there be light :slight_smile:
Pretty happy with the result so far, could use a little bit of tweaking still.

1 Like