Ejemplo n.º 1
0
        DoubleRenderTexture m_obstacles;                //	HACK:2枚も必要ないけど流用

        void Start()
        {
            m_applyImpulse.GetKernelThreadGroupSizes(0, out KernelThreadSize_X, out KernelThreadSize_Y, out KernelThreadSize_Z);

            //Dimension sizes must be pow2 numbers
            m_width  = Mathf.ClosestPowerOfTwo(m_width);
            m_height = Mathf.ClosestPowerOfTwo(m_height);
            m_depth  = Mathf.ClosestPowerOfTwo(m_depth);

            //	オブジェクトのスケールを合わせる
            transform.localScale    = new Vector3(m_width, m_height, m_depth);
            transform.localPosition = new Vector3(0, m_height / 2, 0);

            //Put all dimension sizes in a vector for easy parsing to shader and also prevents user changing
            //dimension sizes during play
            m_size = new Vector4(m_width, m_height, m_depth, 0.0f);

            //Create all the buffers needed

            int SIZE = m_width * m_height * m_depth;

            m_atmosphere = new DoubleRenderTexture(m_width, m_height, m_depth);

            m_velocity   = new DoubleRenderTexture(m_width, m_height, m_depth);
            m_vorticity  = new DoubleRenderTexture(m_width, m_height, m_depth);
            m_divergence = new DoubleRenderTexture(m_width, m_height, m_depth);
            m_pressure   = new DoubleRenderTexture(m_width, m_height, m_depth);

            m_obstacles = new DoubleRenderTexture(m_width, m_height, m_depth);

            //Any areas that are obstacles need to be masked of in the obstacle buffer
            //At the moment is only the border around the edge of the buffers to enforce non-slip boundary conditions
            ComputeObstacles();
        }
Ejemplo n.º 2
0
    DoubleRenderTexture CreateBuffer(int texWidth, int texHeight, int texDepth)
    {
        DoubleRenderTexture rt = new DoubleRenderTexture(texWidth, texHeight, texDepth);

        Blit(rt.renderTexture0, SolverPass.Clear);
        Blit(rt.renderTexture1, SolverPass.Clear);
        return(rt);
    }
Ejemplo n.º 3
0
 void Advect(float step, float dissipation, DoubleRenderTexture target)
 {
     m_CommandBuffer.SetGlobalFloat(Properties.Step, step);
     m_CommandBuffer.SetGlobalFloat(Properties.InverseCellSize, 1f / m_GridScale);
     m_CommandBuffer.SetGlobalFloat(Properties.Dissipation, dissipation);
     m_CommandBuffer.SetGlobalTexture(Properties.Buffer, target.active);
     m_CommandBuffer.SetGlobalTexture(Properties.Buffer2, m_VelocityBuffer.active);
     if (target == m_VelocityBuffer)
     {
         m_VelocityBuffer.Swap();
     }
     Blit(target.active, SolverPass.Advection);
 }
Ejemplo n.º 4
0
    void Start()
    {
        m_FluidSolver      = new Material(shader);
        m_CommandBuffer    = new CommandBuffer();
        m_VelocityBuffer   = CreateBuffer(resolution.x, resolution.y, resolution.z);
        m_DivergenceBuffer = CreateBuffer(resolution.x, resolution.y, resolution.z);
        m_PressureBuffer   = CreateBuffer(resolution.x, resolution.y, resolution.z);

        m_ColorBuffer             = new RenderTexture(colorResolution.x, colorResolution.y, 0, RenderTextureFormat.ARGBFloat);
        m_ColorBuffer.dimension   = TextureDimension.Tex3D;
        m_ColorBuffer.volumeDepth = colorResolution.z;
        m_ColorBuffer.filterMode  = FilterMode.Trilinear;
        Blit(m_ColorBuffer, SolverPass.Clear);

        m_ColorMaterial              = GetComponent <MeshRenderer>().material;
        m_ColorMaterial.mainTexture  = m_ColorBuffer;
        volumeRenderer.volumeTexture = m_ColorBuffer;
        //Camera.main.AddCommandBuffer(CameraEvent.BeforeForwardOpaque, m_CommandBuffer);
    }