private void OnTriggerStay(Collider other)
    {
        //衝突座標(ワールド座標)
        var hitPos = other.ClosestPointOnBounds(transform.position);
        //ワールド座標からローカル座標に変換
        var hitLocalPos = transform.InverseTransformPoint(hitPos);

        //pをuvに変換して代入 成功したら実行
        if (LocalPointToUV(hitLocalPos, out var uv))
        {
            //衝突時に使用するUpdateZone
            //衝突した箇所を更新の原点とする
            //使用するパスも衝突用に変更
            var interactiveZone = new CustomRenderTextureUpdateZone
            {
                needSwap         = true,
                passIndex        = 1,
                rotation         = 0f,
                updateZoneCenter = new Vector2(uv.x, 1 - uv.y),
                updateZoneSize   = new Vector2(_ripppleSize, _ripppleSize)
            };

            _customRenderTexture.SetUpdateZones(new CustomRenderTextureUpdateZone[] { _defaultZone, interactiveZone });
        }
    }
    private void OnTriggerStay(Collider other)
    {
        //衝突座標(ワールド座標)
        //ClosestPointOnBoundsは正確な値を返さなかったのでオブジェクトのバウンズの原点を使う
        var hitPos = other.bounds.center;

        hitPos.y = transform.position.y;
        //ワールド座標からローカル座標に変換
        var hitLocalPos = transform.InverseTransformPoint(hitPos);

        //pをuvに変換して代入 成功したら実行
        if (LocalPointToUV(hitLocalPos, out var uv))
        {
            var boundsSize = other.bounds.size;
            var planeScale = transform.localScale;

            //衝突時に使用するUpdateZone
            //衝突した箇所を更新の原点とする
            //使用するパスも衝突用に変更
            var interactiveZone = new CustomRenderTextureUpdateZone
            {
                needSwap         = true,
                passIndex        = 1,
                rotation         = 0f,
                updateZoneCenter = new Vector2(uv.x, 1 - uv.y),
                //汚いけどこれで丁度良い感じの範囲が凹む
                updateZoneSize = new Vector2(boundsSize.x * 1 / planeScale.x * 0.1f, boundsSize.z * 1 / planeScale.z * 0.1f)
            };

            _customRenderTexture.SetUpdateZones(new CustomRenderTextureUpdateZone[] { _defaultZone, interactiveZone });
        }
    }
    //--------------functions-----------------
    //placeprobe
    void placeProbe()
    {
        ProbeArray = new GameObject[ProbeNumber];
        int midcell = Cellsize / 2;

        Debug.Log("placeprobe");

        IndirectionProbeAtlas.ClearUpdateZones();
        CustomRenderTextureUpdateZone[] ProbeTexture = new CustomRenderTextureUpdateZone[ProbeNumber];

        for (int i = 0; i < ProbeNumber; i++)
        {
            int x = i / 16;
            int y = i % 16;
            //Debug.Log(i);

            ProbeArray[i] = GameObject.CreatePrimitive(PrimitiveType.Sphere);            //new GameObject();
            ProbeArray[i].transform.position = new Vector3((x * Cellsize) + midcell, 0, (y * Cellsize) + midcell);

            //setup atlas textures
            int halftile = AtlasTileSize / 2;
            int xt       = (x * AtlasTileSize) + halftile;
            int yt       = (y * AtlasTileSize) + halftile;
            ProbeTexture[i].updateZoneSize   = new Vector3(AtlasTileSize, AtlasTileSize, 0);
            ProbeTexture[i].updateZoneCenter = new Vector3(xt, yt, 0);
        }
        IndirectionProbeAtlas.SetUpdateZones(ProbeTexture);
    }
Beispiel #4
0
    /// <summary>
    /// クリックした箇所を起点に特定の領域のみ指定したパスでシミュレートさせる
    /// </summary>
    private void UpdateZonesClickArea()
    {
        bool leftClick = Input.GetMouseButton(0);

        if (!leftClick)
        {
            return;
        }

        var ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out var hit))
        {
            //クリック時に使用するUpdateZone
            //クリックした箇所を更新の原点とする
            //使用するパスもクリック用に変更
            var clickZone = new CustomRenderTextureUpdateZone
            {
                needSwap         = true,
                passIndex        = 1,
                rotation         = 0f,
                updateZoneCenter = new Vector2(hit.textureCoord.x, 1f - hit.textureCoord.y),
                updateZoneSize   = new Vector2(_ripppleSize, _ripppleSize)
            };

            _customRenderTexture.SetUpdateZones(new CustomRenderTextureUpdateZone[] { _defaultZone, clickZone });
        }
    }
