Swapping Lightmaps In Realtime

  Рет қаралды 17,570

Birdmask Studio

Birdmask Studio

Күн бұрын

Link to example project: birdmaskstudio.itch.io/unity3...
Link to full video on using Lightmaps: • Lightmapping Done In 9...
Link to my game Vampire Heist: birdmaskstudio.itch.io/vampir...
Took a while but here it is, my video on swapping lightmap and probes on specific objects and areas in runtime in the Unity3D engine, hopefully this helps anyone wanting to do this in their games.
This video is shoot off of another video I did 'Lightmapping Done In 9 Minutes + Switching On and Off In Realtime', if you want a quick crash course of applying lightmaps and post processing effects to make you scene look better check it out.
Timestamps:
How It Works - 00:32
Swapping Lightmaps - 01:00
Updating Light Probes - 02:00
The Result - 03:04
How To Set It Up - 03:25
Final Word Stick Around - 05:18
If you liked this video, please give us a like and subscribe and check out my video game releases on my site birdmaskstudio.itch.io/. While I don’t make videos too often, if there is something I do people would like to see, let me know and i’ll see what I can do.
Thanks for watching and reading down here.
Twitter; / birdmaskstudio
Website; www.birdmaskstudio.com/
Itchio Page; birdmaskstudio.itch.io/
GameJolt Page; gamejolt.com/@BirdmaskStudio
Facebook Page; / birdmaskstudio

