예제 #1
0
 void OnPreRender()
 {
     m_commandBuffer.Clear();
     foreach (var projector in CommandBufferShadowManager.GetProjectorList())
     {
         m_commandBuffer.DrawMesh(m_cubeMesh, projector.GetCubeMatrix(), m_material, 0, 0, projector.GetMaterialPropertyBlock());
     }
 }
    // Use this for initialization
    void Start()
    {
        shadowMaterial = new Material(shadowShader);
        m_rendererList = rendererRoot.GetComponentsInChildren <Renderer>();

        renderTexture        = new RenderTexture(256, 256, 16, RenderTextureFormat.Depth);
        m_commandBuffer      = new CommandBuffer();
        m_commandBuffer.name = "DrawShadow";

        m_materialPropertyBlock = new MaterialPropertyBlock();

        Camera.main.AddCommandBuffer(CameraEvent.AfterForwardOpaque, m_commandBuffer);

        CommandBufferShadowManager.AddProjector(this);
    }