Example #1
0
    public PixelPerfectRT Render(
        Camera iCameraToMatch,
        PixelPerfectRTParameter iPPRTParameter,
        PixelPerfectRT iOcclusionMask,
        RenderSettings iRenderSettings,
        bool iMatrixRotationMode)
    {
        // Arrange.
        Vector2 _renderPosition;

        if (iMatrixRotationMode == false)
        {
            _renderPosition = iPPRTParameter.GetFilteredRendererPosition(iCameraToMatch.transform.position, mPreviousCameraPosition, mPreviousFilteredPosition);
        }
        else
        {
            // Note: Do not apply PixelPerfect position when matrix is rotating.
            _renderPosition = iCameraToMatch.transform.position;
        }

        mPreviousCameraPosition   = iCameraToMatch.transform.position;
        mPreviousFilteredPosition = _renderPosition;

        mMaskCamera.enabled            = false;
        mMaskCamera.backgroundColor    = Color.black;
        mMaskCamera.transform.position = _renderPosition;
        mMaskCamera.orthographicSize   = iPPRTParameter.orthographicSize;
        mMaskCamera.cullingMask        = iRenderSettings.lightSourceLayers;

        if (mPPRenderTexture == null)
        {
            mPPRenderTexture = new PixelPerfectRT(iPPRTParameter);
            mPPRenderTexture.renderTexture.filterMode = FilterMode.Bilinear;
        }
        else
        {
            mPPRenderTexture.Update(iPPRTParameter);
        }

        // Arrange Occlusion RT
        iOcclusionMask.renderTexture.filterMode = FilterMode.Bilinear;
        Shader.SetGlobalTexture("_FovExtendedMask", iOcclusionMask.renderTexture);

        // Note: We need to override mLightPPRT position for transformation, because new position for mLightPPRT will be set during light rendering.
        Shader.SetGlobalVector("_FovTransformation", iOcclusionMask.GetTransformation(mPPRenderTexture, _renderPosition));

        // Execute.
        mPPRenderTexture.Render(mMaskCamera);

        return(mPPRenderTexture);
    }
Example #2
0
    public PixelPerfectRT Render(
        Camera iCameraToMatch,
        PixelPerfectRTParameter iPPRTParameter,
        bool iMatrixRotationMode)
    {
        // Arrange.
        Vector2 _renderPosition;

        if (iMatrixRotationMode == false)
        {
            _renderPosition = iPPRTParameter.GetFilteredRendererPosition(iCameraToMatch.transform.position, mPreviousCameraPosition, mPreviousFilteredPosition);
        }
        else
        {
            // Note: Do not apply PixelPerfect position when matrix is rotating.
            _renderPosition = iCameraToMatch.transform.position;
        }

        mPreviousCameraPosition   = iCameraToMatch.transform.position;
        mPreviousFilteredPosition = _renderPosition;

        mMaskCamera.enabled            = false;
        mMaskCamera.backgroundColor    = new Color(0, 0, 0, 0);
        mMaskCamera.transform.position = _renderPosition;
        mMaskCamera.orthographicSize   = iPPRTParameter.orthographicSize;

        if (mPPRenderTexture == null)
        {
            mPPRenderTexture = new PixelPerfectRT(iPPRTParameter);
        }
        else
        {
            mPPRenderTexture.Update(iPPRTParameter);
        }

        // Execute.
        mPPRenderTexture.Render(mMaskCamera);

        return(mPPRenderTexture);
    }