Ejemplo n.º 1
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         pause = !pause;
     }
     UpdateZones();
     if (zones != null)
     {
         texture.SetUpdateZones(zones);
         zones = null;
         if (pause)
         {
             texture.Update(1);
         }
     }
     else
     {
         texture.SetUpdateZones(new CustomRenderTextureUpdateZone[] { defaultZone, defaultZone, normalZone });
     }
     if (!pause ||
         Input.GetKeyDown(KeyCode.N))
     {
         texture.Update(1);
     }
 }
Ejemplo n.º 2
0
    void Update()
    {
        if (handleInput)
        {
            CreatePoints();
        }

        if (null == mCrTexture || mWaveMat == null)
        {
            return;
        }

        mCrTexture.ClearUpdateZones();
        if (pointQueue.Count > 0)
        {
            var point = pointQueue.Dequeue();
            mWaveMat.SetVector("_ClickPoint", new Vector4(point.x, point.y, 0, 0));
            mCrTexture.SetUpdateZones(updateZones);
            if (point == lastPoint)
            {
                mCrTexture.Update();
            }

            lastPoint = point;
        }
        else
        {
            mCrTexture.Update();
        }
    }
Ejemplo n.º 3
0
    void Update()
    {
        texture.ClearUpdateZones();

        DetectCollision();

        if (hitList.Count > 0)
        {
            CustomRenderTextureUpdateZone[] crtuz = GenerateZonePack(hitList);
            texture.SetUpdateZones(crtuz);
            texture.material.SetFloat("_ArrayLength", directions.Count);
            texture.material.SetVectorArray("_Array", directions);
            texture.Update(iterationPerFrame);
        }
        else
        {
            texture.SetUpdateZones(new CustomRenderTextureUpdateZone[] { defaultZone });
            if (runUpdate)
            {
                texture.Update(iterationPerFrame);
            }
        }


        hitList.Clear();
        amplitudes.Clear();
        directions.Clear();
    }
Ejemplo n.º 4
0
 void Update()
 {
     if (parametersUpdatedThisFrame)
     {
         blittingTexture.shaderPass = 0;
         Vector3 center = (Mathf.Sin(rotation) * Vector3.right * 0.25f) +
                          (Mathf.Cos(rotation) * Vector3.up * 0.25f) +
                          (Vector3.one * 0.5f);
         sphereBlittingMaterial.SetVector("_Center", center);
         sphereBlittingMaterial.SetInt("_Subtraction", subtraction ? 1 : 0);
         sphereBlittingMaterial.SetFloat("_Radius", radius);
         volumeMaterial.SetFloat("_Inflation", inflation);
         blittingTexture.Update();
     }
     else
     {
         //Else just run the distance field healing shader passively
         blittingTexture.shaderPass = usePlanarRepair ? 3 : 2;
         if (repairDistanceField)
         {
             blittingTexture.Update();
         }
     }
     parametersUpdatedThisFrame = false;
 }
Ejemplo n.º 5
0
 void Update()
 {
     parametersUpdatedThisFrame = true;
     if (parametersUpdatedThisFrame)
     {
         blittingTexture.shaderPass = 0;
         rotation = (rotation + Time.deltaTime) % 6.28f;
         Vector3 center = (Mathf.Sin(rotation) * Vector3.right * 0.25f) +
                          (Mathf.Cos(rotation) * Vector3.up * 0.25f) +
                          (Vector3.one * 0.5f);
         sphereBlittingMaterial.SetVector("_Center", center);
         sphereBlittingMaterial.SetInt("_Subtraction", subtraction ? 1 : 0);
         sphereBlittingMaterial.SetFloat("_Radius", radius);
         volumeMaterial.SetFloat("_Inflation", inflation);
         blittingTexture.Update();
     }
     else if (repairDistanceField)
     {
         // Else just run the distance field healing shader passively
         // THIS IS A BROKEN TECHNIQUE, JUST USE JUMP FLOODING
         blittingTexture.shaderPass = usePlanarRepair ? 3 : 2;
         blittingTexture.Update();
     }
     parametersUpdatedThisFrame = false;
 }
