private bool Initialize() { try { if (null != pluginInterop) { pluginInterop.Dispose(); } pluginInterop = new SVFUnityPluginInterop(); #if UNITY_PS4 && !UNITY_EDITOR HCapPs4GlobalParamsInterop globalParams = new HCapPs4GlobalParamsInterop() { PlayerWorkMemorySize = 1024 * 1024 * 1024, PlayerVideoMemorySize = 512 * 1024 * 1024, AudioGranularity = 512, Audio3dAffinity = 0x40, //0b01000000, AmbisonicLevel = 3, AmbisonicCutoffRadius = 10f, }; pluginInterop.InitializeHCapPlugin(globalParams); #endif HCapSettingsInterop hcapSettings = new HCapSettingsInterop() { defaultMaxVertexCount = DefaultMaxVertexCount, defaultMaxIndexCount = DefaultMaxIndexCount, #if UNITY_PS4 StreamMode = 1, StreamCacheSize = 512 * 1024, StreamCacheNum = 12, DecodePipelineSize = 6, DemuxVideoBufferSize = 16 * 1024 * 1024, MeshDecoderAffinity = 0x30, //0b00110000 AudioDecoderAffinity = 0x3f, //0b00111111 VideoDecoderAffinity = 0x3f, //0b00111111 DemuxerAffinity = 0x3f, //0b00111111 ControllerAffinity = 0x3f, //0b00111111 StreamingAffinity = 0x3f, //0b00111111 #endif }; #if ENABLE_NATIVE_LOGGING pluginInterop.EnableTracing(true, LogLevel.Message); #endif pluginInterop.CreateHCapObject(hcapSettings); if (meshRenderer == null) { meshRenderer = GetComponent <MeshRenderer>(); } if (meshFilter == null) { meshFilter = GetComponent <MeshFilter>(); } if (HVCollider == null) { HVCollider = GetComponent <BoxCollider>(); } meshRenderer.material = material; meshFilter.mesh.bounds = localSpaceBounds; pluginInterop.SetComputeNormals(computeNormals); isInitialized = true; } catch (Exception ex) { logger.LogException(ex); isInitialized = false; return(false); } return(true); }
private bool Initialize() { try { if (null != pluginInterop) { pluginInterop.Dispose(); } UnityConfig.ConvertToRelativePath(unityConfig.VertexShaderPath); UnityConfig.ConvertToRelativePath(unityConfig.PixelShaderPath); UnityConfig.ConvertToRelativePath(unityConfig.AtlasVertexShaderPath); UnityConfig.ConvertToRelativePath(unityConfig.BBoxFrameTexturePath); UnityConfig.ConvertToRelativePath(unityConfig.BBoxClipTexturePath); pluginInterop = new SVFUnityPluginInterop(unityConfig); HCapSettingsInterop hcapSettings = new HCapSettingsInterop() { defaultMaxVertexCount = DefaultMaxVertexCount, defaultMaxIndexCount = DefaultMaxIndexCount, allocMemoryMinGb = MemorySettings.MinGbLimitHW, allocMemoryMaxGb = MemorySettings.MaxGbLimitHW }; #if ENABLE_NATIVE_LOGGING pluginInterop.EnableTracing(true, LogLevel.Message); #endif pluginInterop.CreateHCapObject(hcapSettings); pluginInterop.CleanupCommandBuffers(); //foreach (var cam in Camera.allCameras) //{ // CameraView camView = cameraViews.Find(cam, targetDevice, flipHandedness); // pluginInterop.SetCommandBufferOnCamera(cam, camView.cameraId); //} #if UNITY_5_5_OR_NEWER pluginInterop.SetZBufferInverted(true); pluginInterop.SetTextureLoadTimeout(textureLoadTimeout); AudioVolume = _audioVolume; #endif if (meshRenderer == null) { meshRenderer = GetComponent <MeshRenderer>(); } if (meshFilter == null) { meshFilter = GetComponent <MeshFilter>(); } if (HVCollider == null) { HVCollider = GetComponent <BoxCollider>(); } if (renderingMode == RenderingMode.SVFDraw) { meshRenderer.receiveShadows = false; meshRenderer.shadowCastingMode = ShadowCastingMode.Off; meshRenderer.lightProbeUsage = LightProbeUsage.Off; meshRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off; meshRenderer.materials = new Material[0]; // Mesh verts don't have to make sense for rendering in this mode, just for culling meshFilter.mesh.vertices = new Vector3[8]; meshFilter.mesh.RecalculateBounds(); } else if (renderingMode == RenderingMode.UnityDraw) { meshRenderer.material = material; meshFilter.mesh.bounds = localSpaceBounds; pluginInterop.SetUseGPU(useGPU); pluginInterop.SetComputeNormals(computeNormals); } isInitialized = true; } catch (Exception ex) { logger.LogException(ex); isInitialized = false; return(false); } return(true); }