Beispiel #5
0
    void UpdateZones()
    {
        bool leftClick  = Input.GetMouseButton(0);
        bool rightClick = Input.GetMouseButton(1);

        if (!leftClick && !rightClick)
        {
            return;
        }

        RaycastHit hit;
        var        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit))
        {
            var defaultZone = new CustomRenderTextureUpdateZone();
            defaultZone.needSwap         = true;
            defaultZone.passIndex        = 0;
            defaultZone.rotation         = 0f;
            defaultZone.updateZoneCenter = new Vector2(0.5f, 0.5f);
            defaultZone.updateZoneSize   = new Vector2(1f, 1f);

            var clickZone = new CustomRenderTextureUpdateZone();
            clickZone.needSwap         = true;
            clickZone.passIndex        = leftClick ? 1 : 2;
            clickZone.rotation         = 0f;
            clickZone.updateZoneCenter = new Vector2(hit.textureCoord.x, 1f - hit.textureCoord.y);
            clickZone.updateZoneSize   = new Vector2(0.0025f, 0.01f);

            texture.SetUpdateZones(new CustomRenderTextureUpdateZone[] { defaultZone, clickZone });
        }
    }
Beispiel #6
0
    // enum LMGBtexture{
    //  albedo = 0,
    //  worldNormal = 1,
    //  worldPosition = 2,
    //  shadowMasking = 3
    // }
    #endregion

    //--------------functions-----------------
    void placeProbe()
    {
        //set slots parameters
        ProbeArray = new GameObject[ProbeNumber];
        int midcell = Cellsize / 2;

        //texture zones data
        IndirectionProbeAtlas.ClearUpdateZones();
        CustomRenderTextureUpdateZone[] ProbeTexture = new CustomRenderTextureUpdateZone[ProbeNumber];

        for (int i = 0; i < ProbeNumber; i++)
        {
            int x = i / 16;
            int y = i % 16;

            //create slots primitive
            ProbeArray[i] = GameObject.CreatePrimitive(PrimitiveType.Sphere);            //new GameObject();
            ProbeArray[i].transform.position = new Vector3((x * Cellsize) + midcell, 0, (y * Cellsize) + midcell);
            ProbeArray[i].SetActive(false);

            //create atlas textures zones
            int halftile = AtlasTileSize / 2;
            int xt       = (x * AtlasTileSize) + halftile;
            int yt       = (y * AtlasTileSize) + halftile;
            ProbeTexture[i].updateZoneSize   = new Vector3(AtlasTileSize, AtlasTileSize, 0);
            ProbeTexture[i].updateZoneCenter = new Vector3(xt, yt, 0);
        }
        //initialize the texture zones
        IndirectionProbeAtlas.SetUpdateZones(ProbeTexture);
    }
Beispiel #7
0
        void UpdateZones()
        {
            bool leftClick = Input.GetMouseButton(0);

            if (!leftClick)
            {
                return;
            }

            RaycastHit hit;
            var        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit))
            {
                var clickZone = new CustomRenderTextureUpdateZone();
                clickZone.needSwap         = true;
                clickZone.passIndex        = 1;
                clickZone.rotation         = 0f;
                clickZone.updateZoneCenter = new Vector2(center.x, center.y);
                clickZone.updateZoneSize   = new Vector2(range.x, range.y);

                var click = new Vector4(hit.textureCoord.x, hit.textureCoord.y, 0, 0);
                Debug.Log(click);
                waveMat.SetVector("_ClickPoint", click);

                texture.SetUpdateZones(new CustomRenderTextureUpdateZone[] { clickZone });
            }
        }
    void UpdateZones()
    {
        if (Input.GetMouseButton(0))
        {
            RaycastHit hit;

            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            //cast a ray to see if hit surface, apply deformation if hit water
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.gameObject.tag == "Water")
                {
                    CustomRenderTextureUpdateZone zone = new CustomRenderTextureUpdateZone();
                    zone.needSwap         = true;
                    zone.passIndex        = 0;
                    zone.rotation         = 0.0f;
                    zone.updateZoneCenter = new Vector2(0.5f, 0.5f);
                    zone.updateZoneSize   = new Vector2(1.0f, 1.0f);

                    CustomRenderTextureUpdateZone clickZone = new CustomRenderTextureUpdateZone();

                    clickZone.needSwap  = true;
                    clickZone.passIndex = 1; // Path to buffer buffer at 1 or -1
                    clickZone.rotation  = 0.0f;
                    //update the "event" in the list
                    clickZone.updateZoneCenter = new Vector2(hit.textureCoord.x, 1f - hit.textureCoord.y);
                    clickZone.updateZoneSize   = new Vector2(0.01f, 0.01f);


                    _texture.SetUpdateZones(new CustomRenderTextureUpdateZone[] { zone, clickZone });
                }
            }
        }
    }
