void OnEnable() { manualCam = new ManuallyRenderCamera(refCam); output = new LODRenderTexture(); var formatOutput = output.Format; formatOutput.depth = 24; formatOutput.textureFormat = RenderTextureFormat.ARGBFloat; output.Format = formatOutput; manualCam.AfterCopyFrom += (Camera obj) => { obj.cullingMask = tuner.MaskValue; if (tuner.overrideClearFlags) { obj.clearFlags = tuner.clearFlags; obj.backgroundColor = tuner.backgroundColor; } }; output.AfterCreateTexture += (LODRenderTexture obj) => { obj.Texture.filterMode = FilterMode.Bilinear; obj.Texture.wrapMode = TextureWrapMode.Clamp; OnUpdateVelocityTex.Invoke(obj.Texture); }; }
public GPUDune(RenderTextureFormat format) { OnCreate = null; tex = new LODRenderTexture(); var formatTex = tex.Format; formatTex.textureFormat = format; tex.Format = formatTex; validator.Reset(); validator.Validation += () => { if (size.x < 2 || size.y < 2) { return; } tex.Lod = lod; tex.Size = size; Debug.LogFormat("GPUDune : Create texture size={0}", tex.LodSize); }; validator.Validated += () => { NotifyOnCreate(); }; validator.SetCheckers(() => tex != null); }
void Start() { _attachedCamera = GetComponent <Camera> (); _attachedCamera.depthTextureMode = DepthTextureMode.Depth; manualCam = new ManuallyRenderCamera(_attachedCamera); _imageTex0 = new LODRenderTexture(); _imageTex1 = new LODRenderTexture(); _sourceTex = new LODRenderTexture(); var format0 = _imageTex0.Format; format0.depth = 0; format0.textureFormat = textureFormatAdvected; format0.readWrite = RenderTextureReadWrite.Linear; _imageTex0.Format = format0; _imageTex1.Format = format0; var formatSource = _sourceTex.Format; formatSource.depth = 24; formatSource.textureFormat = textureFormatSource; formatSource.readWrite = RenderTextureReadWrite.Linear; formatSource.antiAliasing = QualitySettings.antiAliasing; _imageTex0.AfterCreateTexture += UpdateAfterCreateTexture; _imageTex1.AfterCreateTexture += UpdateAfterCreateTexture; Prepare(); }
protected void ReleaseTexture() { if (tex != null) { tex.Dispose(); tex = null; } }
void OnDestroy() { if (output != null) { output.Dispose(); output = null; } }
void OnDestroy() { manualCam.Dispose(); if (_imageTex0 != null) { _imageTex0.Dispose(); _imageTex0 = null; } if (_imageTex1 != null) { _imageTex1.Dispose(); _imageTex1 = null; } if (_sourceTex != null) { _sourceTex.Dispose(); _sourceTex = null; } }
protected void UpdateAfterCreateTexture(LODRenderTexture obj) { obj.Texture.wrapMode = TextureWrapMode.Clamp; obj.Texture.filterMode = FilterMode.Bilinear; obj.Clear(Color.clear); }