/// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary> public void Dispose() { for (int i = 0; i < _volumeRtSections.Length; ++i) { _volumeSections[i]?.Dispose(); _volumeRtSections[i]?.Dispose(); } _textureView = null; _cube?.Dispose(); _volumeScaleFactor?.Dispose(); _volumeRayParams?.Dispose(); _cubeTransform?.Dispose(); _cubePosShader?.Dispose(); _cubeDirShader?.Dispose(); _cubeVs?.Dispose(); _inputLayout?.Dispose(); _cubeTransform = null; _inputLayout = null; _cube = null; _volumeScaleFactor = null; _volumeRayParams = null; _cubePosShader = null; _cubeDirShader = null; _cubeVs = null; }
/// <summary>Function to dispose any texture resources.</summary> protected override void OnDestroyTexture() { _texture?.Dispose(); _textureView?.Dispose(); _texture = null; _textureView = null; }
/// <summary>Function to create the texture for the view.</summary> /// <param name="graphics">The graphics interface used to create the texture.</param> /// <param name="imageData">The image data to create the texture from.</param> /// <param name="name">The name of the texture.</param> protected override void OnCreateTexture(GorgonGraphics graphics, IGorgonImage imageData, string name) { _texture = imageData.ToTexture3D(graphics, new GorgonTextureLoadOptions { Name = name, Binding = TextureBinding.ShaderResource, Usage = ResourceUsage.Immutable }); _textureView = _texture.GetShaderResourceView(); _volRenderer.AssignTexture(_textureView); }
/// <summary> /// Function to assign the volume texture to render. /// </summary> /// <param name="texture">The volume texture to render.</param> public void AssignTexture(GorgonTexture3DView texture) { _textureView = texture; var size = new DX.Vector3(texture.Width, texture.Height, texture.Depth); float maxSize = texture.Width.Max(texture.Height).Max(texture.Depth); var volParams = new VolumeRayParameters { Steps = new DX.Vector3(1.0f / texture.Width, 1.0f / texture.Height, 1.0f / texture.Depth) * 0.5f, Iterations = (int)(maxSize * 2.0f) }; _volumeRayParams.SetData(ref volParams); var scaleFactor = new DX.Vector4(1.0f, 1.0f, 1.0f / (maxSize / size.Z), 1.0f); _volumeScaleFactor.SetData(ref scaleFactor); RebuildVolumeData(); }