Esempio n. 1
0
    void ResetResources()
    {
        // parameter sanitization
        info.numParticles  = Mathf.Clamp(info.numParticles, 1, 8192);
        info.historyLength = Mathf.Clamp(info.historyLength, 8, 1024);

        // mesh object
        if (_mesh)
        {
            DestroyImmediate(_mesh);
        }
        _mesh = CreateMesh();

        if (buffer == null)
        {
            buffer = new RhoBuffer(info);
        }

        buffer.Reset();

        kernel.material.SetVector("_Direction", direction);
        kernel.material.SetFloat("_Speed", speed);


        // buffer initialization
        Graphics.Blit(null, buffer.positionOut, kernel.material, 0);
        Graphics.Blit(null, buffer.velocityOut, kernel.material, 1);

        _time = 0;

        _needsReset = false;
    }
Esempio n. 2
0
    public void StepKernel(float time, float deltaTime, RhoBuffer buffer )
    {
        // GPGPU buffer swap
        buffer.Swap();

        Material m = kernel.material;
        m.SetVector("_TimeParams", new Vector2(time, deltaTime));

        // velocity update
        m.SetTexture("_PositionTex", buffer.positionIn);
        m.SetTexture("_VelocityTex", buffer.velocityIn);
        Graphics.Blit(null, buffer.velocityOut, m, 1);

        // position update
        m.SetTexture("_VelocityTex", buffer.velocityOut);
        Graphics.Blit(null, buffer.positionOut, m, 0);
    }
Esempio n. 3
0
    public void StepKernel(float time, float deltaTime, RhoBuffer buffer)
    {
        // GPGPU buffer swap
        buffer.Swap();

        Material m = kernel.material;

        m.SetVector("_TimeParams", new Vector2(time, deltaTime));

        // velocity update
        m.SetTexture("_PositionTex", buffer.positionIn);
        m.SetTexture("_VelocityTex", buffer.velocityIn);
        Graphics.Blit(null, buffer.velocityOut, m, 1);

        // position update
        m.SetTexture("_VelocityTex", buffer.velocityOut);
        Graphics.Blit(null, buffer.positionOut, m, 0);
    }
Esempio n. 4
0
    void ResetResources()
    {
        // parameter sanitization
        info.numParticles = Mathf.Clamp(info.numParticles, 1, 8192);
        info.historyLength = Mathf.Clamp(info.historyLength, 8, 1024);

        // mesh object
        if (_mesh) DestroyImmediate(_mesh);
        _mesh = CreateMesh();

        if( buffer == null )
            buffer = new RhoBuffer( info );

        buffer.Reset();

        kernel.material.SetVector("_Direction", direction);
        kernel.material.SetFloat("_Speed", speed);

        // buffer initialization
        Graphics.Blit(null, buffer.positionOut, kernel.material, 0);
        Graphics.Blit(null, buffer.velocityOut, kernel.material, 1);

        _time = 0;

        _needsReset = false;
    }