06. Baked Lighting with Blender in BabylonJS

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 พ.ค. 2024
  • Lighting is one of the most expensive aspects of interactive 3d scenes in regards to performance. Understanding how to bake lighting will not only greatly improve the visual quality of your lit environments but they'll be more performant as well.
    For this video, we'll be utilizing Blender as our 3d application to bake out lighting using the Cycles render engine. Baking can be a tedious and sometimes confusing process, so we'll go step by step on how to set this up with just a few objects. We'll discuss tips and tricks on how to quickly pack UVs for baking, improve the baked texture quality as well as how to export the final scene as a .glb with baked lighting implemented to be used in BabylonJS.
    Chapters:
    0:00 Intro
    0:32 Blender Overview
    3:30 Understanding UVs
    5:27 Creating the Bake Image
    7:26 Creating Secondary UVs for Baking
    8:35 Combining UV Maps
    14:10 Updating Materials for Baking
    15:48 Render Settings for Baking
    18:37 Baking the Texture
    19:08 Improving Bake Quality
    21:37 Rendering with the Compositor
    23:48 Utilizing Baked Texture with Material
    27:37 Export GLB File
    29:14 Importing File Into BakedLighting Class
    Github Code Repository (06_Baked_Lighting): github.com/Babylon-Projects/B...
    Blender: www.blender.org/
    BabylonJS: www.babylonjs.com/
    Poly Haven Assets:
    Marble Bust: polyhaven.com/a/marble_bust_01
    Floor Tiles: polyhaven.com/a/floor_tiles_02
    #babylonjs #blender #tutorial