Ejemplo n.º 6
0
 void Update()
 {
     _texture.ClearUpdateZones();
     UpdateZones();
     //UpdateZones(Input.mousePosition);
     _texture.Update(1);
     _normalTexture.Update(1);
     _causticTexture.Update(1);
     _texture.Update(1);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Unity coroutine. Execute the specified pass of the update material. It takes 2 frames.
        /// </summary>
        /// <param name="pass">The ID of the wanted pass</param>
        IEnumerator ExecutePass(int pass)
        {
            // Set the desired shader pass
            volumeMap.shaderPass = pass;

            // Make sure the update pass is executed on both buffers (remember it's double buffered)
            volumeMap.Update(2);
            yield return(null);                 //Wait next frame

            // Sets the default pass again
            volumeMap.shaderPass = 0;
            yield return(null);

            UpdateMap();
        }
Ejemplo n.º 8
0
        void Update()
        {
            _texture.material.SetTexture("_InputTex", _Input);
            _texture.material.SetFloat("_Laplacian", m_laplacian);
            _texture.material.SetFloat("_Curl", m_curl);
            _texture.material.SetFloat("_RotationPower", m_RotationPower);
            _texture.material.SetFloat("_Amplification", m_Amplification);
            _texture.material.SetFloat("_Diagonal", m_Diagonal);
            _texture.material.SetFloat("_LaplDivScale", m_laplDiv);
            _texture.material.SetFloat("_DivScale", m_div);
            _texture.material.SetFloat("_CenterWeight", m_centerWeight);
            _texture.material.SetFloat("_EdgeWeight", m_edgeWeight);
            _texture.material.SetFloat("_CornerWeight", m_cornerWeight);
            _texture.material.SetFloat("_InputWeight", m_InputWeight);

            _texture.material.SetFloat("_dx", m_dx / 1000);
            _texture.material.SetFloat("_dy", m_dy / 1000);

            m_material.SetFloat("_Displacement", m_displace);

            _texture.Update(_stepsPerFrame);



            if (Input.GetKeyDown(KeyCode.Space))
            {
                _texture.Initialize();
            }
        }
Ejemplo n.º 9
0
 //Updateはダメ ライフサイクル要参照
 private void FixedUpdate()
 {
     //UpdateZoneはリセット
     _customRenderTexture.ClearUpdateZones();
     //更新したいフレーム数を指定して更新
     _customRenderTexture.Update(_iterationPerFrame);
 }
Ejemplo n.º 10
0
 private void FixedUpdate()
 {
     p.x = (target.position.x + center.x) * 0.1f * texture.width;
     p.y = (target.position.z + center.z) * 0.1f * texture.height;
     material.SetVector("_WorldPos", p);
     texture.Update(0);
 }
Ejemplo n.º 11
0
 void Update()
 {
     if (onScreen || SimulateOffScreen)
     {
         Texture.Update(1);
     }
 }
Ejemplo n.º 12
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;

        if (Input.GetKey(KeyCode.Mouse0) && Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
        {
            pos.x = hit.point.x / size;
            pos.y = hit.point.z / size;

            if (Input.GetKeyDown(KeyCode.Mouse0))
            {
                oldpos = pos;
            }

            if (oldpos != pos)
            {
                angle = Vector2.SignedAngle(Vector2.up, pos - oldpos);
            }
            else
            {
                angle = 0;
            }

            PaintRenderTexture.material.SetVector("_vector", new Vector4(oldpos.x, oldpos.y, radius, Vector2.Distance(pos, oldpos)));
            PaintRenderTexture.material.SetFloat("_angle", angle);

            PaintRenderTexture.Update();
            oldpos = pos;
        }
    }
Ejemplo n.º 13
0
 void InitTexture(CustomRenderTexture texture)
 {
     texture.material.SetVector("_Position", new Vector4(hitPosition.x, hitPosition.y, 0, 0));
     texture.material.SetColor("_Color1", hitColor);
     texture.shaderPass = 1;
     texture.Update();
 }
Ejemplo n.º 14
0
    protected void FixedUpdate()
    {
#if UNITY_EDITOR
        RDP_FixedUpdate();
#endif

        if (randomize)
        {
            Randomize();

            randomize = false;
        }

        if (Parameters.hasChanged)
        {
            texture.Initialize();
            needsUpdate = true;
        }

        if (needsUpdate)
        {
            UpdateValues();
            needsUpdate = false;
        }

        if (updateRate > 0)
        {
            texture.Update(updateRate);
        }
    }
Ejemplo n.º 15
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit = new RaycastHit();

            if (Physics.Raycast(ray, out hit))
            {
                GameObject  clickedGameObject = hit.collider.gameObject;
                Vector3     localHitPos       = clickedGameObject.transform.InverseTransformPoint(hit.point);
                BoxCollider box     = clickedGameObject.GetComponent <BoxCollider>();
                float       local_x = localHitPos.x / box.bounds.size.x + 0.5f; // 正規化されたローカル空間でのクリックした位置
                float       local_z = localHitPos.z / box.bounds.size.z + 0.5f; // [0.0, 1.0]

                const float SIZE      = 3.0f;                                   // デカールのワールド空間での大きさ
                float       tex_scale = box.bounds.size.x / SIZE;               // テクスチャ空間での大きさ(の逆数)

                texture.material.SetFloat("_TexScale", tex_scale);
                texture.material.SetFloat("_OffsetX", 1.0f - local_x);// UVとローカル座標が反対だったので補正
                texture.material.SetFloat("_OffsetZ", 1.0f - local_z);
                texture.Update();

                Debug.Log(local_x + " " + local_z + " " + tex_scale);
            }
        }
    }
