Jump to content

PBR and Light Maps


Hersir
 Share

Recommended Posts

Hi,

Have somebody managed to use light maps with PBR materials?

Meshes have UV2 for light map and they reuse 1 lightmapTexture , but somehow it works only for Standard materials, and not PBR, if I remove PBR shadows appear.

material.lightmapTexture = // Texture
material.lightmapTexture.coordinatesIndex = 1;
material.useLightmapAsShadowmap = true;

Is that by design? Or I am doing something wrong?

Thank you.

Link to comment
Share on other sites

2 hours ago, Hersir said:

Hi,

Have somebody managed to use light maps with PBR materials?

Meshes have UV2 for light map and they reuse 1 lightmapTexture , but somehow it works only for Standard materials, and not PBR, if I remove PBR shadows appear.


material.lightmapTexture = // Texture
material.lightmapTexture.coordinatesIndex = 1;
material.useLightmapAsShadowmap = true;

Is that by design? Or I am doing something wrong?

Thank you.

I use lightmaps on PBR materials all the time... The scene in the thread is using all Standard Materials (so that uses PBR Materials)

Note: PBR Materials and SHADOWS DO NOT WORK IF USING AMBIENT OCCLUSION TEXTURE (Ping @Deltakosh For That Issue)

FYI.... This is how I set Lightmap Texture Info in C# Toolkit Code:

 

// Lightmapping Texture
            if (hasLightmap)
            {
                var lightmap = LightmapSettings.lightmaps[lightmapIndex].lightmapColor;
                var texturePath = AssetDatabase.GetAssetPath(lightmap);
                if (!String.IsNullOrEmpty(texturePath))
                {
                    ExporterWindow.ReportProgress(1, "Dumping physical material shadow mask: " + lightmap.name);
                    babylonPbrMaterial.lightmapTexture = DumpTexture(lightmap, isLightmap: true);
                    babylonPbrMaterial.lightmapTexture.coordinatesIndex = (lightmapCoordIndex >= 0) ? lightmapCoordIndex : exportationOptions.DefaultCoordinatesIndex;
                    babylonPbrMaterial.useLightmapAsShadowmap = true;

                    babylonPbrMaterial.lightmapTexture.uScale = Tools.GetTextureScale(lightmapScaleOffset.x);
                    babylonPbrMaterial.lightmapTexture.vScale = Tools.GetTextureScale(lightmapScaleOffset.y);

                    babylonPbrMaterial.lightmapTexture.uOffset = lightmapScaleOffset.z;
                    babylonPbrMaterial.lightmapTexture.vOffset = lightmapScaleOffset.w;

                    babylonPbrMaterial.lightmapTexture.level *= lightmapScale;
                }
            }

 

Link to comment
Share on other sites

11 minutes ago, Hersir said:

Ok weird, looks the same setup, but somehow for me it doesn't show up for objects that have PBRMetallicRoughnessMaterial,  will investigate further.

I don't use PBRMetallicRoughnessMaterial... I use the Low Level PBR.Material and setup a metallic/roughness workflow...

Note if metallic and or roughness = NULL or Undefined... PBR Material will be default use a Specular Workflow... hope that helps some :)

 

Link to comment
Share on other sites

9 hours ago, Sebavan said:

Hello,

So just to be sure, you want lightmap in the simple pbr materials ???

Hey @Sebavan Dunno about Simple PBR... But using the normal Babylon.PBRMaterial either with the metallic/roughness or specular workflow, if your material is using an ambient texture (In Unity, We Map the OcclusionMap to this texture if specified) then the lightmap texture DOES NOT show. Its ONLY when trying to use BOTH ambient and lightmap textures that the shadows from the lightmap seem to get ignored (they dont show). If you simply remove the ambient texture the shadows show perfect.

Take a look at this thread for details:

 

Link to comment
Share on other sites

I actual RE-VAMPED Unity Lighting Export Settings (Unity Changed Lightmap Modes For Mixed Lights)...

Note: Unity Mixed Light Mode Must Be Set To The New 'Subtractive' Mode (NOT Baked Indirect or Shadow Mask)

The new Toolkit 3.1.044 (Alpha) will have the lighting fixes.

So to recap... All Lightmap Baking working Great...

The Toolkit now supports:

Realtime Lights - (For Realtime Shadows Only) - Light will be exported to scene

Mixed Lights - (For Realtime And Baked Shadows) - Light will be exported to scene

Baked Lights (For Baked Shadows Only - Including Area Lights) - Light will not be exported to scene

This will all the use of as many BAKING AND/OR AREA lights to get great shadows, while only Realtime and Mixed lights are exported to scene :)

Just like baking lightmaps for a native unity game. You dont do ANYTHING different (Just make sure 'Mixed Lighting Mode' is set to: Subtractive on Lighting Panel)

 

Example: (With Ambient Occlusion Maps As Well)

5a06dab449b9d_ScreenShot2017-11-11at1_09_09AM.thumb.png.57e3f87623103bf162b5a8a79a27cba5.png

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