void EnsureCachedTextureExist(CachedShadowMapLight a_light) { if (this._CachedShadowMapTextures.ContainsKey(key: a_light.LightComponent)) { if (this._CachedShadowMapTextures[key : a_light.LightComponent].width == a_light.LightComponent.shadowCustomResolution && this._CachedShadowMapTextures[key : a_light.LightComponent].height == a_light.LightComponent.shadowCustomResolution && this.TextureTypeFits(a_light : a_light) && this._CachedShadowMapTextures[key : a_light.LightComponent].depth == (int)CachedShadowMapLight.MShadowMapBitDepth && this._CachedShadowMapTextures[key : a_light.LightComponent].IsCreated()) { return; } this._CachedShadowMapTextures[key : a_light.LightComponent].DiscardContents(); this._CachedShadowMapTextures[key : a_light.LightComponent].Release(); RenderTexture.DestroyImmediate(obj: this._CachedShadowMapTextures[key: a_light.LightComponent]); this._CachedShadowMapTextures.Remove(key: a_light.LightComponent); //this.CachedShadowMapTextures[aLight.LightComponent].MarkRestoreExpected(); } ; var shadow_custom_resolution = a_light.LightComponent.shadowCustomResolution; var cached_shadow_map = new RenderTexture(width: shadow_custom_resolution, height: shadow_custom_resolution, depth: (int)CachedShadowMapLight.MShadowMapBitDepth, format: RenderTextureFormat.Shadowmap) { antiAliasing = (int)AntiAliasingEnum.None_, filterMode = CachedShadowMapLight._MFilterMode, useMipMap = false, autoGenerateMips = false, wrapMode = TextureWrapMode.Clamp, memorylessMode = RenderTextureMemoryless.None, vrUsage = VRTextureUsage.None, useDynamicScale = false, name = $"Cached Shadow Map for #{a_light.GetInstanceID()}", anisoLevel = CachedShadowMapLight ._MAnisoLevel }; if (a_light.LightComponent.type == LightType.Point) { cached_shadow_map.dimension = TextureDimension.Cube; } cached_shadow_map.Create(); this._CachedShadowMapTextures[key : a_light.LightComponent] = cached_shadow_map; }
void EnsureCaptureCmdBufferExist(CachedShadowMapLight a_light) { if (!this._CaptureCmdBuffers.ContainsKey(key: a_light.LightComponent)) { var s = new CommandBuffer { name = $"Shadow Map Cache #{unchecked(this._capture_id++)} #CID{a_light.GetInstanceID()}" }; //unchecked wraps integer instead of throwing exception a_light.LightComponent.AddCommandBuffer(evt: this._capture_event, buffer: s); this._CaptureCmdBuffers.Add(key: a_light.LightComponent, value: s); } a_light.LightComponent.RemoveCommandBuffer(evt: this._capture_event, buffer: this._CaptureCmdBuffers [key: a_light.LightComponent]); a_light.LightComponent.AddCommandBuffer(evt: this._capture_event, buffer: this._CaptureCmdBuffers[key: a_light.LightComponent]); }