Ejemplo n.º 16
0
        void UpdateFluid()
        {
            if (!_initialized)
            {
                Initialize();
                return;
            }

            //Update shader time
            fluidMaterial.SetFloat("_AbsoluteTime", Time.time);

            //Update emitters
            UpdateEmittersBuffer();

            //Update fluid texture
            fluidTexture.Update(updatesPerFrame);

            //Debug
            if (reinitialize)
            {
                fluidTexture.Initialize();
                reinitialize = false;
            }

            if (showLogs)
            {
                DebugEmittersList();
            }
        }
Ejemplo n.º 17
0
    IEnumerator FractalTask()
    {
        iteration = 0;

        Vector2 drawPos  = new Vector2(5f, 5f);
        Vector2 pointPos = GetPointPosition(pointsCount);

        while (true)
        {
            drawPos += Vector2.Scale(pointPos - drawPos, new Vector2(proportion, proportion));;
            Draw(drawPos);
            IterationCounter();
            pointPos = GetPointPosition(pointsCount);
            Texture.Update();

            if (IsFast)
            {
                yield return(null);
            }
            else
            {
                yield return(new WaitForSeconds(speed));
            }
        }
    }
Ejemplo n.º 18
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();
    }
Ejemplo n.º 19
0
 private void Update()
 {
     //クリック時のUpdateZoneがクリック後も適応された状態にならないように一度消去する
     _customRenderTexture.ClearUpdateZones();
     UpdateZonesClickArea();
     //更新したいフレーム数を指定して更新
     _customRenderTexture.Update(iterationPerFrame);
 }
Ejemplo n.º 20
0
    void Update()
    {
        //Graphics.Blit(aTexture, rTex,m,-1);
        //m.SetTexture("_HeightMap",rTex);

        _texture.ClearUpdateZones();
        UpdateZones();
        _texture.Update(2);
    }
