예제 #1
0
        void Update()
        {
            cs.SetInt(CSPARAM.PARTICLE_NUM, particleNum);
            cs.SetFloat(CSPARAM.TIME, Time.time);
            cs.SetFloat(CSPARAM.TIME_SCALE, timeScale);
            cs.SetFloat(CSPARAM.POSITION_SCALE, positionScale);
            cs.SetFloat(CSPARAM.NOISE_SCALE, noiseScale);

            var kernelUpdate = cs.FindKernel(CSPARAM.UPDATE);

            cs.SetBuffer(kernelUpdate, CSPARAM.PARTICLE_BUFFER_WRITE, particleBuffer);

            var updateThureadNum = new Vector3(particleNum, 1f, 1f);

            ComputeShaderUtil.Dispatch(cs, kernelUpdate, updateThureadNum);


            var kernelInput = cs.FindKernel(CSPARAM.WRITE_TO_INPUT);

            cs.SetBuffer(kernelInput, CSPARAM.PARTICLE_BUFFER_READ, particleBuffer);
            cs.SetBuffer(kernelInput, CSPARAM.INPUT_BUFFER, trails.inputBuffer);

            var inputThreadNum = new Vector3(particleNum, 1f, 1f);

            ComputeShaderUtil.Dispatch(cs, kernelInput, inputThreadNum);
        }
예제 #2
0
        void LateUpdate()
        {
            cs.SetFloat(CSPARAM.TIME, Time.time);
            cs.SetFloat(CSPARAM.UPDATE_DISTANCE_MIN, updateDistaceMin);
            cs.SetInt(CSPARAM.TRAIL_NUM, trailNum);
            cs.SetInt(CSPARAM.NODE_NUM_PER_TRAIL, nodeNum);

            var kernel = cs.FindKernel(CSPARAM.CALC_INPUT);

            cs.SetBuffer(kernel, CSPARAM.TRAIL_BUFFER, trailBuffer);
            cs.SetBuffer(kernel, CSPARAM.NODE_BUFFER, nodeBuffer);
            cs.SetBuffer(kernel, CSPARAM.INPUT_BUFFER, inputBuffer);

            ComputeShaderUtil.Dispatch(cs, kernel, new Vector3(trailNum, 1f, 1f));
        }