protected override bool ProcessNode(CommandBuffer cmd) { if (output == null) { return(false); } var outputDimension = rtSettings.GetTextureDimension(graph); MixtureUtils.SetupDimensionKeyword(material, outputDimension); var s = material.shader; for (int i = 0; i < s.GetPropertyCount(); i++) { if (s.GetPropertyType(i) != ShaderPropertyType.Texture) { continue; } int id = s.GetPropertyNameId(i); if (material.GetTexture(id) != null) { continue; // Avoid overriding existing textures } var dim = s.GetPropertyTextureDimension(i); if (dim == TextureDimension.Tex2D) { continue; // Texture2D don't need this feature } // default texture names doesn't work with cubemap and 3D textures so we do it ourselves... switch (s.GetPropertyTextureDefaultName(i)) { case "black": material.SetTexture(id, TextureUtils.GetBlackTexture(dim)); break; case "white": material.SetTexture(id, TextureUtils.GetWhiteTexture(dim)); break; // TODO: grey and bump } } output.material = material; bool useCustomUV = material.HasTextureBound("_UV", rtSettings.GetTextureDimension(graph)); material.SetKeywordEnabled("USE_CUSTOM_UV", useCustomUV); return(true); }
protected override bool ProcessNode() { if (graph.outputTexture == null) { Debug.LogError("Output Node can't write to target texture, Graph references a null output texture"); return(false); } // Update the renderTexture reference for realtime graph if (graph.isRealtime) { if (tempRenderTexture != graph.outputTexture) { onTempRenderTextureUpdated?.Invoke(); } tempRenderTexture = graph.outputTexture as CustomRenderTexture; } var inputPort = GetPort(nameof(input), nameof(input)); if (inputPort.GetEdges().Count == 0) { if (uniqueMessages.Add("OutputNotConnected")) { AddMessage("Output node input is not connected", NodeMessageType.Warning); } input = TextureUtils.GetBlackTexture(rtSettings); // TODO: set a black texture of texture dimension as default value return(false); } else { uniqueMessages.Clear(); ClearMessages(); } // Update the renderTexture size and format: if (UpdateTempRenderTexture(ref tempRenderTexture)) { onTempRenderTextureUpdated?.Invoke(); } if (input.dimension != graph.outputTexture.dimension) { Debug.LogError("Error: Expected texture type input for the OutputNode is " + graph.outputTexture.dimension + " but " + input?.dimension + " was provided"); return(false); } MixtureUtils.SetupDimensionKeyword(finalCopyMaterial, input.dimension); // Manually reset all texture inputs ResetMaterialPropertyToDefault(finalCopyMaterial, "_Source_2D"); ResetMaterialPropertyToDefault(finalCopyMaterial, "_Source_3D"); ResetMaterialPropertyToDefault(finalCopyMaterial, "_Source_Cube"); if (input.dimension == TextureDimension.Tex2D) { finalCopyMaterial.SetTexture("_Source_2D", input); } else if (input.dimension == TextureDimension.Tex3D) { finalCopyMaterial.SetTexture("_Source_3D", input); } else { finalCopyMaterial.SetTexture("_Source_Cube", input); } tempRenderTexture.material = finalCopyMaterial; return(true); }