Beispiel #9
0
    private void Update()
    {
        //if holding left click
        if (Input.GetMouseButton(0))
        {
            RaycastHit hit;

            Ray ray = cam.ScreenPointToRay(Input.mousePosition);
            //cast a ray to see if hit surface, apply deformation if hit water
            if (Physics.Raycast(ray, out hit))
            {
                GameObject target = hit.collider.gameObject;
                if (target.tag == "Water")
                {
                    CustomRenderTexture           texture = (CustomRenderTexture)target.GetComponent <Material>().mainTexture;
                    CustomRenderTextureUpdateZone zone    = new CustomRenderTextureUpdateZone();
                    zone.needSwap         = true;
                    zone.passIndex        = 0;
                    zone.rotation         = 0.0f;
                    zone.updateZoneCenter = new Vector2(0.5f, 0.5f);
                    zone.updateZoneSize   = new Vector2(1.0f, 1.0f);

                    CustomRenderTextureUpdateZone clickZone = new CustomRenderTextureUpdateZone();

                    clickZone.needSwap         = true;
                    clickZone.passIndex        = 1;//leftClick ? 1 : 2; // Path to buffer buffer at 1 or -1
                    clickZone.rotation         = 0.0f;
                    clickZone.updateZoneCenter = new Vector2(hit.textureCoord.x, 1f - hit.textureCoord.y);
                    clickZone.updateZoneSize   = new Vector2(0.01f, 0.01f);
                    texture.SetUpdateZones(new CustomRenderTextureUpdateZone[] { zone, clickZone });
                }
            }
        }
    }
Beispiel #10
0
        protected override bool ProcessNode()
        {
            // Force the double buffering for multi-pass flooding
            rtSettings.doubleBuffered = true;

            if (!base.ProcessNode())
            {
                return(false);
            }

            // Setup passes for jump flooding
            int stepCount = Mathf.CeilToInt(Mathf.Log(output.width, 2));

            CustomRenderTextureUpdateZone[] updateZones = new CustomRenderTextureUpdateZone[stepCount + 3];

            updateZones[0] = new CustomRenderTextureUpdateZone {
                needSwap         = false,
                passIndex        = 0,
                rotation         = 0f,
                updateZoneCenter = new Vector3(0.5f, 0.5f, 0.5f),
                updateZoneSize   = new Vector3(1f, 1f, 1f),
            };

            for (int i = 0; i < stepCount; i++)
            {
                updateZones[i + 1] = new CustomRenderTextureUpdateZone {
                    needSwap         = true,
                    passIndex        = stepCount - i + 1,
                    rotation         = 0f,
                    updateZoneCenter = new Vector3(0.5f, 0.5f, 0.5f),
                    updateZoneSize   = new Vector3(1f, 1f, 1f),
                };
            }
            ;

            updateZones[stepCount + 1] = new CustomRenderTextureUpdateZone {
                needSwap         = true,
                passIndex        = 1,
                rotation         = 0f,
                updateZoneCenter = new Vector3(0.5f, 0.5f, 0.5f),
                updateZoneSize   = new Vector3(1f, 1f, 1f),
            };

            // CRT Workaround: we need to add an additional pass because there is a bug in the swap
            // of the double buffered CRTs: the last pudate zone will not be passed to the next CRT in the chain.
            // So we add a dummy pass to force a copy
            updateZones[stepCount + 2] = new CustomRenderTextureUpdateZone {
                needSwap         = true,
                passIndex        = 1,
                rotation         = 0f,
                updateZoneCenter = new Vector3(0.0f, 0.0f, 0.0f),
                updateZoneSize   = new Vector3(0f, 0f, 0f),
            };

            material.SetFloat("_SourceMipCount", Mathf.Log(output.width, 2));
            output.SetUpdateZones(updateZones);

            return(true);
        }
    CustomRenderTextureUpdateZone CreateUpdateZone()
    {
        var clickZone = new CustomRenderTextureUpdateZone();

        clickZone.needSwap         = true;
        clickZone.passIndex        = 1;
        clickZone.rotation         = 0f;
        clickZone.updateZoneCenter = new Vector2(center.x, center.y);
        clickZone.updateZoneSize   = new Vector2(range.x, range.y);
        return(clickZone);
    }
