Ejemplo n.º 1
0
        public QueryBase()
        {
            _dataArrivedAction = new System.Action <AsyncGPUReadbackRequest>(DataArrived);

            if (_maxQueryCount != OceanRenderer.Instance._lodDataAnimWaves.Settings.MaxQueryCount)
            {
                _maxQueryCount          = OceanRenderer.Instance._lodDataAnimWaves.Settings.MaxQueryCount;
                _queryPosXZ_minGridSize = new Vector3[_maxQueryCount];
            }

            _computeBufQueries = new ComputeBuffer(_maxQueryCount, 12, ComputeBufferType.Default);
            _computeBufResults = new ComputeBuffer(_maxQueryCount, 12, ComputeBufferType.Default);

            _queryResults     = new NativeArray <Vector3>(_maxQueryCount, Allocator.Persistent, NativeArrayOptions.ClearMemory);
            _queryResultsLast = new NativeArray <Vector3>(_maxQueryCount, Allocator.Persistent, NativeArrayOptions.ClearMemory);

            _shaderProcessQueries = ComputeShaderHelpers.LoadShader(QueryShaderName);
            if (_shaderProcessQueries == null)
            {
                Debug.LogError($"Could not load Query compute shader {QueryShaderName}");
                return;
            }
            _kernelHandle = _shaderProcessQueries.FindKernel(QueryKernelName);
            _wrapper      = new PropertyWrapperComputeStandalone(_shaderProcessQueries, _kernelHandle);
        }
        protected virtual void OnEnable()
        {
            _dataArrivedAction = new System.Action <AsyncGPUReadbackRequest>(DataArrived);

            if (_maxQueryCount != OceanRenderer.Instance._simSettingsAnimatedWaves.MaxQueryCount)
            {
                _maxQueryCount          = OceanRenderer.Instance._simSettingsAnimatedWaves.MaxQueryCount;
                _queryPosXZ_minGridSize = new Vector3[_maxQueryCount];
            }

            _computeBufQueries = new ComputeBuffer(_maxQueryCount, 12, ComputeBufferType.Default);
            _computeBufResults = new ComputeBuffer(_maxQueryCount, 12, ComputeBufferType.Default);

            _queryResults     = new NativeArray <Vector3>(_maxQueryCount, Allocator.Persistent, NativeArrayOptions.ClearMemory);
            _queryResultsLast = new NativeArray <Vector3>(_maxQueryCount, Allocator.Persistent, NativeArrayOptions.ClearMemory);

            _shaderProcessQueries = ComputeShaderHelpers.LoadShader(QueryShaderName);
            if (_shaderProcessQueries == null)
            {
                enabled = false;
                return;
            }
            _kernelHandle = _shaderProcessQueries.FindKernel(QueryKernelName);
            _wrapper      = new PropertyWrapperComputeStandalone(_shaderProcessQueries, _kernelHandle);
        }
Ejemplo n.º 3
0
        protected override void BindInputsAndOutputs(PropertyWrapperComputeStandalone wrapper, ComputeBuffer resultsBuffer)
        {
            LodDataMgrAnimWaves.Bind(wrapper);
            ShaderProcessQueries.SetTexture(_kernelHandle, sp_LD_TexArray_AnimatedWaves, OceanRenderer.Instance._lodDataAnimWaves.DataTexture);
            ShaderProcessQueries.SetBuffer(_kernelHandle, sp_ResultDisplacements, resultsBuffer);

            ShaderProcessQueries.SetBuffer(_kernelHandle, OceanRenderer.sp_cascadeData, OceanRenderer.Instance._bufCascadeDataTgt);
        }
Ejemplo n.º 4
0
 protected override void BindInputsAndOutputs(PropertyWrapperComputeStandalone wrapper, ComputeBuffer resultsBuffer)
 {
     if (OceanRenderer.Instance._lodDataFlow != null)
     {
         OceanRenderer.Instance._lodDataFlow.BindResultData(wrapper);
         ShaderProcessQueries.SetTexture(_kernelHandle, sp_LD_TexArray_Flow, OceanRenderer.Instance._lodDataFlow.DataTexture);
     }
     ShaderProcessQueries.SetBuffer(_kernelHandle, sp_ResultFlows, resultsBuffer);
 }
Ejemplo n.º 5
0
        protected virtual void OnEnable()
        {
            _dataArrivedAction = new System.Action <AsyncGPUReadbackRequest>(DataArrived);

            _shaderProcessQueries = Resources.Load <ComputeShader>(QueryShaderName);
            _kernelHandle         = _shaderProcessQueries.FindKernel(QueryKernelName);
            _wrapper = new PropertyWrapperComputeStandalone(_shaderProcessQueries, _kernelHandle);

            _computeBufQueries = new ComputeBuffer(s_maxQueryCount, 12, ComputeBufferType.Default);
            _computeBufResults = new ComputeBuffer(s_maxQueryCount, 12, ComputeBufferType.Default);

            _queryResults     = new NativeArray <Vector3>(s_maxQueryCount, Allocator.Persistent, NativeArrayOptions.ClearMemory);
            _queryResultsLast = new NativeArray <Vector3>(s_maxQueryCount, Allocator.Persistent, NativeArrayOptions.ClearMemory);
        }
Ejemplo n.º 6
0
 protected abstract void BindInputsAndOutputs(PropertyWrapperComputeStandalone wrapper, ComputeBuffer resultsBuffer);
Ejemplo n.º 7
0
 protected override void BindInputsAndOutputs(PropertyWrapperComputeStandalone wrapper, ComputeBuffer resultsBuffer)
 {
     LodDataMgrFlow.Bind(wrapper);
     ShaderProcessQueries.SetBuffer(_kernelHandle, sp_ResultFlows, resultsBuffer);
 }