コード例 #1
0
    private void OnEnable()
    {
        Logger.Log("Lighting system enabled.", Category.Lighting);
        //don't run lighting system on headless
        if (GameData.IsHeadlessServer)
        {
            return;
        }

        OnLightingSystemEnabled?.Invoke(true);

        if (!SystemInfo.supportsAsyncGPUReadback)
        {
            Logger.LogWarning("LightingSystem: Async GPU Readback not supported on this machine, slower synchronous readback will" +
                              " be used instead.", Category.Lighting);
        }
        HandlePPPositionRequest += ProviderPPPosition;

        // Initialize members.
        mMainCamera = gameObject.GetComponent <Camera>();

        if (mMainCamera == null)
        {
            throw new Exception("FovSystemManager require Camera component to operate.");
        }

        // Let's force camera to cull background light
        mMainCamera.cullingMask &= ~renderSettings.backgroundLayers;
        // Now validate other settings
        ValidateMainCamera(mMainCamera, renderSettings);

        if (mOcclusionRenderer == null)
        {
            mOcclusionRenderer = OcclusionMaskRenderer.InitializeMaskRenderer(gameObject, renderSettings.occlusionLayers, materialContainer.OcclusionMaskShader);
        }

        if (mLightMaskRenderer == null)
        {
            mLightMaskRenderer = LightMaskRenderer.InitializeMaskRenderer(gameObject);
        }

        if (mBackgroundRenderer == null)
        {
            mBackgroundRenderer = BackgroundRenderer.InitializeMaskRenderer(gameObject);
        }

        if (mPostProcessingStack == null)
        {
            mPostProcessingStack = new PostProcessingStack(materialContainer);
        }

        if (!renderSettings.disableAsyncGPUReadback && SystemInfo.supportsAsyncGPUReadback)
        {
            mTextureDataRequest = new TextureDataRequest();
        }

        operationParameters = new OperationParameters(mMainCamera, renderSettings, matrixRotationMode);;

        ResolveRenderingTextures(operationParameters);
    }
コード例 #2
0
    private void OnDisable()
    {
        Logger.Log("Lighting system disabled.", Category.Lighting);
        //don't run lighting system on headless
        if (GameData.IsHeadlessServer)
        {
            return;
        }

        OnLightingSystemEnabled?.Invoke(false);

        // Set object occlusion white, so occlusion dependent shaders will show appropriately while system is off.
        Shader.SetGlobalTexture("_ObjectFovMask", Texture2D.whiteTexture);

        // Default parameters to force parameters update on enable.
        operationParameters = default(OperationParameters);

        HandlePPPositionRequest -= ProviderPPPosition;

        // We can enable background layers again
        if (mMainCamera)
        {
            mMainCamera.cullingMask |= renderSettings.backgroundLayers;
        }

        if (mTextureDataRequest != null)
        {
            mTextureDataRequest.Dispose();
            mTextureDataRequest = null;
        }
    }
コード例 #3
0
    /// <summary>
    /// Handle data access callback from gpu.
    /// Wraps data request in to struct that handles protection and sampling.
    /// </summary>
    /// <param name="iRequest">requested callback to wrap.</param>
    private void AsyncReadCallback(AsyncGPUReadbackRequest iRequest)
    {
        if (iRequest.hasError || iRequest.done == false)
        {
            return;
        }

        mTextureDataRequest = new TextureDataRequest(iRequest);
    }
コード例 #4
0
    private void OnDisable()
    {
        Logger.Log("Lighting system disabled.", Category.Lighting);
        //don't run lighting system on headless
        if (GameData.IsHeadlessServer)
        {
            return;
        }
        // Set object occlusion white, so occlusion dependent shaders will show appropriately while system is off.
        Shader.SetGlobalTexture("_ObjectFovMask", Texture2D.whiteTexture);

        // Default parameters to force parameters update on enable.
        operationParameters = default(OperationParameters);

        HandlePPPositionRequest -= ProviderPPPosition;

        if (mTextureDataRequest != null)
        {
            mTextureDataRequest.Dispose();
            mTextureDataRequest = null;
        }
    }