Jump to content

[SOLVED] Wall lamp .gltf with emissive texture doesn't light wall, floor


vtange
 Share

Recommended Posts

Hello everyone!

I'm trying to learn how emissive textures work in BJS, and through this tutorial (https://github.com/KhronosGroup/glTF-Blender-Exporter/blob/master/docs/user.md) managed to get a Blender model with an emissive texture (basically itself) loaded in BJS as a .gltf model.

However, even though in Blender's Cycles Render I can see some illumination from the light on the wall, I don't get any lighting in BJS. Why is that?

Also, is there a setting, in Blender and in BJS, that controls the range/brightness of the light? I'd light it bright enough to light the floor :)

sconce.thumb.png.f911cd901972abd370d09dd34ffff157.png

Here's the bare-bones playground:

https://playground.babylonjs.com/#F2H81M

Link to comment
Share on other sites

Hi vtange.  I'm pretty sure that using ONLY an emissiveTexture... cannot light-up nearby 'other things'.  You need to have a light inside the mesh... to get "real" lighting, and with it, shadowCasting power.

But, there's a "cheat" way.  https://playground.babylonjs.com/#F2H81M#1

There is your scene.... with a highlightLayer activated.  No light is inside the sconce.  It won't light-up anything, but it does add a "backlighting" effect that is pretty decent.

https://playground.babylonjs.com/#F2H81M#2

There is one with a real pointLight near or inside the sconce.  I did some experimenting with its range... sort of failed.  But, I turned-off the hemi light and let ONLY the pointLight... light the scene.

It manages to light-up the front of the column and the floor.  Not too bad. 

If you have a long hallway/street lined with lights like these... you may need to do some work or light faking (painting light glows onto your textures), which i think is called baked lightMaps).  There is a 4-lights-per-single-material limit in webGL, as far as i know.  Anyway, I am rushed for time atm, but will be back in a while.  Now you have some things to think about and play-with.

I'm curious... when you saw light-on-the-column in Blender, did you have a real light inside the sconce?

It is rare/impossible for an emissiveTexture to "cast" light, as far as I know.  But, I'm old, and I don't stay very aware of newest GL features.  We'll talk.  :)

Link to comment
Share on other sites

Hi Wingnut.

The Highlight layer trick is pretty neat! It certainly makes the sconce look more like how I originally envisioned it.

It now just needs to light up that side of the wall/the ground below.

So emissiveTextures aren't as strong as I thought...I was hoping I didn't have to rely on adding lots of lights in a scene. (The playground we have here is a small piece of a larger room with multiple columns and sconces.) My worry is relying on a pointLight for every lamp might impact performance...plus I read somewhere that materials in BJS only react to 4 light sources?? Wouldn't that mean that given a room I can only have four columns with lights?

EDIT: I was writing this post as I read your reply, so I might really have to do this "light baking" trick... Do you know of any good examples of this in .gltf? I somehow doubt it's just throwing in an emissive layer on every texture. Plus it'd get annoying to have to do the column AND the floor separately.

Funnily enough I don't even know why Blender showed the illumination. There was literally no light in the sconce mesh. The .blend file is literally 3 objects: the floor, column, and light. You can check the hierarchy on the upper right

blender.thumb.png.d489d37f3ef86015325db83102b1304f.png

Edited by vtange
finished reading Wingnut's post
Link to comment
Share on other sites

How exactly does the highlight system work and how does it affect performance?

I was just tinkering around and realized hey, maybe I could do a map-wide mesh that's invisible but emits a "shadow" highlight with a dark grey color or something, and have the rest of the map be bright-as-heck. Wouldn't that work?

EDIT1: First failed try with new "shadow" object. I tried to be clever and make the "shadow" mesh have inverted normals on purpose to make it invisible. Maybe inverted normals mean highlights don't get triggered? https://playground.babylonjs.com/#F2H81M#4

Link to comment
Share on other sites

2 hours ago, vtange said:

materials in BJS only react to 4 light sources?

