/// <summary> /// レンダーターゲットをリセットします. /// </summary> private void ResetTargets() { // ターゲットを破棄 if (RenderTargetView != null && !RenderTargetView.Disposed) { RenderTargetView.Dispose(); } if (RenderTarget != null && !RenderTarget.Disposed) { RenderTarget.Dispose(); } if (DepthTargetView != null && !DepthTargetView.Disposed) { DepthTargetView.Dispose(); } if (DepthTarget != null && !DepthTarget.Disposed) { DepthTarget.Dispose(); } Device device = Context.DeviceManager.Device; //深度ステンシルバッファの初期化 //レンダーターゲットの初期化 renderTarget = new Texture2D(device, getRenderTargetTexture2DDescription()); renderTargetView = new RenderTargetView(device, RenderTarget); //深度ステンシルバッファの初期化 depthTarget = new Texture2D(device, getDepthBufferTexture2DDescription()); depthTargetView = new DepthStencilView(device, DepthTarget); SetViewport(); }
/// <summary> /// Removes the DepthTarget from a list of depth consumers. /// </summary> /// <param name="target">A DepthTarget instance, which uses depth.</param> public static void RemoveDepthTarget(DepthTarget target) { CheckAttachedToScene(); if (s_DepthTargets.Contains(target)) { s_DepthTargets.Remove(target); } }
/// <summary> /// Adds the DepthTarget to a list of depth consumers. /// </summary> /// <param name="target">A DepthTarget instance, which uses depth.</param> public static void AddDepthTarget(DepthTarget target) { CheckAttachedToScene(); if (!s_DepthTargets.Contains(target)) { s_DepthTargets.Add(target); if (target.DepthTargetMaterial != null) { SetDepthTexture(target); } } }
private static void SetDepthTexture(DepthTarget target) { if (target.SetAsMainTexture) { if (target.DepthTargetMaterial.mainTexture != DepthTexture) { target.DepthTargetMaterial.mainTexture = DepthTexture; } } else if (target.DepthTargetMaterial.GetTexture(k_CurrentDepthTexturePropertyName) != DepthTexture) { target.DepthTargetMaterial.SetTexture(k_CurrentDepthTexturePropertyName, DepthTexture); } }
protected virtual void Dispose(bool disposing) { if (!disposed) { if (disposing) { DepthTarget.Dispose(); foreach (var ct in ColorTargets) { ct.Dispose(); } RenderTarget.Dispose(); } disposed = true; } }
private static void SetDepthTexture(DepthTarget target) { Texture2D depthTexture = DepthTexture; if (target.SetAsMainTexture) { if (target.DepthTargetMaterial.mainTexture != depthTexture) { target.DepthTargetMaterial.mainTexture = depthTexture; } } //target.DepthTargetMaterial.HasProperty(k_CurrentDepthTexturePropertyName) else if (target.DepthTargetMaterial.GetTexture(k_CurrentDepthTexturePropertyName) != depthTexture) { target.DepthTargetMaterial.SetTexture(k_CurrentDepthTexturePropertyName, depthTexture); } }