Ejemplo n.º 21
0
 // Update is called once per frame
 void Update()
 {
     _textureApproxDist.Update(1);
     _Ssed8ApproxDist.Update(1);
     _Ssed8ApproxDist5.Update(1);
     _Ssed8ApproxDist10.Update(1);
     _Ssed8ApproxDist15.Update(1);
     _Ssed8ApproxDist30.Update(1);
 }
Ejemplo n.º 22
0
        private void BlitRt(Shader shader)
        {
            var mat = EffectMaterial;

            mat.shader = shader;

            if (IsUsingCrt)
            {
                _effetBuffer.material = mat;
                _effetBuffer.Update();
            }
            else
            {
                Swap();
                Graphics.Blit(PreviousTexture, MainTexture, mat);
            }

            _onUpdated?.Invoke();
        }
Ejemplo n.º 23
0
    private void FixedUpdate()
    {
        texture.ClearUpdateZones();
        updateZones.Add(defaultZone);
        UpdateMouseClickZones();
        UpdateZones();
        updateZones.Clear();

        texture.Update(iterationPerFrame);
    }
Ejemplo n.º 24
0
        public IEnumerator Update()
        {
            writableTexture.Update();

            EditorApplication.Step();

            yield return(null);

            UpdateReadableTexture();
        }
Ejemplo n.º 25
0
    void Update()
    {
        if (position.x != transform.position.x || position.z != transform.position.z)
        {
            mapLinesMaterial.SetVector("_Coordinate", new Vector4(transform.position.x / worldSize.x,
                                                                  transform.position.z / worldSize.y, 0, 0));

            position = transform.position;
            mapLinesRenderTexture.Update();
        }
    }
 void Update()
 {
     texture.ClearUpdateZones();
     UpdateZones();
     texture.Update(iterationPerFrame);
     myTexture2D = TextureToTexture2D(texture);
     if (Input.GetKeyDown(KeyCode.Space))
     {
         texture.Initialize();
     }
 }
Ejemplo n.º 27
0
 void Update()
 {
     m_ScrollPos += Time.deltaTime * m_Scroll;
     _Input.material.SetFloat("_Scroll", m_ScrollPos);
     _Input.material.SetFloat("_Width", m_Width);
     _Input.material.SetFloat("_Type", m_Type);
     _Input.material.SetFloat("_Rotate", m_Rotate);
     _Input.material.SetFloat("_Margin", m_Margin);
     _Input.material.SetFloat("_Repeat", m_Repeat);
     _Input.material.SetFloat("_Amount", m_Amount);
     _Input.Update(1);
 }
