예제 #1
0
    // Start is called before the first frame update
    void Start()
    {
        emitPts = new Vector3[Count];

        for (int i = 0; i < Count; i++)
        {
            Vector2 dir = getND();
            emitPts[i] = new Vector3(dir.x, dir.y, 0) * Random.Range(0f, 1f);
        }

        emitterMat = Matrix4x4.LookAt(EmitterPosition, TargetPosition, Vector3.up);

        _EmitterBuffer  = new ComputeBuffer(Count, Marshal.SizeOf(typeof(Vector3)));
        _VerticesBuffer = new ComputeBuffer(Count * Iterate, Marshal.SizeOf(typeof(Vector3)));

        kernelMain = cstrail.FindKernel("CSTrailVert");

        baker = BakerObj.GetComponent <SDFBaker>();

        _PositionMap = new RenderTexture(Iterate, Count, 0, RenderTextureFormat.ARGBFloat);
        _PositionMap.enableRandomWrite = true;
        _PositionMap.Create();

        cstrail.SetTexture(kernelMain, "_PositionMap", _PositionMap);

        _VFX.SetTexture("PositionMap", _PositionMap);
        _VFX.SetUInt("SegmentCount", (uint)Iterate);
        _VFX.SetUInt("TrailCount", (uint)Count);
    }
예제 #2
0
    void SaveAsTextureAsset(SDFBaker baker)
    {
        var path = EditorUtility.SaveFilePanel("Save as ...", Application.dataPath, "SDF Texture.asset", "asset");

        if (path.Length != 0)
        {
            var relativePath = path.Substring(path.IndexOf("Assets/"));
            AssetDatabase.CreateAsset(baker.targetTexture, relativePath);
        }
    }
예제 #3
0
 // Start is called before the first frame update
 void Start()
 {
     baker = Target.GetComponent <SDFBaker>();
 }