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); }
public BookShelveConstructionProvider() { drawables = new SimpleDrawableComponent[] { new SimpleDrawableComponent( 0, new TextureDrawable( CustomTextureManager.GetFromAssemblyResource( Assembly.GetExecutingAssembly(), "Faark.Gnomoria.Mods.Resources.sprite.png" ), new Rectangle(0, 32, 32, 32), new Vector2(0, -12) ) ) }; }
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); }
public static void On_Skin_Init(Skin self) { if ((graphicsTex == null) || (graphicsTex.GraphicsDevice != GnomanEmpire.Instance.GraphicsDevice) || graphicsTex.IsDisposed) { graphicsTex = CustomTextureManager.GetFromAssemblyResource(Assembly.GetExecutingAssembly(), "Faark.Gnomoria.Mods.Resources.maxButtons.png"); //Texture2D.FromStream(GnomanEmpire.Instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream( "Faark.Gnomoria.Mods.Resources.maxButtons.png")); } var maxImg = new SkinImage(); maxImg.Resource = graphicsTex; // warning have to load it here! maxImg.Name = "Window.MaximizeButton"; self.Images.Add(maxImg); var mySkinLayer = new SkinLayer(); mySkinLayer.Name = "Control"; mySkinLayer.Alignment = Alignment.MiddleLeft; mySkinLayer.ContentMargins = new Margins(6); mySkinLayer.SizingMargins = new Margins(6); mySkinLayer.Image = maxImg; mySkinLayer.Height = 28; mySkinLayer.Width = 28; mySkinLayer.States.Disabled.Index = 2; mySkinLayer.States.Enabled.Index = 2; mySkinLayer.States.Focused.Index = 0; mySkinLayer.States.Hovered.Index = 0; mySkinLayer.States.Pressed.Index = 2; mySkinLayer.Text = new SkinText(self.Controls["Window.CloseButton"].Layers[0].Text); var mySkinControl = new SkinControl(); mySkinControl.Inherits = "Button"; mySkinControl.ResizerSize = 4; mySkinControl.DefaultSize = new Size(28, 28); mySkinControl.Name = "Window.MaximizeButton"; mySkinControl.Layers.Add(mySkinLayer); self.Controls.Add(mySkinControl); }
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); }