Beispiel #12
0
    public void AddZone(Mode mode, Vector2 normalizedCoordinate, Vector2 size)
    {
        var zone = new CustomRenderTextureUpdateZone();

        zone.needSwap         = true;
        zone.passIndex        = (int)mode;
        zone.rotation         = 0f;
        zone.updateZoneCenter = normalizedCoordinate;
        zone.updateZoneSize   = size;

        updateZones.Add(zone);
    }
Beispiel #13
0
    CustomRenderTextureUpdateZone GenerateZone(float x, float y, float size)
    {
        var updateZone = new CustomRenderTextureUpdateZone();

        updateZone.needSwap         = true;
        updateZone.passIndex        = 1;
        updateZone.rotation         = 0f;
        updateZone.updateZoneCenter = new Vector2(x, 1f - y);
        updateZone.updateZoneSize   = new Vector2(size, size);

        return(updateZone);
    }
Beispiel #14
0
    void Start()
    {
        texture.Initialize();

        texture.material.SetVectorArray("_Array", new Vector4[1000]);

        defaultZone                  = new CustomRenderTextureUpdateZone();
        defaultZone.needSwap         = true;
        defaultZone.passIndex        = 0;
        defaultZone.rotation         = 0f;
        defaultZone.updateZoneCenter = new Vector2(0.5f, 0.5f);
        defaultZone.updateZoneSize   = new Vector2(1f, 1f);
    }
Beispiel #15
0
    CustomRenderTextureUpdateZone[] GenerateZonePack(List <Vector3> hits)
    {
        var updateZonePack = new CustomRenderTextureUpdateZone[hits.Count + 1];

        updateZonePack[0] = defaultZone; // needed for update to work properly

        for (int i = 0; i < hits.Count; i++)
        {
            updateZonePack[i + 1] = GenerateZone(hits[i].x, hits[i].y, hits[i].z * 1.5f);
        }

        return(updateZonePack);
    }
Beispiel #16
0
    void Start()
    {
        updateZones = new List <CustomRenderTextureUpdateZone>();

        defaultZone                  = new CustomRenderTextureUpdateZone();
        defaultZone.needSwap         = true;
        defaultZone.passIndex        = 0;
        defaultZone.rotation         = 0f;
        defaultZone.updateZoneCenter = new Vector2(0.5f, 0.5f);
        defaultZone.updateZoneSize   = new Vector2(1f, 1f);

        texture.Initialize();
    }
Beispiel #17
0
    private void Start()
    {
        //初期化
        _customRenderTexture.Initialize();

        //波動方程式のシミュレート用のUpdateZone
        //全体の更新用
        _defaultZone = new CustomRenderTextureUpdateZone
        {
            needSwap         = true,
            passIndex        = 0,
            rotation         = 0f,
            updateZoneCenter = new Vector2(0.5f, 0.5f),
            updateZoneSize   = new Vector2(1f, 1f)
        };
    }
