public static Texture2D CaptureModelForNormalMap(Model model, bool isGrayscale, GameObject shadowObj) { if (Camera.main == null) { return(Texture2D.whiteTexture); } model.BackupAllShaders(); model.ChangeAllShaders(isGrayscale ? GrayscaleMapShader : NormalMapShader); if (shadowObj != null) { shadowObj.SetActive(false); } RenderTexture.active = Camera.main.targetTexture; Texture2D resultTexture = new Texture2D(Camera.main.targetTexture.width, Camera.main.targetTexture.height, TextureFormat.ARGB32, false); Color32 defaultColor = (isGrayscale ? EngineGlobal.CLEAR_COLOR32 : EngineGlobal.NORMALMAP_COLOR32); ExtractionHelper.ExtractOpqaue(ref resultTexture, defaultColor, true); RenderTexture.active = null; if (shadowObj != null) { shadowObj.SetActive(true); } model.RestoreAllShaders(); return(resultTexture); }
public static Texture2D CaptureModelInCamera(Model model, Camera camera, Studio studio, bool isShadow = false) { if (camera == null || studio.extraction.com == null) { return(Texture2D.whiteTexture); } RenderTexture.active = camera.targetTexture; Texture2D resultTexure = new Texture2D(camera.targetTexture.width, camera.targetTexture.height, TextureFormat.ARGB32, false); if (isShadow) { ExtractionHelper.ExtractInShadowCamera(camera, ref resultTexure); } else { studio.extraction.com.Extract(camera, model, ref resultTexure); } if (studio.variation.on && !isShadow) { ApplyVariation(studio.variation, ref resultTexure); } RenderTexture.active = null; return(resultTexure); }
public override void Extract(Camera camera, Model model, ref Texture2D resultTexture) { ExtractionHelper.ExtractOpqaue(ref resultTexture, EngineGlobal.CLEAR_COLOR32); }