void ResetResources() { SanitizeParameters(); // Lattice mesh object. if (_lattice == null) _lattice = new Lattice(_slices, _stacks); else _lattice.Rebuild(_slices, _stacks); // GPGPU buffers. if (_positionBuffer) DestroyImmediate(_positionBuffer); if (_normalBuffer1) DestroyImmediate(_normalBuffer1); if (_normalBuffer2) DestroyImmediate(_normalBuffer2); _positionBuffer = CreateBuffer(); _normalBuffer1 = CreateBuffer(); _normalBuffer2 = CreateBuffer(); // Shader materials. if (!_kernelMaterial) _kernelMaterial = CreateMaterial(_kernelShader); if (!_surfaceMaterial1) _surfaceMaterial1 = CreateMaterial(_surfaceShader); if (!_surfaceMaterial2) _surfaceMaterial2 = CreateMaterial(_surfaceShader); if (!_lineMaterial) _lineMaterial = CreateMaterial(_lineShader); if (!_debugMaterial) _debugMaterial = CreateMaterial(_debugShader); // Set buffer references. _surfaceMaterial1.SetTexture("_PositionTex", _positionBuffer); _surfaceMaterial2.SetTexture("_PositionTex", _positionBuffer); _lineMaterial .SetTexture("_PositionTex", _positionBuffer); _surfaceMaterial1.SetTexture("_NormalTex", _normalBuffer1); _surfaceMaterial2.SetTexture("_NormalTex", _normalBuffer2); _needsReset = false; }
void ResetResources() { SanitizeParameters(); // Lattice mesh object. if (_lattice == null) { _lattice = new Lattice(_slices, _stacks); } else { _lattice.Rebuild(_slices, _stacks); } // GPGPU buffers. if (_positionBuffer) { DestroyImmediate(_positionBuffer); } if (_normalBuffer1) { DestroyImmediate(_normalBuffer1); } if (_normalBuffer2) { DestroyImmediate(_normalBuffer2); } _positionBuffer = CreateBuffer(); _normalBuffer1 = CreateBuffer(); _normalBuffer2 = CreateBuffer(); // Shader materials. if (!_kernelMaterial) { _kernelMaterial = CreateMaterial(_kernelShader); } if (!_surfaceMaterial1) { _surfaceMaterial1 = CreateMaterial(_surfaceShader); } if (!_surfaceMaterial2) { _surfaceMaterial2 = CreateMaterial(_surfaceShader); } if (!_lineMaterial) { _lineMaterial = CreateMaterial(_lineShader); } if (!_debugMaterial) { _debugMaterial = CreateMaterial(_debugShader); } // Set buffer references. _surfaceMaterial1.SetTexture("_PositionTex", _positionBuffer); _surfaceMaterial2.SetTexture("_PositionTex", _positionBuffer); _lineMaterial.SetTexture("_PositionTex", _positionBuffer); _surfaceMaterial1.SetTexture("_NormalTex", _normalBuffer1); _surfaceMaterial2.SetTexture("_NormalTex", _normalBuffer2); _needsReset = false; }