void ProcessNode(CommandBuffer cmd, BaseNode node) { if (node.computeOrder < 0 || !node.canProcess) { return; } if (node is MixtureNode m) { m.OnProcess(cmd); if (node is IUseCustomRenderTextureProcessing iUseCRT) { foreach (var crt in iUseCRT.GetCustomRenderTextures()) { if (crt != null) { crt.Update(); CustomTextureManager.UpdateCustomRenderTexture(cmd, crt); } } } } else { node.OnProcess(); } }
protected override bool ProcessNode(CommandBuffer cmd) { if (!base.ProcessNode(cmd) || input == null) { return(false); } HistogramUtility.ComputeLuminanceMinMax(cmd, minMaxBuffer, input); TextureUtils.UpdateTextureFromCurve(interpolationCurve, ref curveTexture); var mat = tempRenderTexture.material = GetTempMaterial("Hidden/Mixture/Levels"); mat.SetFloat("_Mode", (int)mode); mat.SetFloat("_ManualMin", min); mat.SetFloat("_ManualMax", max); mat.SetVector("_RcpTextureSize", new Vector4(1.0f / input.width, 1.0f / input.height, 1.0f / TextureUtils.GetSliceCount(input), 0)); MixtureUtils.SetupDimensionKeyword(mat, tempRenderTexture.dimension); MixtureUtils.SetTextureWithDimension(mat, "_Input", input); mat.SetBuffer("_Luminance", minMaxBuffer); mat.SetTexture("_InterpolationCurve", curveTexture); tempRenderTexture.Update(); CustomTextureManager.UpdateCustomRenderTexture(cmd, tempRenderTexture); output = tempRenderTexture; return(true); }
protected override bool ProcessNode(CommandBuffer cmd) { if (!base.ProcessNode(cmd)) { return(false); } // Update temp target in case settings changes UpdateTempRenderTexture(ref previewHeightmap); var heightmapConvertMaterial = GetTempMaterial("Hidden/Mixture/EarthHeightmap"); heightmapConvertMaterial.SetTexture("_Heightmap", savedHeightmap); previewHeightmap.material = heightmapConvertMaterial; CustomTextureManager.UpdateCustomRenderTexture(cmd, previewHeightmap, 1); output = (editMap || savedHeightmap == null) ? (Texture)previewHeightmap : savedHeightmap; return(true); }
protected override bool ProcessNode(CommandBuffer cmd) { rtSettings.doubleBuffered = true; if (!base.ProcessNode(cmd) || input == null) { return(false); } TextureUtils.CopyTexture(cmd, input, output, false); var mipmapGenMat = GetTempMaterial("Hidden/Mixture/GenerateMipMaps"); if (mode == Mode.Custom) { mipmapGenMat = material; } else { output.material = null; } if (mode == Mode.Auto) { cmd.GenerateMips(output); } else { var props = new MaterialPropertyBlock(); MixtureUtils.SetupDimensionKeyword(mipmapGenMat, rtSettings.GetTextureDimension(graph)); mipmapGenMat.SetFloat("_Mode", (int)mode); MixtureUtils.SetTextureWithDimension(props, "_PreviousMip", input); // Manually generate mips: for (int i = 0; i < output.mipmapCount - 1; i++) { props.SetFloat("_SourceMip", i); float width = Mathf.Max(1, input.width >> i); float height = Mathf.Max(1, input.width >> i); float depth = Mathf.Max(1, TextureUtils.GetSliceCount(input) >> i); props.SetVector("_RcpTextureSize", new Vector4(1.0f / width, 1.0f / height, 1.0f / depth, 0.0f)); output.material = mipmapGenMat; if (mode == Mode.Gaussian) { // 2 passes of gaussian blur for 2D and Cubemaps props.SetVector("_GaussianBlurDirection", Vector3.right); CustomTextureManager.UpdateCustomRenderTexture(cmd, output, 1, i + 1, props); TextureUtils.CopyTexture(cmd, output.GetDoubleBufferRenderTexture(), output, i + 1); props.SetFloat("_SourceMip", i + 1); MixtureUtils.SetTextureWithDimension(props, "_PreviousMip", output); props.SetVector("_GaussianBlurDirection", Vector3.up); CustomTextureManager.UpdateCustomRenderTexture(cmd, output, 1, i + 1, props); // And a third pass if we're in 3D if (input.dimension == TextureDimension.Tex3D) { props.SetVector("_GaussianBlurDirection", Vector3.forward); TextureUtils.CopyTexture(cmd, output.GetDoubleBufferRenderTexture(), output, i + 1); CustomTextureManager.UpdateCustomRenderTexture(cmd, output, 1, i + 1, props); } } else { CustomTextureManager.UpdateCustomRenderTexture(cmd, output, 1, i + 1, props); } TextureUtils.CopyTexture(cmd, output.GetDoubleBufferRenderTexture(), output, i + 1); MixtureUtils.SetTextureWithDimension(props, "_PreviousMip", output); } } output.material = null; return(true); }