Exemplo n.º 1
0
    private void Capture()
    {
        Camera viewCamera = Camera.main;

        MinMax[]         depthRanges;
        List <Vector3>[] splitBounds = SplitScene.Execute(mSceneBoundVertexs, viewCamera, mRelativeSplitArray, out depthRanges);

        for (int i = 0; i < splitBounds.Length; i++)
        {
            mLightCamera.targetTexture = mDepthMaps[i];

            SetLightCameraFrustum.SetFitToView(mLightCamera, mLightObj, mSceneBoundVertexs, splitBounds[i]);
            mLightCamera.RenderWithShader(mCaptureShader, "RenderType");

            Shader.SetGlobalFloat("_shadowDepth" + i, ToCameraShaderDepth(depthRanges[i].min, viewCamera));
            Shader.SetGlobalTexture("_shadowDepthMap" + i, mDepthMaps[i]);
            SetProjectionMatrix.Execute(mLightCamera, "_LightProjection" + i);
        }
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        Camera lightCamera = CreateCamera.Execute(gameObject, depthShadowMap);
        Camera viewCamera  = Camera.main;

        if (frustumType == FrustumType.FIT_TO_SCENE)
        {
            SetFitToScene(lightCamera);
        }
        else
        {
            SetFitToView(lightCamera, viewCamera);
        }

        CaptureDepth depthCapturer = lightCamera.gameObject.AddComponent <CaptureDepth>();

        depthCapturer.SetCaptureShader(depthCaptureShader);

        SetProjectionMatrix.Execute(lightCamera);
    }