MackeyK24 Posted October 17, 2016 Share Posted October 17, 2016 Shadows from UnityExporter not showing. The export shadows options is on but i don't see any shadows... I can manually create shadows, but i thought the exporter was supposed to create shadows for you, if you have a 'Render' component on the game object along side the MeshFilter. Or is there something i have to do thru code to enable the shadows from UnityExporter? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 17, 2016 Share Posted October 17, 2016 Hey! can you try to play with shadow bias? Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted October 18, 2016 Author Share Posted October 18, 2016 1... So is there anything that needs to be done to 'Active' the shadows created by unity exporter? or is supposed to be automatic? 2... When you say play with shadow bias, are talking about adjusting the bias on the Unity Exporter side? var generator = new BabylonShadowGenerator { lightId = GetID(light.gameObject), usePoissonSampling = light.shadows == LightShadows.Soft, mapSize = 256 + 256 * QualitySettings.GetQualityLevel(), bias = light.shadowBias / 10.0f }; 3... How do i get a reference on client client javascript side after the scene has been loaded, to the ShadowGenerator created from UnityExporter, Is there some kind of scene.getShadowGenerator() or something... So far the only way i got shadows working is to manually create on client side javascript in the scene ready event like so: float quality = 1.0f; var shadows = new BABYLON.ShadowGenerator(256 + 256 * quality, light); shadows.useBlurVarianceShadowMap = true; shadows.getShadowMap().renderList.push(cube.As<dynamic>()); Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted October 18, 2016 Author Share Posted October 18, 2016 If i am reading things right... The lower the shadow bias to 0 for it to show up... since the light shadow bias default to like 0.05... Then the shadow generator in the unity exporter should divide by 100 instead of 10... Like so: var generator = new BabylonShadowGenerator { lightId = GetID(light.gameObject), usePoissonSampling = light.shadows == LightShadows.Soft, mapSize = 256 + 256 * QualitySettings.GetQualityLevel(), bias = light.shadowBias / 100.0f }; Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted October 18, 2016 Author Share Posted October 18, 2016 Also i found the shadow generator on the light not the scene: var shadows = light.getShadowGenerator(); And i Added a field 'Map Size Factor' to the Shadow Export Section of the ExportWindow. Default ExportWindow.MapSizeFactor to '256' But now you can easily change your shadow map size from exporter by using mapSizeFactor instead of hard coding '256': var generator = new BabylonShadowGenerator { lightId = GetID(light.gameObject), usePoissonSampling = light.shadows == LightShadows.Soft, mapSize = mapSizeFactor + mapSizeFactor * QualitySettings.GetQualityLevel(), bias = light.shadowBias / 100.0f }; Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 18, 2016 Share Posted October 18, 2016 You should submit a PR Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted October 19, 2016 Author Share Posted October 19, 2016 Hey David... Is there a way to either from the UnityExport Babylon classes or in Babylon JS client, to set the Default Physics Framework? I know about scene.enablePhysics()... BUT i have went ahead and implemented Unity Exporter Physics Option. The only problem is at the UnityExporter level i can't seem to find any api to set where the framework should use OIMO or CANNON. By default it seems to use CANNON. But i want to give the option on the Unity Exporter Window to specify which physics to use. Using my new exporter physics stuff you can now easily just add a 'BabylonPhysicsState' unity script component to your mesh in unity: using System; using UnityEngine; public sealed class BabylonPhysicsState : MonoBehaviour { public float mass = 0.0f; public float friction = 0.2f; public float restitution = 0.2f; public BabylonPhysicsImposter imposter = BabylonPhysicsImposter.None; } Then the SceneBuilder.Meshes ConvertUnityMeshToBabylon: // Babylon Physics if (exportationOptions.ExportPhysics) { var physics = gameObject.GetComponent<BabylonPhysicsState>(); if (physics != null) { babylonMesh.physicsMass = physics.mass; babylonMesh.physicsFriction = physics.friction; babylonMesh.physicsRestitution = physics.restitution; babylonMesh.physicsImpostor = (int)physics.imposter; } } Using 'BabylonPhysicsImposter' enums in the Unity Inspector: public enum BabylonPhysicsImposter { None = 0, Sphere = 1, Box = 2, Plane = 3, Mesh = 4, Cylinder = 7, Particle = 8, Heightmap = 9 } And is all kicked off from SceneBuilder ConvertFromUnity: // Babylon Physics if (exportationOptions.ExportPhysics) { babylonScene.physicsEnabled = true; babylonScene.physicsGravity = exportationOptions.Gravity.ToFloat(); } This works great... No need to manually call scene.enablePhysics from code OR mesh.setPhysicsState. But would be REAL NICE if i could do: babylonScene.physicsEngine = "oimo" at the UnityExporter level or at least a engine.setDefaultPhysicsEngine("oimo")... Or something like that. Right now, using my built-in unity exported physics will ONLY use cannon.js NOTE: I will be push all this to a github Pull Request after i done cleaning up a few things. So far i got: 1... Manifest export support 2... Unity Meta Data Support (including unity tags and layers) 3... Extended shadow export options 4... Babylon Physics State Script Component 5... Abstract base class 'BabylonGameComponent' to support custom babylon client side game components classes. public abstract class BabylonGameComponent : MonoBehaviour { internal const string DEFAULT_GAME_COMPONENT = "System.Default.Component"; [Unity3D2Babylon.ReadOnly] public string babylonClass; protected BabylonGameComponent() { this.babylonClass = BabylonGameComponent.DEFAULT_GAME_COMPONENT; } } You can them make custom scripts in unity and attach to components like normal, including Meshes, Cameras, Lights and Empty GameObjects: using UnityEngine; using System.Collections; public class MyRotator : BabylonGameComponent { public MyRotator() { this.babylonClass = "My.Custom.RotatorClass"; } [BabylonProperty] public float speed; } I think its SWEET Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted October 19, 2016 Author Share Posted October 19, 2016 A couple screen shots Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 19, 2016 Share Posted October 19, 2016 I'm not opposed to this idea, we could add this at scene level. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted October 21, 2016 Author Share Posted October 21, 2016 I don't know how to change the src to make default physics engine at the scene level. You (or someone who knows the codebase) will have to do that... PLEASE 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.