Hersir Posted November 9, 2017 Share Posted November 9, 2017 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. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted November 9, 2017 Share Posted November 9, 2017 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; } } Quote Link to comment Share on other sites More sharing options...
Hersir Posted November 9, 2017 Author Share Posted November 9, 2017 Ok weird, looks the same setup, but somehow for me it doesn't show up for objects that have PBRMetallicRoughnessMaterial, will investigate further. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted November 9, 2017 Share Posted November 9, 2017 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 Quote Link to comment Share on other sites More sharing options...
Hersir Posted November 9, 2017 Author Share Posted November 9, 2017 I get it in PBRMetallicRoughnessMaterial because its exported from 3d max in this form, but I can try to make it manual with just plain PBR to compare if that helps Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 9, 2017 Share Posted November 9, 2017 Ping @Sebavan for this: Quote PBR Materials and SHADOWS DO NOT WORK IF USING AMBIENT OCCLUSION TEXTURE Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 9, 2017 Share Posted November 9, 2017 Hello, So just to be sure, you want lightmap in the simple pbr materials ??? Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted November 10, 2017 Share Posted November 10, 2017 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: Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 10, 2017 Share Posted November 10, 2017 Ok got it , let me check. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 10, 2017 Share Posted November 10, 2017 Nothing is obvious looking at the code, could you create a small PG to repro it ? GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted November 11, 2017 Share Posted November 11, 2017 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) 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.