[Solved] Light emitting Material Possible?

Hi!



Long time lurker, first poster here …



I have a question:



Is it possible for a material to emit light ( and affect/lit up other objects in the scene ) without using manually a point light ?



My problem is i have a semi tile based application where i use different materials for different tiles ( all tiles are a box-like base mesh ) i have land, water, stone etc.

I try to make a lava lake in there with the lava lighting up the tiles next to it. I know about Glow ( as it seems it just affects the object itself) and Bloom ( which affects other objects but only at a small degree ), but none of them work for me. Maybe just i do something wrong.



This is my Lava material:

[java]

Material Lava : Common/MatDefs/Light/Lighting.j3md {



MaterialParameters {

GlowMap : Textures/Ground/Lava/glow.jpg

GlowColor : 2.0 1.6 1.1 1.0

DiffuseMap : Textures/Ground/Lava/diffuse.jpg

UseMaterialColors : true

Shininess : 1.0

Ambient: 2.0 1.8 1.1 1.0

Diffuse: 1.4 1.0 1.0 1.0

Specular: 1.4 1.0 1.0 1.0

}

AdditionalRenderState {

FaceCull Back

}

}

[/java]



And an another - but related - question:



How can i make light stopped by objects ? Like Objects behind objects shouldnt receive light, only the object infront of the light.



Hope that somebody can help.

For the first, look for “glow maps” in the wiki, you can assign a map with parts of the model that are supposed to glow. And for the second, thats actually not so easy, you can try ordering the nodes and lights so that only those parts of the scene are lit that are supposed to. Say if you have two rooms and the light shines over, attach one room to one node and the other to another and then put the light for each room to the node its attached to instead of the root node.

2 Likes

Thank you for the reply, i already tried glow maps ( from this article: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:bloom_and_glow )



Here is a screenshot:

Dropbox - Error



The tiles in the middle ( and the lava itself too ) are lit by a Point Light attached to the mouse, but the lava itself doesnt emit any light ( the front faces facing the camera next to the lava are all dark )



Regarding to your answer to my second question which one is resource wide better:

  • Attaching 64x64 Geometries to 64x64 different Nodes

    or
  • Creating one (map) node and attaching all 64x64 tiles to this Node ( which is what i done currently )



    (the light is attached to the root node in the image above and it moves with the mouse)

Well, you could apply a softer glow to parts that are lit but you are right, it doesn’t really work like a normal light source. To get this effect most convincingly I’d suggest using baked lightmaps, the blender wiki page has a tutorial for that. But from the screenshot it looks like your game is somewhat procedural in which case you should generate the meshes yourself, you could do the same for lightmaps that you assign to the material.

1 Like

yeah it is procedural,

i tried once to attach one pointlight to any lava tile automatically ( in the map loader ) where i was rewarder with an out of heap memory exception ( tried it with maximum lava tiles ) so i knew this isnt the way…



Im generating the meshes programatically ( actually later i plan to changing their geometry depending on whats next to them individually )



Do you think that lightmaps could solve my issue with lighting up surrondings of the tile ?



Can u give me an example how to deal with lightmaps in jme ? ( i have friends who deal with blender and ill ask them tomorrow for help from that side )



Thanks in advance.

If using lots of real lights in a scene you need to look at things like deferred rendering.



For baked in lighting essentially you just calculate your light at the same time you generate your world. You then render out that lighting information (usually into a texture) and apply that texture to your objects…so they get the glow applied ahead of time.

1 Like

Minecraft and similar have actually no real lighting, they propagate the light for each air tile furhter with a darken amount untill it is zero. Then they just store the light for each surface lit.

1 Like

I agree with zarch. Creating a sort of baked light texture and applying it to the ground would seem like a great way to go.

Not sure how to do the baking tho…

1 Like

Thanks guys, i will try then the baked light texture path…



(and marked the thread solved as it answered my questions )