kaitek666 Posted May 2, 2017 Share Posted May 2, 2017 Hello! I have a square surface. I wanted it to shine. Other objects around it needed to get lit by it, but.. here's a problem. Light is always round, wherever I place it. I know why, because I understand how lighting works. Here's an image showing what I mean: Is there any way to make a light emitting from a mesh, not from a point? ps. My game is in 3D. Dunno if it's important. Cheers!Kajtek Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 2, 2017 Share Posted May 2, 2017 Hiya K. One thought. You could use the BJS PolygonMeshBuilder (or CSG system - boolean subtract) (or 4-planes grouped together)... to make a plane with an any-shape hole in the middle. Now fire-up a spotlight, use it on a shadowGenerator, push the polygonMesh into the shadowMap.renderList, then shine that spotlight at/through the hole. Put that hole... directly behind a mesh, and... that SHOULD work. Don't add the mesh in front of the hole... to the shadowGenerator.shadowMap.renderList. That would block the light beam. PolygonMesh "cutout" might need .visibility = .001 or something. No promises. Might be good, might not be. Here's a possible testing playground if you need one. (I sure hope .showBoundingBox starts working again, soon. SO MANY broken playgrounds because of it, and edgesRendering, and some .visibility problems, and and and... sigh.) Party on! kaitek666 1 Quote Link to comment Share on other sites More sharing options...
gryff Posted May 3, 2017 Share Posted May 3, 2017 @kaitek666: One option you may have is found in this PG: A Light All three objects are lit by a hemispheric light. The sphere, only, is lit by a single point light. See line 31 pLight.includedOnlyMeshes.push(sphere); So if you use your example 2 - big light - you can ensure that that light only lights your square using similar type of code (Click the cube to make the light illuminate the floor too.) cheers, gryff kaitek666 1 Quote Link to comment Share on other sites More sharing options...
gryff Posted May 3, 2017 Share Posted May 3, 2017 @kaitek666: here is another option - a PG to fake lighting using the emissive color of an object A Fake Light The cube has a material but is not lit by any of the lights - so it appears black even though its diffuse color is set to red. Clicking on the cube adds a red emissive color to it. Fake lighting cheers, gryff kaitek666 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 3, 2017 Share Posted May 3, 2017 What a cool idea, Gryff! With careful use of light.includedMesh and .excludedMesh, you make it APPEAR as if the .emissive of a mesh... is shining light on other mesh. Actually, the emissive levels are used as a trigger... to add/remove meshes to/from somelight.included/excluded. Cool trickery! (I dunno if k666 needs light-dimming abilities, or just on/off) If an .emissiveTexture was used on the fake light, then fakeLight.material.emissiveTexture.level could be "bound" to reallight.intensity (in the renderLoop). Fun! Lower the emissiveTexture.level, and the renderLoop instantly converts texture.level... to a realLight.intensity setting (after a little massaging). No shadow-generating allowed from the emissive-material fake-light mesh, though. It would still need a real light... positioned in/at/near the fakeLight mesh... to do that. Still... this is an interesting idea. Opens more possibilities. Cool! BJS is SO versatile, huh? Gotta love it. It might be handy to have an emissiveColor.level, eh? But you can do that by adjusting the 3 emissiveColor Color3 values. If we allowed a Color4 as the .emissiveColor, then we could use the 4th value as the color level scaler. oooh, fancy. I tried one. Mat.emissiveColor accepts Color4 dataType just fine, but the 4th value appears to be ignored. If we COULD use 4th value as a colorScale (color .level setting)... it would HAVE TO default to 1.0 value. Otherwise, every time someone accidentally used a color4 instead of a wanted color3, the color would fail to work... due to colorLevel = 0. Fun thinkin. kaitek666 1 Quote Link to comment Share on other sites More sharing options...
gryff Posted May 4, 2017 Share Posted May 4, 2017 19 hours ago, Wingnut said: What a cool idea, Gryff! @Wingnut : not cool - just my approach. I look at some posts and I keep seeing "I want" - not my style. Me, I know what we have (well more or less) so I try to use that. Perhaps not very innovative in terms of BJS - a workaround I guess but sometimes workarounds are seeing things differently. Now I have to admit that I did ask @Deltakosh for "includedOnlyMeshes" and did suggest to @JCPalmer that maybe we could make use of Blender Layers and lighting only the current layer for "includedOnlyMeshes" In the Blender Exporter. But I would never say "I want" to those two gentlemen And of course there is Wingy - the best man at finding workarounds and PGs I know of.. Mind you the Color4 for emissiveColor with the 4th value for an intensity setting is an interesting idea Or could that be done with just changing the Color3 value? cheers, gryff kaitek666 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 4, 2017 Share Posted May 4, 2017 You're too kind, G-man. Boy, that search-in-code PG searcher feature that we recently got... that thing is just SWEET. Makes find playgrounds EASY. I think I do some of these things well... ONLY because I have no purpose in life... besides webGL. Yeah, it could be done with a color3, but you might need to set all 3 values proportionately. With a color.level, it's just a single value... acts like a light.intensity or texture.level. Then again... hmm... would .emissiveColor.scale(.9) reduce all 3 color values the same amount, and yet maintain the proportions? Let's try it... https://www.babylonjs-playground.com/#10JNZ8#4 Line 13. Chewbacca! err... youbetcha. Works fine. The scaling factor is a single number that acts just like a color.level. Coooool. I should read the docs for BJS someday. I tried animating the color scaler... with a cosine 0-2 range (see console). Failed. Surely caused by Wingnut incompetency. heh. Gryff... you contributed includedOnlyMeshes idea? Nice! That's a good one... people started using that puppy immediately. kaitek666 1 Quote Link to comment Share on other sites More sharing options...
kaitek666 Posted May 5, 2017 Author Share Posted May 5, 2017 Thanks for your answers @gryff & @Wingnut! Emissive texture/color were really helpful. But still, I cannot achieve what I wanted to @Wingnut, I tried making a mesh with a square above the tile, but I've got ~20 of them in my small map, and performance drops really hard on it. Shadows are expensive. Wish I could find a way to push to shadow render list my whole scene. I cannot, I think. @gryff, I could add some meshes to render list easily, but squares around my square are the same size, resulting in a weird, unnatural lighting around it. I appreciate your ideas, but I don't know if I'm going to find a satisfying answer for me. Sorry Thanks a lot!Kajtek Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted May 5, 2017 Share Posted May 5, 2017 Is your lighting must be realtime ? 'cause it sound like you want a precalculated lighting quality, and they're not so much options than baking lightmaps. kaitek666 1 Quote Link to comment Share on other sites More sharing options...
kaitek666 Posted May 5, 2017 Author Share Posted May 5, 2017 12 minutes ago, V!nc3r said: Is your lighting must be realtime ? 'cause it sound like you want a precalculated lighting quality, and they're not so much options than baking lightmaps. Not realtime. I will need it to be updated from time to time when environment changes, but not in real time Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted May 5, 2017 Share Posted May 5, 2017 So, let's go for texture baking I guess Quote Link to comment Share on other sites More sharing options...
kaitek666 Posted May 5, 2017 Author Share Posted May 5, 2017 3 hours ago, V!nc3r said: So, let's go for texture baking I guess I think I need some explanation Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted May 5, 2017 Share Posted May 5, 2017 Which soft do you use ? I can make a mini-tuto on the next few days on how to get baked lighting on BJS from Blender (or 3dsMax at worst). Meanwhile, you'll have to do some searches Quote Link to comment Share on other sites More sharing options...
kaitek666 Posted May 5, 2017 Author Share Posted May 5, 2017 @V!nc3r the problem is, these squares are meshes. It would be performance-heavy and hard to change (textures, etc. I know you can, but I don't enjoy manipulating models..) Correct me if I'm wrong, you can bake lighting only in outside software, yes? I need other tiles to be lit by this tile. I don't think this is the way to go. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.