Beispiel #18
0
    public static int constructor(IntPtr l)
    {
        int result;

        try
        {
            CustomRenderTextureUpdateZone customRenderTextureUpdateZone = default(CustomRenderTextureUpdateZone);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, customRenderTextureUpdateZone);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Beispiel #19
0
    public void ClearFogByBounds(Bounds bd)
    {
        Vector2 zoneCenter = bd.center / 10;

        zoneCenter += Vector2.one * 0.5f;
        Vector2 zoneSize = bd.size / 10;

        CustomRenderTextureUpdateZone clearZone = new CustomRenderTextureUpdateZone();

        clearZone.needSwap         = false;
        clearZone.passIndex        = 0;
        clearZone.rotation         = 0;
        clearZone.updateZoneCenter = zoneCenter;
        clearZone.updateZoneSize   = zoneSize;
        texture.SetUpdateZones(new CustomRenderTextureUpdateZone[] { clearZone });
        texture.Update();
    }
    void UpdateZones()
    {
        bool       leftClick  = Input.GetMouseButton(0);
        bool       rightClick = Input.GetMouseButton(1);
        var        ray        = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (!leftClick && !rightClick)
        {
            if (Physics.Raycast(ray, out hit, Mathf.Infinity, detectLayer))
            {
                Debug.DrawLine(Camera.main.transform.position, hit.point, Color.blue);
                //Debug.Log(myTexture2D.GetPixel((int)hit.point.x,(int)hit.point.z));
                //Debug.Log(new Vector2((int)hit.point.x,(int)hit.point.z));
            }
        }
        else
        {
            if (Physics.Raycast(ray, out hit, Mathf.Infinity, detectLayer))
            {
                var defaultZone = new CustomRenderTextureUpdateZone();
                defaultZone.needSwap         = true;
                defaultZone.passIndex        = 0;
                defaultZone.rotation         = 0f;
                defaultZone.updateZoneCenter = new Vector2(0.5f, 0.5f);
                defaultZone.updateZoneSize   = new Vector2(1f, 1f);

                var clickZone = new CustomRenderTextureUpdateZone();
                clickZone.needSwap         = true;
                clickZone.passIndex        = leftClick ? 1 : 2;
                clickZone.rotation         = 0f;
                clickZone.updateZoneCenter = new Vector2(hit.textureCoord.x, 1f - hit.textureCoord.y);
                clickZone.updateZoneSize   = new Vector2(0.01f, 0.01f);

                texture.SetUpdateZones(new CustomRenderTextureUpdateZone[] { defaultZone, clickZone });


                Debug.DrawLine(Camera.main.transform.position, hit.point, Color.red);
                // Vector2Int pointMatrix = new Vector2Int(
                //     (int)(hit.point.x + texture.width/2),
                //     (int)(hit.point.z + texture.height/2));
                //Debug.Log(myTexture2D.GetPixel(0,1));
                //Debug.Log(pointMatrix);
            }
        }
    }
Beispiel #21
0
    void Start()
    {
        center = new Vector3(5f, 0f, 5f);
        texture.initializationColor = Color.clear;
        texture.Initialize();
        texture.ClearUpdateZones();
        p.x = target.position.x * 0.1f * texture.width;
        p.y = target.position.z * 0.1f * texture.height;
        material.SetVector("_WorldPos", p);

        var defaultZone = new CustomRenderTextureUpdateZone();

        defaultZone.needSwap         = true;
        defaultZone.passIndex        = 0;
        defaultZone.rotation         = 0f;
        defaultZone.updateZoneCenter = new Vector2(0.5f, 0.5f);
        defaultZone.updateZoneSize   = new Vector2(1f, 1f);

        texture.SetUpdateZones(new CustomRenderTextureUpdateZone[] { defaultZone });
    }
    private void Start()
    {
        _meshFilter    = GetComponent <MeshFilter>();
        _meshTriangles = _meshFilter.mesh.triangles;
        _meshVertices  = _meshFilter.mesh.vertices;
        _meshUV        = _meshFilter.mesh.uv;

        //初期化
        _customRenderTexture.Initialize();

        //シミュレート用のUpdateZone
        //全体の更新用
        _defaultZone = new CustomRenderTextureUpdateZone
        {
            needSwap         = true,
            passIndex        = 0,
            rotation         = 0f,
            updateZoneCenter = new Vector2(0.5f, 0.5f),
            updateZoneSize   = new Vector2(1f, 1f)
        };
    }
Beispiel #23
0
 void UpdateZone()
 {
     if (Input.GetMouseButtonDown(0))
     {
         if (Camera.main != null)
         {
             RaycastHit hit;
             if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
             {
                 CustomRenderTextureUpdateZone clearZone = new CustomRenderTextureUpdateZone();
                 clearZone.needSwap         = false;
                 clearZone.passIndex        = 0;
                 clearZone.rotation         = 0;
                 clearZone.updateZoneCenter = new Vector2(hit.textureCoord.x, 1 - hit.textureCoord.y);
                 clearZone.updateZoneSize   = Vector2.one * 0.2f;
                 texture.SetUpdateZones(new CustomRenderTextureUpdateZone[] { clearZone });
                 texture.Update();
                 print("new zone");
             }
         }
     }
 }
Beispiel #24
0
    void UpdateZones()
    {
        customRenderTexture = GetComponent <Renderer>().sharedMaterial.mainTexture as CustomRenderTexture;
        int totalCount = zonesX * zonesY;

        zones = new CustomRenderTextureUpdateZone[totalCount];
        float size = 1 / Mathf.Sqrt(totalCount);

        for (int i = 0; i < totalCount; i++)
        {
            float xPos = i % zonesX;
            float yPos = i / zonesY;

            CustomRenderTextureUpdateZone newZone = new CustomRenderTextureUpdateZone();
            newZone.updateZoneCenter = new Vector3(xPos * size + size / 2, yPos * size + size / 2, 0);
            newZone.updateZoneSize   = new Vector3(size, size, size);
            zones[i] = newZone;
        }
        CustomRenderTextureUpdateZone[] clearZone = new CustomRenderTextureUpdateZone[1];
        clearZone[0].updateZoneCenter = new Vector2(0.5f, 0.5f);
        clearZone[0].updateZoneSize   = Vector2.zero;
        customRenderTexture.SetUpdateZones(clearZone);
    }
Beispiel #25
0
    void Start()
    {
        texture.Initialize();
        collider = GetComponent <Collider>();

        defaultZone                  = new CustomRenderTextureUpdateZone();
        defaultZone.needSwap         = true;
        defaultZone.passIndex        = 0; // integrate
        defaultZone.rotation         = 0f;
        defaultZone.updateZoneCenter = new Vector2(0.5f, 0.5f);
        defaultZone.updateZoneSize   = new Vector2(1f, 1f);

        normalZone                  = new CustomRenderTextureUpdateZone();
        normalZone.needSwap         = true;
        normalZone.passIndex        = 2; // update normals
        normalZone.rotation         = 0f;
        normalZone.updateZoneCenter = new Vector2(0.5f, 0.5f);
        normalZone.updateZoneSize   = new Vector2(1f, 1f);

        waveZone           = new CustomRenderTextureUpdateZone();
        waveZone.needSwap  = true;
        waveZone.passIndex = 1; // drop
        waveZone.rotation  = 0f;
        // waveZone.updateZoneCenter = uv;
        waveZone.updateZoneSize = new Vector2(dropRadius, dropRadius);

        var waves = new List <CustomRenderTextureUpdateZone>();

        for (int i = 0; i < initialDropCount; i++)
        {
            waveZone.updateZoneCenter = new Vector2(Random.Range(0f, 1f),
                                                    Random.Range(0f, 1f));
            // CustomRenderTextureUpdateZone is a struct so this is a copy operation.
            waves.Add(waveZone);
        }
        zones = waves.ToArray();
    }
Beispiel #26
0
    public void OnCollision(List <Ray> rays)
    {
        RaycastHit hit;

        List <Vector2> uvs = new List <Vector2>();

        foreach (var ray in rays)
        {
            if (Physics.Raycast(ray, out hit))
            {
                uvs.Add(hit.textureCoord);
            }
        }

        int hitCnt = uvs.Count;

        CustomRenderTextureUpdateZone[] updateZones = new CustomRenderTextureUpdateZone[hitCnt + 1];
        for (int i = 0; i < hitCnt; i++)
        {
            updateZones[i].needSwap         = true;
            updateZones[i].passIndex        = 1;
            updateZones[i].rotation         = 0f;
            updateZones[i].updateZoneCenter = new Vector2(uvs[i].x, 1f - uvs[i].y);
            updateZones[i].updateZoneSize   = new Vector2(0.01f, 0.01f);
            Debug.Log("bbbb");
        }


        updateZones[hitCnt].needSwap         = true;
        updateZones[hitCnt].passIndex        = 0; // 波動方程式のシミュレーションのパス
        updateZones[hitCnt].rotation         = 0f;
        updateZones[hitCnt].updateZoneCenter = new Vector2(0.5f, 0.5f);
        updateZones[hitCnt].updateZoneSize   = new Vector2(1f, 1f);


        _texture.SetUpdateZones(updateZones);
    }
Beispiel #27
0
        protected override bool ProcessNode(CommandBuffer cmd)
        {
            if (!base.ProcessNode(cmd))
            {
                return(false);
            }

            CustomRenderTextureUpdateZone[] updateZones;

            // Setup the custom render texture multi-pass for the blur:
            switch (output.dimension)
            {
            default:
            case TextureDimension.Cube:
                throw new NotImplementedException();

            case TextureDimension.Tex2D:
                updateZones = new CustomRenderTextureUpdateZone[] {
                    new CustomRenderTextureUpdateZone {
                        needSwap         = false,
                        passIndex        = 0,
                        rotation         = 0f,
                        updateZoneCenter = new Vector3(0.5f, 0.5f, 0.5f),
                        updateZoneSize   = new Vector3(1f, 1f, 1f),
                    },
                    new CustomRenderTextureUpdateZone {
                        needSwap         = true,
                        passIndex        = 1,
                        rotation         = 0f,
                        updateZoneCenter = new Vector3(0.5f, 0.5f, 0.5f),
                        updateZoneSize   = new Vector3(1f, 1f, 1f),
                    },
                    new CustomRenderTextureUpdateZone {
                        needSwap         = true,
                        passIndex        = 3,
                        rotation         = 0f,
                        updateZoneCenter = new Vector3(0.5f, 0.5f, 0.5f),
                        updateZoneSize   = new Vector3(1f, 1f, 1f),
                    },
                    // CRT Workaround: we need to add an additional pass because there is a bug in the swap
                    // of the double buffered CRTs: the last pudate zone will not be passed to the next CRT in the chain.
                    // So we add a dummy pass to force a copy
                    new CustomRenderTextureUpdateZone {
                        needSwap         = true,
                        passIndex        = 1,
                        rotation         = 0f,
                        updateZoneCenter = new Vector3(0.0f, 0.0f, 0.0f),
                        updateZoneSize   = new Vector3(0f, 0f, 0f),
                    },
                };
                break;

            case TextureDimension.Tex3D:
                updateZones = new CustomRenderTextureUpdateZone[] {
                    new CustomRenderTextureUpdateZone {
                        needSwap         = false,
                        passIndex        = 0,
                        rotation         = 0f,
                        updateZoneCenter = new Vector3(0.5f, 0.5f, 0.5f),
                        updateZoneSize   = new Vector3(1f, 1f, 1f),
                    },
                    new CustomRenderTextureUpdateZone {
                        needSwap         = true,
                        passIndex        = 1,
                        rotation         = 0f,
                        updateZoneCenter = new Vector3(0.5f, 0.5f, 0.5f),
                        updateZoneSize   = new Vector3(1f, 1f, 1f),
                    },
                    new CustomRenderTextureUpdateZone {
                        needSwap         = true,
                        passIndex        = 2,
                        rotation         = 0f,
                        updateZoneCenter = new Vector3(0.5f, 0.5f, 0.5f),
                        updateZoneSize   = new Vector3(1f, 1f, 1f),
                    },
                    new CustomRenderTextureUpdateZone {
                        needSwap         = true,
                        passIndex        = 3,
                        rotation         = 0f,
                        updateZoneCenter = new Vector3(0.5f, 0.5f, 0.5f),
                        updateZoneSize   = new Vector3(1f, 1f, 1f),
                    },
                    // CRT Workaround: we need to add an additional pass because there is a bug in the swap
                    // of the double buffered CRTs: the last pudate zone will not be passed to the next CRT in the chain.
                    // So we add a dummy pass to force a copy
                    new CustomRenderTextureUpdateZone {
                        needSwap         = true,
                        passIndex        = 1,
                        rotation         = 0f,
                        updateZoneCenter = new Vector3(0.0f, 0.0f, 0.0f),
                        updateZoneSize   = new Vector3(0f, 0f, 0f),
                    },
                };
                break;
            }

            rtSettings.doubleBuffered = true;

            // Setup the successive passes needed or the blur
            output.SetUpdateZones(updateZones);

            return(true);
        }
Beispiel #28
0
        protected override bool ProcessNode(CommandBuffer cmd)
        {
            if (!base.ProcessNode(cmd))
            {
                return(false);
            }

            CustomRenderTextureUpdateZone[] updateZones;

            // Setup the custom render texture multi-pass for the blur:
            switch (output.dimension)
            {
            default:
            case TextureDimension.Tex2D:
            case TextureDimension.Cube:
                updateZones = new CustomRenderTextureUpdateZone[] {
                    new CustomRenderTextureUpdateZone {
                        needSwap         = false,
                        passIndex        = 0,
                        rotation         = 0f,
                        updateZoneCenter = new Vector3(0.5f, 0.5f, 0.5f),
                        updateZoneSize   = new Vector3(1f, 1f, 1f),
                    },
                    new CustomRenderTextureUpdateZone {
                        needSwap         = true,
                        passIndex        = 1,
                        rotation         = 0f,
                        updateZoneCenter = new Vector3(0.5f, 0.5f, 0.5f),
                        updateZoneSize   = new Vector3(1f, 1f, 1f),
                    },
                    // CRT Workaround: we need to add an additional pass because there is a bug in the swap
                    // of the double buffered CRTs: the last pudate zone will not be passed to the next CRT in the chain.
                    // So we add a dummy pass to force a copy
                    new CustomRenderTextureUpdateZone {
                        needSwap         = true,
                        passIndex        = 1,
                        rotation         = 0f,
                        updateZoneCenter = new Vector3(0.0f, 0.0f, 0.0f),
                        updateZoneSize   = new Vector3(0f, 0f, 0f),
                    },
                };
                break;

            case TextureDimension.Tex3D:
                updateZones = new CustomRenderTextureUpdateZone[] {
                    new CustomRenderTextureUpdateZone {
                        needSwap         = false,
                        passIndex        = 0,
                        rotation         = 0f,
                        updateZoneCenter = new Vector3(0.5f, 0.5f, 0.5f),
                        updateZoneSize   = new Vector3(1f, 1f, 1f),
                    },
                    new CustomRenderTextureUpdateZone {
                        needSwap         = true,
                        passIndex        = 1,
                        rotation         = 0f,
                        updateZoneCenter = new Vector3(0.5f, 0.5f, 0.5f),
                        updateZoneSize   = new Vector3(1f, 1f, 1f),
                    },
                    new CustomRenderTextureUpdateZone {
                        needSwap         = true,
                        passIndex        = 2,
                        rotation         = 0f,
                        updateZoneCenter = new Vector3(0.5f, 0.5f, 0.5f),
                        updateZoneSize   = new Vector3(1f, 1f, 1f),
                    },
                    // CRT Workaround: we need to add an additional pass because there is a bug in the swap
                    // of the double buffered CRTs: the last pudate zone will not be passed to the next CRT in the chain.
                    // So we add a dummy pass to force a copy
                    new CustomRenderTextureUpdateZone {
                        needSwap         = true,
                        passIndex        = 1,
                        rotation         = 0f,
                        updateZoneCenter = new Vector3(0.0f, 0.0f, 0.0f),
                        updateZoneSize   = new Vector3(0f, 0f, 0f),
                    },
                };
                break;
            }

            settings.doubleBuffered = true;

            output.EnsureDoubleBufferConsistency();
            var rt = output.GetDoubleBufferRenderTexture();
            var t  = material.GetTextureWithDimension("_Source", settings.GetResolvedTextureDimension(graph));

            if (rt != null && t != null)
            {
                rt.filterMode = t.filterMode;
                rt.wrapMode   = t.wrapMode;
            }

            // Setup the successive passes needed or the blur
            output.SetUpdateZones(updateZones);

            return(true);
        }