Ejemplo n.º 1
0
    public void ResetParameters(MinMaxVec mm)
    {
        ComputeDirectionVectors();

        Vector3Int box, box_center;

        mm.GetRenderTextureBoundingBox((int)Constants.ThreadMutiples, out box, out box_center);
        if (NozzleRT && NozzleRT.IsCreated())
        {
            NozzleRT.Release();
        }

        NozzleRT = FFT.CreateRenderTexture3D(box.x, box.y, box.z, RenderTextureFormat.RFloat);

        topleft = ISFUtils.IntToFloat(box_center) - ISFUtils.IntToFloat(box) / 2;
        if (topleft.x < 0 || topleft.y < 0 || topleft.z < 0)
        {
            Debug.LogError("The bounding box excceeds");
        }

        nozzle_relative_center  = ISFUtils.IntToFloat(box) / 2;
        nozzle_center_in_shader = ISFUtils.IntToFloat(box_center);

        SetCSData();

        CS.SetTexture(kernelCreateNozzleMask, "Nozzle", NozzleRT);
        DispatchCS(kernelCreateNozzleMask);
    }
Ejemplo n.º 2
0
    // TODO: 测试支持6个自由度的nozzle
    public void UpdateNozzles()
    {
        nozzle_dir.Normalize();
        if (nozzle_dir == Vector3.up)
        {
            nozzle_dir.x += 0.01f;
        }
        nozzle_right = Vector3.Cross(nozzle_dir, Vector3.up);
        nozzle_right.Normalize();

        Vector3 nozzle_up = Vector3.Cross(nozzle_dir, nozzle_right);

        nozzle_up.Normalize();

        var mm = MinMaxVec.Create();

        mm.Feed(nozzle_center + nozzle_dir * nozzle_length / 2);
        mm.Feed(nozzle_center - nozzle_dir * nozzle_length / 2);

        mm.Feed(nozzle_center + nozzle_right * nozzle_radius);
        mm.Feed(nozzle_center - nozzle_right * nozzle_radius);

        mm.Feed(nozzle_center + nozzle_up * nozzle_radius);
        mm.Feed(nozzle_center - nozzle_up * nozzle_radius);

        Vector3Int box, box_center;

        mm.GetRenderTextureBoundingBox(8, out box, out box_center);

        if (NozzleRT && NozzleRT.IsCreated())
        {
            NozzleRT.Release();
        }

        NozzleRT = FFT.CreateRenderTexture3D(box.x, box.y, box.z, RenderTextureFormat.RFloat);

        var topleft = ISFUtils.IntToFloat(box_center) - ISFUtils.IntToFloat(box) / 2;

        if (topleft.x < 0 || topleft.y < 0 || topleft.z < 0)
        {
            Debug.LogError("The bounding box excceeds");
        }
        nozzle_topleft = topleft;
        CS.SetVector("nozzle_ralative_center", ISFUtils.IntToFloat(box) / 2);
        CS.SetVector("nozzle_center", ISFUtils.IntToFloat(box_center));
        CS.SetFloat("nozzle_radius", nozzle_radius);
        CS.SetVector("nozzle_dir", nozzle_dir);
        CS.SetVector("nozzle_topleft", topleft);
        CS.SetFloat("nozzle_length", nozzle_length);
        CS.SetVector("nozzle_velocity", nozzle_velocity / isf.hbar);
        CS.SetVector("nozzle_right", nozzle_right);
        CS.SetVector("nozzle_up", nozzle_up);

        ISFSync();

        CS.SetTexture(kernelCreateNozzleMask, "Nozzle", NozzleRT);
        DispatchCS(kernelCreateNozzleMask, true);

        //ExportDebugMask();
    }
Ejemplo n.º 3
0
    void Prepare()
    {
        InitScale();

        fft = isf.fft;
        fft.init();

        isf.hbar        = HBar;
        isf.size        = Size;
        isf.N           = N;
        isf.estimate_dt = 1.0f / DtInv;

        NFloat = ISFUtils.IntToFloat(N);


        isf.InitComputeShader();
        isf.InitISF();

        psi1 = FFT.CreateRenderTexture3D(N[0], N[1], N[2], RenderTextureFormat.RGFloat);
        psi2 = FFT.CreateRenderTexture3D(N[0], N[1], N[2], RenderTextureFormat.RGFloat);
        isf.InitializePsi(ref psi1, ref psi2);


        InitComputeShader();
        InitPsi(ref psi1, ref psi2);
        InitParticles();
    }
Ejemplo n.º 4
0
 public Vector3 GetGridSize()
 {
     return(ISFUtils.Div(size, ISFUtils.IntToFloat(N)));
 }