Hi again, vtange.  I think that is a webGL limit, not necessarily BJS framework.  Still, there is something happening with BJS... material.maxSimultaneousLights.  Setting it to 10 seems to be about max, before the shaders start producing errors. 

https://playground.babylonjs.com/#F2H81M#3

There, I managed to get 9 spotlights shining against the side of the brick column.

20 minutes ago, vtange said:

How exactly does the highlight system work and how does it affect performance?

Do I LOOK like the author and chief custodian of the highlightLayer feature?  heh.

https://github.com/BabylonJS/Babylon.js/blob/master/src/Layer/babylon.highlightlayer.ts

http://doc.babylonjs.com/how_to/highlight_layer

That's how I learn about things.  Docs and source.

As far as performance, it all depends upon what platform you are testing-upon.  You can use the profiling tools in most browsers... to do performance testing.

HighlightLayer is a 2D post-processing effect, and thus is under difficult depth-rendering challenges.  Unexpected results can happen when two highLit mesh... overlap.  SOme relief might be found... by placing multiple highlightLayers on different scene layerMasks or renderID's/renderGroups.  I don't know much about that, either, but there's plenty of playgrounds to search.

Good luck, stay in touch.

Link to comment
Share on other sites

A little thought:  Sometimes this 4-lights-per-material thing is a bit difficult to grasp.

Let's say the flooring to your "Great Hall" is made-up of 8-planes.  Identical or different materials can be put on each "tile", and the texture can look perfectly seamless, and yet... its 8 different materials.

So... using light ranges, .includedMesh, .excludedMesh, you can "think optimized".   Your sconce light really only needs to shine on the floor tile(s) BENEATH IT.  Unlikely more than 2-of-8 floor sections will have receive light from any ONE sconce.  SO, no problems.  These sconce lights don't have much range... and you don't want them to.

SO, put LOTS of mesh into a light excludedMeshes array.  Light ONLY what needs lit... for max perf.  Ok, bye again.  :)

Link to comment
Share on other sites

4 minutes ago, Wingnut said:

A little thought:  Sometimes this 4-lights-per-material thing is a bit difficult to grasp.

Let's say the fooring to your "Great Hall" is made-up of 8-planes.  Identical or different materials can be put on each "tile", and the texture can look perfectly seamless, and yet... its 8 different materials.

So... using lihgt ranes, .includedMesh, .excludedMesh, you can "think optimized".   You sconce light really only needs to shine on the tile(s) BENEATH IT.  Unlikely more than 2-of-8 floor sections will have receive light from any ONE sconce.  SO, no problems.  These sconce lights don't have much range... and you don't want them to.

SO, put LOTS of mesh into a light.excludedMeshes array.  Light ONLY what needs lit... for max perf.  Ok, bye again.  :)

Got it. I hadn't thought of this, but yeah I have a "great hall" that's currently one big mesh. Fortunately the flooring is tiled so it is possible to do what you mentioned.

In Blender do the materials have to literally be different, but using the same texture, or does BJS only care about lighting on a mesh-to-mesh basis? If this is the case then all my columns should be fine as is; since they are separate instances in the "great hall", and have enough distance that other lights don't affect them.

Haha I didn't know that BJS even had a mesh-highlighting feature until you told me about it, naturally I'd think you know quite a bit on it.

Link to comment
Share on other sites

33 minutes ago, vtange said:

In Blender do the materials have to literally be different, but using the same texture, or does BJS only care about lighting on a mesh-to-mesh basis?

I think... different material, but they can use same texture.  I know very little about Blender.  But, you might wish to model-up a scene in BJS/playground... that is similar to "great hall"... and do some experiments.  I am not experienced with advanced lighting, and I could easily tell you something that is incorrect.

http://www.html5gamedevs.com/topic/22238-why-the-4-light-limit-edit-limit-has-been-increased/?do=findComment&comment=127257

Looks like the 16 light and 24 light demo is working, but not the 32.  hmm.

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