Ejemplo n.º 28
0
    // Update is called once per frame
    void UpdateTexture()
    {
        if (m_CustomRenderTexture != null)
        {
            //m_ClearTimer += Time.deltaTime;
            //if(m_ClearTimer > m_ClearFrequency)
            //{
            //m_ClearTimer = 0.0f;
            //m_ClearColorIndex = (m_ClearColorIndex + 1 ) % 3;
            m_CustomRenderTexture.initializationColor = m_ClearColors[m_ClearColorIndex];

            if (m_CustomRenderTexture.initializationTexture == null)
            {
                m_CustomRenderTexture.initializationTexture = m_ClearTexture;
            }
            else
            {
                m_CustomRenderTexture.initializationTexture = null;
            }


            if (m_ClearColorIndex == 0 || m_ClearColorIndex == 2)
            {
                m_CustomRenderTexture.ClearUpdateZones();
            }

            m_CustomRenderTexture.material.SetFloat("_CheckerSize", m_CheckerSizes[m_ClearColorIndex]);
            m_CustomRenderTexture.Initialize();

            if (m_ClearColorIndex == 2)
            {
                m_CustomRenderTexture.material.SetFloat("_Alpha", 0.1f);
                m_CustomRenderTexture.updateMode = CustomRenderTextureUpdateMode.OnDemand;
                m_CustomRenderTexture.Update(10);
            }
            else
            {
                m_CustomRenderTexture.material.SetFloat("_Alpha", 0.005f);
                m_CustomRenderTexture.updateMode = CustomRenderTextureUpdateMode.Realtime;
            }
            //	}

            //if (m_ClearColorIndex == 1)
            //{
            //	m_UpdateZones[0].rotation = (m_UpdateZones[0].rotation + m_RotationSpeed * Time.deltaTime) % 360.0f;
            //	m_UpdateZones[1].rotation = (m_UpdateZones[1].rotation + m_RotationSpeed * Time.deltaTime) % 360.0f;
            //m_UpdateZones[0].rotation = (m_UpdateZones[0].rotation + m_RotationSpeed * factor) % 360.0f;
            // m_UpdateZones[1].rotation = (m_UpdateZones[1].rotation + m_RotationSpeed * factor) % 360.0f;
            //   m_CustomRenderTexture.SetUpdateZones(m_UpdateZones);
            //}
        }
    }
    public static CustomRenderTexture GenerateNoiseRT(NoiseType type, float scale, int width, int height, int depth = 128)
    {
        CustomRenderTexture noiseRT = new CustomRenderTexture(width, height);

        noiseRT.format               = RenderTextureFormat.ARGB32;
        noiseRT.wrapMode             = TextureWrapMode.Repeat;
        noiseRT.filterMode           = FilterMode.Bilinear;
        noiseRT.updateMode           = CustomRenderTextureUpdateMode.Realtime;
        noiseRT.initializationMode   = CustomRenderTextureUpdateMode.Realtime;
        noiseRT.initializationSource = CustomRenderTextureInitializationSource.Material;
        noiseRT.enableRandomWrite    = true;
        switch (type)
        {
        case NoiseType.PerilinNoise2D:
            noiseRT.dimension = UnityEngine.Rendering.TextureDimension.Tex2D;
            noiseRT.material  = m_perlin2D;
            noiseRT.initializationMaterial = m_perlin2D;
            noiseRT.shaderPass             = 0;
            noiseRT.material.SetFloat("_Scale", scale);
            break;

        case NoiseType.PerilinNoise2D_Tileable:
            noiseRT.dimension = UnityEngine.Rendering.TextureDimension.Tex2D;
            noiseRT.material  = m_perlin2D_Tile;
            noiseRT.initializationMaterial = m_perlin2D_Tile;
            noiseRT.shaderPass             = 0;
            noiseRT.material.SetFloat("_Scale", scale);
            break;

        case NoiseType.PerilinNoise3D:
            noiseRT.dimension              = UnityEngine.Rendering.TextureDimension.Tex3D;
            noiseRT.volumeDepth            = depth;
            noiseRT.material               = m_perlin3D;
            noiseRT.initializationMaterial = m_perlin3D;
            noiseRT.shaderPass             = 0;
            noiseRT.material.SetFloat("_Scale", scale);
            break;

        case NoiseType.PerilinNoise3D_ZLoop:
            noiseRT.dimension              = UnityEngine.Rendering.TextureDimension.Tex3D;
            noiseRT.volumeDepth            = depth;
            noiseRT.material               = m_perlin3D_ZLoop;
            noiseRT.initializationMaterial = m_perlin3D_ZLoop;
            noiseRT.shaderPass             = 0;
            noiseRT.material.SetFloat("_Scale", scale);
            break;
        }
        noiseRT.Initialize();
        noiseRT.Update();
        noiseRT.Create();
        return(noiseRT);
    }
Ejemplo n.º 30
0
        void Update()
        {
            //float low = _material.GetFloat("_Kill");
            //float t = Mathf.PingPong(Time.time, oscillate);
            //float _Val = Mathf.Lerp(low, high, t);

            //float _Val = low + Mathf.PingPong(t, high - low);
            _material.SetFloat("_Feed", _Feed);
            _material.SetFloat("_Kill", _Kill);
            _material.SetFloat("_Speed", _Speed);

            _texture.Update(_stepsPerFrame);
        }