コード例 #1
0
    void SetupTpData(Transform t)
    {
        if (t.GetComponent <Renderer>() == null)
        {
            return;
        }
        var tpData = t.GetComponent <TriplanarData>();

        if (tpData == null)
        {
            tpData = t.gameObject.AddComponent <TriplanarData>();
            tpData.forwardInfo.position      = Vector3.forward;
            tpData.forwardInfo.verticalFov   = textureCam.fieldOfView;
            tpData.forwardInfo.horizontalFov = textureCam.fieldOfView * textureCam.aspect;

            tpData.rightInfo.position      = Vector3.right;
            tpData.rightInfo.verticalFov   = textureCam.fieldOfView;
            tpData.rightInfo.horizontalFov = textureCam.fieldOfView * textureCam.aspect;

            tpData.upInfo.position      = Vector3.up;
            tpData.upInfo.verticalFov   = textureCam.fieldOfView;
            tpData.upInfo.horizontalFov = textureCam.fieldOfView * textureCam.aspect;

            tpData.triplanarMaterial = new Material(triplanarShader);

            tpData.forward            = this.tpData.forward ?? new Texture2D(256, 256);
            tpData.forward.filterMode = FilterMode.Point;

            tpData.right            = this.tpData.right ?? new Texture2D(256, 256);
            tpData.right.filterMode = FilterMode.Point;

            tpData.up            = this.tpData.up ?? new Texture2D(256, 256);
            tpData.up.filterMode = FilterMode.Point;

            tpData.offset = t.position - this.transform.position;
        }
    }
コード例 #2
0
 void CopyToTpTextures(TriplanarData tpData)
 {
     Graphics.CopyTexture(forwardRTex, tpData.forward);
     Graphics.CopyTexture(rightRTex, tpData.right);
     Graphics.CopyTexture(upRTex, tpData.up);
 }