Пікірлер: 42
@erz3030
@erz3030 3 жыл бұрын
This is shockingly useful, thanks for the work mate, cheers!
@joshuareeves9985
@joshuareeves9985 3 жыл бұрын
Well done! Wish Unity had this feature built in. So useful to have multiple performant versions of a level that don't need dynamic lights moving around.
@bnjmo
@bnjmo 3 жыл бұрын
This is gold! Thank you for your great work!
@HAXZingTERR0R
@HAXZingTERR0R 3 жыл бұрын
I was going nuts wondering why my culling mask wasn't working on baked lighting. After some research, culling masks don't work on baked lighting, so I thought about generating two light maps and just switching between them to accomplish what I was trying to do. And that brings me to here... Thank you!
@shadmanarko7398
@shadmanarko7398 4 жыл бұрын
Thank you very much. I have waited for this video for 1 month
@Maufdiot
@Maufdiot 3 жыл бұрын
Your a legend in my book !
@Klash120
@Klash120 4 жыл бұрын
Stellar stuff!
@amal_joy_
@amal_joy_ 3 жыл бұрын
amazing work.. thank you
@MikeTheAnomaly
@MikeTheAnomaly 2 жыл бұрын
So helpful!
@ColeWithAGoal
@ColeWithAGoal 2 жыл бұрын
Awesome, thanks for the share! :)
@fabfab408
@fabfab408 3 жыл бұрын
Thanks ! that's awesome !
@maurofuentes8076
@maurofuentes8076 3 жыл бұрын
AWESOME!!!!
@petereldredge2329
@petereldredge2329 4 жыл бұрын
This is fantastic! Thanks so much and for actually teaching the concepts. Are there any restrictions on using/tweaking this code?
@BirdmaskStudio
@BirdmaskStudio 4 жыл бұрын
Thanks! Glad you liked the video. No restrictions on using the code from the example project for your own work. I want people to be able to just be able to use this without having to worry about it.
@sean8306
@sean8306 3 жыл бұрын
Looks awesome! and sorry to ask the same question. But this is completely royalty free and can be used in commercial projects?
4 жыл бұрын
hello!! thanks a lot for the tool :) would there be any way to just remove the lightmaps but keeping the lightprobe data? doesn't matter if it's at runtime or not.
@chicoB001
@chicoB001 3 жыл бұрын
Can this work with Bakerys Lightmapping tools in unity?
@tufanaydin6340
@tufanaydin6340 7 ай бұрын
You guys are great! but after import it gives this message "Assets\AlternativeLights\Editor\Editor_AlternateBakedLight.cs(147,29): error CS0117: 'Handles' does not contain a definition for 'DrawSphere'" using Unity 2022.3.15
@huxi26
@huxi26 5 ай бұрын
replace it with SphereHandleCap
@1wdc
@1wdc 3 жыл бұрын
I ran into an issue, not sure if I'm the only one but it seems like there's an off by one error in the code. On Line 70 of AlternativeLightsManager it checks if l_dir.Length >= i, then if it is it tries to access l_dir[i], which will return an IndexOutOfRange exception if i == l_dir.Length. I think the check should be l_dir.Length > i for that reason, but it's kind of weird no one else brought it up so maybe I'm doing something wacky (I don't have any directional maps, so l_dir.Length of 0 is returning the error).
@disdathit
@disdathit Жыл бұрын
Hey there and thanks very much for this, it's very useful. Do you know if it is possible to apply a saved lightmap, to a model which is loaded at runtime? I have tried a little test in your scene (and my own). For example, bake a light map onto an object in the scene. I then delete the model/gameobject, then add the gameobject back in to the scene. But unfortunately, the lightmap is no longer affecting the mesh. I assume because the lightmap contains a reference to the specific deleted gameobject. Any ideas if there is a way round this?
@BirdmaskStudio
@BirdmaskStudio Жыл бұрын
So it's been a while since I've looked at the lightmapping system - I can't say for sure but, if I were to try and find a way to do this I think I would look to shaders. My understanding is when unity bakes a scene, it basically makes a 2nd set of UV coordinates (different from the models main UV coordinates used for texture mapping) that it uses to get and overlay the lightmap texture. So if you had a way to; 1 - Copy the lightmap UV coordinates of the baked version of the object. 2 - Apply said saved lightmap UV coordinates onto your generated object. Then you would just need a custom shader that directly overlaid the lightmap texture onto the object, regardless of whether it was static or not. Like I said I've not looked into it so I can't say any of that is doable or would lead anywhere, It's just where I would start. I would like to look at this tool again and add some more features sometimes, like the one you've just mentioned, but in all honestly won't have the time to do that anytime soon.
@disdathit
@disdathit Жыл бұрын
Thanks very much for the reply! And i'm glad you did, because i forgot to reply myself... I've actually found the solution! Here: github.com/laurenth-personal/lightmap-switching-tool Basically it's a script which you attach to the object you intend to bake. Then, a new option appears in Asset menu (next to file). Click bake from there. Then, drag the now baked object into your project files as a prefab. Now whenever you drag this prefab into the scene, it remembers the baked lighting :) Awesome! I still have hurdles with my project, but that's my problem! Basically main thing is i don't know how apply saved lightmap to a scene which has none. But i think your project hopefully has that information in there somewhere. I'm going to show it to my developer friend tomorrow to get advice. Thanks again! :) Super chuffed you replied.
@tanujcherian3911
@tanujcherian3911 Жыл бұрын
@@disdathit Hey Man....was wondering if the link you posted supports unity 2020 versions and up?
@disdathit
@disdathit Жыл бұрын
@@tanujcherian3911 i believe so yes. Give it a go!
@muhammadumair6306
@muhammadumair6306 4 жыл бұрын
Is there any overhead of changing lightmaps at runtime for mobile devices? Can we use this tool for mobile devices? I mean real-time changing like switching on and off lights of rooms?
@BirdmaskStudio
@BirdmaskStudio 4 жыл бұрын
Honestly I don't do much with mobile so I can't really say, the tool is free to use and download if you want to test it out. I can't think of any reason it wouldn't work with mobile, but in case it doesn't and you need an alternative, I talk about using projectors in my other lightmaps video as a way to darken areas in realtime. Sorry I couldn't give you any specific info on this, good luck with your work.
@CHEEZEyCHEEZE
@CHEEZEyCHEEZE 3 жыл бұрын
I love this. Only issue I see is that my project is currently purple textures and some of the code is giving me errors because DrawSphere is not recognized in 2020.2.3f1. I will try rolling back my project until at least 2019 LTS and see if that fixes some of the issues. Going back to 2019 LTS it fixed some of the issues like depreciated DrawSphere for the GUI. But everything is still missing textures in the sample Scene. It seems that each room is missing "The associated script can not be loaded. Please fix any compile errors and assign a valid script." After reviewing the video I noticed I didn't have ProBuilder installed. That fixed the issue. It is working now. Still getting a null pointer for the two Void Objects for the scripts that are missing there. What were the scripts?
@MrSmileyturnsgrumpy
@MrSmileyturnsgrumpy 2 жыл бұрын
From looking at the project and lil clips of the video, I'm pretty certain the reason you're getting the Magenta Materials and missing scripts is because the sample scene was made with ProBuilder. You should be able to add any old material to the mesh renders no worries. Also to fix the deprecated sphere handles, change Handles.DrawSphere to Handles.SphereHandleCapand add EventType.Repaint as a fourth parameter
@disdathit
@disdathit Жыл бұрын
@@MrSmileyturnsgrumpy Hi there and thanks for this! I tried swapping out the references of "Handles.DrawSphere" to "Handles.SphereHandleCap", (in the "Editor_AlternateBakedLight.cs" file), but then got the following error: "There is no argument given that corresponds to the required formal parameter 'eventType' of 'Handles.SphereHandleCap(int, Vector3, Quaternion, float, EventType)' " Any ideas? Also i do not know what adding a fourth parameter means :( I would appreciate any help!
@disdathit
@disdathit Жыл бұрын
@@MrSmileyturnsgrumpy I worked it out! It means, add "EventType.Repaint" as a 4th 'thing' (lol) in the brackets which appear after Handles.DrawSphere / Handles.SphereHandleCap. Thanks for this! Hopefully i can get it working :/
@ParallaxDev
@ParallaxDev Жыл бұрын
@@disdathit its not Handles.DrawSphere anymore thats deprecated, its now Handles.SphereHandleCap and your fourth parameter got rid of the errors!
@Beikenost
@Beikenost 2 жыл бұрын
This is perfect and professionally made! But i have an issue though; I have a building with a lot of static objects. Is there a way to group them all up with a parent and only apply the alternate baked light script on a single object instead of every single one? EDIT i fixed it (Just edit the "AlternateBakedLight.cs" script): Turn the "rend" variable into an array: private MeshRenderer[] rend; In the start method, do this instead: rend = GetComponentsInChildren(); In the ChangeLightState method, do this instead: for (int i = 0; i < rend.Length; i++) { rend[i].lightmapIndex = currentLightState; } Finally: Place the "AlternateBakedLight.cs" on a empty parent object housing your changable objects. Hope this helps. Thanks again for this amazing tool!
@ItssVenom
@ItssVenom 2 жыл бұрын
This is exactly what I was looking for. Thank you!!
@zellator
@zellator Жыл бұрын
Thanks!! :)
@randomstuff6786
@randomstuff6786 5 ай бұрын
Thank so much!
@schizoscope8703
@schizoscope8703 2 жыл бұрын
Thank you very much. It wierd Unity has not this function by default.
@Shiffo
@Shiffo 3 ай бұрын
Isn’t this coming to unity 6 now ?
@3rdAxis
@3rdAxis 2 жыл бұрын
I just downloaded the example project and tried loading it up using the asset manager and I'm running into some problems. I get this error in the console : Assets\AlternativeLights\Editor\Editor_AlternateBakedLight.cs(147,29): error CS0117: 'Handles' does not contain a definition for 'DrawSphere' Also I get errors on the _Set Room objects that say the Script is missing. I also uploaded a youtube video to demonstrate the problem. kzfaq.info/get/bejne/ptKcnNln1te3pqM.html Any help would be much appreciated.
@nickolas6060
@nickolas6060 Жыл бұрын
No reflection probes ??? Hmm
@xtoc
@xtoc Жыл бұрын
Hi, I purchased it, but the lightprobes isn't working anymore. Could you help me with it? I updated it to Handles.SphereHandleCap, but the probes are still not working when using the edit mode.
Lightmapping Done In 9 Minutes + Switching On and Off In Realtime
8:28
Best KFC Homemade For My Son #cooking #shorts
00:58
BANKII
Рет қаралды 70 МЛН
EVOLUTION OF ICE CREAM 😱 #shorts
00:11
Savage Vlogs
Рет қаралды 10 МЛН
Red❤️+Green💚=
00:38
ISSEI / いっせい
Рет қаралды 89 МЛН
Little girl's dream of a giant teddy bear is about to come true #shorts
00:32
A new way to generate worlds (stitched WFC)
10:51
Watt Designs
Рет қаралды 520 М.
The Best Games from GMTK Game Jam 2021
20:05
Game Maker's Toolkit
Рет қаралды 1,3 МЛН
I could NEVER finish a game UNTIL THIS...
9:17
DevWhale
Рет қаралды 53 М.
When Your Game Is Bad But Your Optimisation Is Genius
8:52
Vercidium
Рет қаралды 1,4 МЛН
If You Can't Make Games After This Video, Give Up
4:37
Fredyy
Рет қаралды 844 М.
I Made a Game Where You Scam a Scammer - GMTK Game Jam 2023
9:30
Lightmapping Tips and Tricks in Unity3D
12:41
Skookum Arts
Рет қаралды 30 М.
Unity in 100 Seconds
2:45
Fireship
Рет қаралды 1,1 МЛН
Beginner GameDev Mistakes - Ep 1
6:40
Shaun Spalding
Рет қаралды 162 М.
Brawl Stars Animation: PAINT BRAWL STARTS NOW!
0:52
Brawl Stars
Рет қаралды 6 МЛН