ความคิดเห็น • 29

  • @theman7050
    @theman7050 หลายเดือนก่อน

    This video should go down in history. :)
    I had always wanted to know how come the real estate models look so realistic. They cheated LIGHT!!

  • @jiluen
    @jiluen ปีที่แล้ว +2

    This is a gold mine of information, thank you sir!
    It's hard to find much ressource on the worflow to bake light for blender to gltf, this video nails it.

    • @CodeSmall
      @CodeSmall  ปีที่แล้ว

      Glad you liked it!

  • @pavelleonov1042
    @pavelleonov1042 2 ปีที่แล้ว +3

    Thank you for Babylon.JS video sires. It's perfect! You are rock!♥♥♥

  • @ruzzifer
    @ruzzifer 2 ปีที่แล้ว +2

    cool! I've been looking for this for a long time

    • @CodeSmall
      @CodeSmall  2 ปีที่แล้ว

      Glad you enjoy it!

  • @user-iy2jb8st3u
    @user-iy2jb8st3u 2 ปีที่แล้ว

    感谢分享,视频对我非常有帮助👍👍👍

  • @BeattapeFactory
    @BeattapeFactory 2 ปีที่แล้ว +1

    dope. thanks

  • @Constantinesis
    @Constantinesis 2 ปีที่แล้ว

    Hello! This is the best explanation i`v seen about UV mapping and baking. I am new to exporting gltf for web rendering or gaming . I want to make sure i understand the workflow about baking: You use the different texture maps in order to bake a single texture and then you replace all the original maps with that one texture in order to properly export a gltf model? I ask this because on the gltf documentation website, it sais that you can also export the Base Color, Metallic, Roughness, Ambient Occlusion, Emissive , as separate maps through the RGB channels. With the exception of the lights which is more obvious as they are not dynamic when you bake, Is there a quality or performance difference between baking and exporting those original maps "unbaked" or it actually depends on the engine and the platform that will be used on?

    • @CodeSmall
      @CodeSmall  2 ปีที่แล้ว +1

      In the video I mostly focused on baking for lights and shadows. You'll notice that I didn't replace some of the other textures, only the color/emission textures. That in itself allows us to save on performance with lighting since I don't need dynamic lights anymore.
      You can take it a step forward and bake out all your textures onto one texture map and utilize one material for everything. That's a bit more tedious and time consuming but would be better for performance.I'd like to explore that technique in a future video on performance optimization with assets. In general the less you need to pack into a glb/gltf the smaller the file and improved performance.

    • @Constantinesis
      @Constantinesis 2 ปีที่แล้ว

      @@CodeSmall @Code-Small Thanks for replying! Does it mean that you actually didn't bake all those channels? You only baked the lights? I ask this because I see they were all checked and the Baking mode was set to Combined. Is there a different procedure?

    • @CodeSmall
      @CodeSmall  2 ปีที่แล้ว +1

      @@Constantinesis With the baked combined you get most of those channels included but it also has its limitations since it's one combined texture. In the video, I only used the baked texture for diffuse/emission and kept the original Metallic/Roughness/Normal maps that were included previously. That texture couldn't be used for the normal maps as it's a different type of texture map and if you try to use it with the roughness you may also see it doesn't work properly. Within Blender, you can set the bake type to different types of maps as well such as normal, roughness, ambient occlusion, etc. Baking really starts to make a big difference when you have multiple objects. You could have multiple texture maps such as Metallic, Rough, Normal, AO, etc but they could all be baked textures from all objects in the scene using the same technique in the video. Those textures would all be shared by all the objects and you can create a single material that uses all those texture maps. The combined bake just makes it easy to get most of what you'd want in one texture.

  • @thomasluk4319
    @thomasluk4319 ปีที่แล้ว

    Thanks! it helps me a lot for the bake setup, instead of exporting the whole pj, how can I export the items that I want?

    • @thomasluk4319
      @thomasluk4319 ปีที่แล้ว

      i got some weird black line and black spot in my light texture...

    • @jongonzalez3998
      @jongonzalez3998 ปีที่แล้ว

      To export specific objects from a Blender scene you need to select it. A orange outline will appear, then go to export the glb. There will be a checkbox on export that says “selected objects”. This will export only what was selected.

  • @timvw01
    @timvw01 ปีที่แล้ว

    Worked great, my computer is so much slower though😂 is there any benefit to doing it into one texture vs having seprate textures in terms of workflow / babylon performance?

    • @CodeSmall
      @CodeSmall  ปีที่แล้ว +1

      Well the less textures you use the less memory needed to allocate those resources. That and just having one texture to use is much simpler. You can definitely use multiple textures to get more fine control over them.

  • @qepri
    @qepri 2 ปีที่แล้ว

    It is possible to bake animated lightings?

    • @CodeSmall
      @CodeSmall  2 ปีที่แล้ว +2

      Baked animations are really only done when you have a complex animation such as fluid simulations or physics involved. Baked animations would also be static, so playing them would always look the same (no interactions). If you have an animated character or animated objects that you can interact with, I would import those separately from a scene (that has baked lighting) and used dynamic lights specifically for that animated object. I may go over this process in a future video on how to combine baked/dynamic lighting for BabylonJS.

  • @ArnavSingh-im5bj
    @ArnavSingh-im5bj 2 ปีที่แล้ว +1

    Can you please do the same in unity, I mean bake in blender and then import in unity. I don't know how to use light probe in case of imported light map

    • @CodeSmall
      @CodeSmall  ปีที่แล้ว

      For Unity you’d save the baked textures from Blender then use them on an unlit material. Its nearly identical but more of a manual process.

    • @ArnavSingh-im5bj
      @ArnavSingh-im5bj ปีที่แล้ว

      @@CodeSmallThanks for reply but with unlit material, player's shadow won't be drawn. I am thinking about using lit material with light map in the emission slot, do you think that will work? If not please help.

    • @CodeSmall
      @CodeSmall  ปีที่แล้ว

      Baked textures are meant to be used on static objects. If its a moving character use dynamic lighting for them. I believe Unity has a mixed lighting setup for using baked and dynamic lights. Thats beyond the scope of this video so you’ll need to experiment.

    • @ArnavSingh-im5bj
      @ArnavSingh-im5bj ปีที่แล้ว

      @@CodeSmall no, you misread my reply, shadow of a non static object can't be drawn on a unlit material, that is my problem. I am not talking about using baked texture on non static objects

    • @CodeSmall
      @CodeSmall  ปีที่แล้ว +1

      @@ArnavSingh-im5bj That's why I mentioned the mixed lighting, which allows baked lighting with dynamic lights. You'll have to experiment with different shaders and lighting modes. You can use a PBR material with the texture for both albedo and emission then play around with the emission strength.

  • @hindahmed2686
    @hindahmed2686 11 หลายเดือนก่อน

    Is this Woking in maya 3d?

  • @bestapps4709
    @bestapps4709 ปีที่แล้ว

    Do you know how to use .obj file bro?