• 大小: 4.26MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-10-03
  • 语言: 其他
  • 标签: unity  shadowmap  

资源简介

shadow map范例,对应解释文档参考 http://blog.csdn.net/ronintao/article/details/51649664

资源截图

代码片段和文件信息

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using ShadowMap;

public class BasicShadowMap : MonoBehaviour
{

    public Gameobject sceneAABB;

    public FrustumType frustumType;

    // For Render
    public RenderTexture depthShadowMap;
    public Shader depthCaptureShader;



    // 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();
        depthCapturer.SetCaptureShader(depthCaptureShader);

        SetProjectionMatrix.Execute(lightCamera);
    }

    private void SetFitToScene(Camera lightCamera)
    {
        List sceneBoundVertexs = BoundVertexsDetector.GetSceneBoundVertexs(sceneAABB);
        SetLightCameraFrustum.SetFitToScene(lightCamera gameobject sceneBoundVertexs);
    }

    private void SetFitToView(Camera lightCamera Camera viewCamera)
    {
        List sceneBoundVertexs = BoundVertexsDetector.GetSceneBoundVertexs(sceneAABB);
        List viewBoundVertexs = BoundVertexsDetector.GetPerspectiveCameraFrustumVertexs(viewCamera);
        SetLightCameraFrustum.SetFitToView(lightCamera gameobject sceneBoundVertexs viewBoundVertexs);
    }


}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-07-07 11:08  ShadowMap\
     目录           0  2016-07-05 10:42  ShadowMap\.vs\
     目录           0  2016-07-05 10:42  ShadowMap\.vs\ShadowMap\
     目录           0  2016-07-05 10:44  ShadowMap\.vs\ShadowMap\v14\
     文件       77824  2016-07-06 17:02  ShadowMap\.vs\ShadowMap\v14\.suo
     目录           0  2016-07-05 18:28  ShadowMap\Assets\
     目录           0  2016-07-05 18:26  ShadowMap\Assets\00 Ref Scene\
     文件         192  2016-07-05 18:25  ShadowMap\Assets\00 Ref Scene.meta
     文件       16952  2016-07-05 18:26  ShadowMap\Assets\00 Ref Scene\unity ref.unity
     文件         175  2016-07-05 18:26  ShadowMap\Assets\00 Ref Scene\unity ref.unity.meta
     目录           0  2016-07-06 16:00  ShadowMap\Assets\01 Basic ShadowMap\
     文件         192  2016-07-05 10:37  ShadowMap\Assets\01 Basic ShadowMap.meta
     文件       18928  2016-07-05 14:20  ShadowMap\Assets\01 Basic ShadowMap\01 Basic ShadowMap.unity
     文件         175  2016-07-05 15:34  ShadowMap\Assets\01 Basic ShadowMap\01 Basic ShadowMap.unity.meta
     文件        1593  2016-07-05 14:50  ShadowMap\Assets\01 Basic ShadowMap\BasicShadowMap.cs
     文件         263  2016-07-05 10:41  ShadowMap\Assets\01 Basic ShadowMap\BasicShadowMap.cs.meta
     文件         503  2016-07-06 16:00  ShadowMap\Assets\01 Basic ShadowMap\CaptureDepth.cs
     文件         263  2016-07-05 14:09  ShadowMap\Assets\01 Basic ShadowMap\CaptureDepth.cs.meta
     文件         210  2016-07-05 10:59  ShadowMap\Assets\01 Basic ShadowMap\FrustumType.cs
     文件         263  2016-07-05 11:01  ShadowMap\Assets\01 Basic ShadowMap\FrustumType.cs.meta
     目录           0  2016-07-06 16:00  ShadowMap\Assets\01 Basic ShadowMap\Helper\
     文件         192  2016-07-05 10:41  ShadowMap\Assets\01 Basic ShadowMap\Helper.meta
     文件        1965  2016-07-06 14:27  ShadowMap\Assets\01 Basic ShadowMap\Helper\BoundVertexsDetector.cs
     文件         263  2016-07-05 11:07  ShadowMap\Assets\01 Basic ShadowMap\Helper\BoundVertexsDetector.cs.meta
     文件         839  2016-07-05 14:45  ShadowMap\Assets\01 Basic ShadowMap\Helper\CreateCamera.cs
     文件         263  2016-07-05 10:54  ShadowMap\Assets\01 Basic ShadowMap\Helper\CreateCamera.cs.meta
     文件        1774  2016-07-06 16:00  ShadowMap\Assets\01 Basic ShadowMap\Helper\SetLightCameraFrustum.cs
     文件         263  2016-07-05 11:36  ShadowMap\Assets\01 Basic ShadowMap\Helper\SetLightCameraFrustum.cs.meta
     文件         842  2016-07-06 15:30  ShadowMap\Assets\01 Basic ShadowMap\Helper\SetProjectionMatrix.cs
     文件         263  2016-07-05 14:50  ShadowMap\Assets\01 Basic ShadowMap\Helper\SetProjectionMatrix.cs.meta
     文件        4892  2016-07-05 15:06  ShadowMap\Assets\01 Basic ShadowMap\Scene.mat
............此处省略1673个文件信息

评论

共有 条评论