From 751c1f20dccaf609c8dfac43541b797edff37928 Mon Sep 17 00:00:00 2001 From: Olly Rybak Date: Wed, 3 Jul 2024 18:35:32 +1000 Subject: [PATCH] Returns lightmap UV correctly with no errors --- Source/Editor/Surface/Archetypes/Textures.cs | 13 +++++++++++++ .../MaterialGenerator.Textures.cpp | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/Source/Editor/Surface/Archetypes/Textures.cs b/Source/Editor/Surface/Archetypes/Textures.cs index 00c0a806d..53b2ccf04 100644 --- a/Source/Editor/Surface/Archetypes/Textures.cs +++ b/Source/Editor/Surface/Archetypes/Textures.cs @@ -434,6 +434,19 @@ namespace FlaxEditor.Surface.Archetypes NodeElementArchetype.Factory.ComboBox(50, Surface.Constants.LayoutOffsetY * 4, 100, 0, typeof(CommonSamplerType)) } }, + new NodeArchetype + { + TypeID = 18, + Title = "Lightmap UV", + AlternativeTitles = new string[] { "Lightmap TexCoord" }, + Description = "Lightmap UVs", + Flags = NodeFlags.MaterialGraph, + Size = new Float2(110, 30), + Elements = new [] + { + NodeElementArchetype.Factory.Output(0, "UVs", typeof(Float2), 0) + } + } }; } } diff --git a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Textures.cpp b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Textures.cpp index 9b0a334e6..8083718dd 100644 --- a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Textures.cpp +++ b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Textures.cpp @@ -733,6 +733,25 @@ void MaterialGenerator::ProcessGroupTextures(Box* box, Node* node, Value& value) _writer.Write(*triplanarTexture); value = result; } + // Get Lightmap UV + case 18: + { + auto output = writeLocal(Value::InitForZero(ValueType::Float2), node); + auto lightmapUV = String::Format(TEXT( + "{{\n" + "#if USE_LIGHTMAP\n" + "\t {0} = input.LightmapUV;\n" + "#else\n" + "\t {0} = float2(0,0);\n" + "#endif\n" + "}}\n" + ), output.Value); + + _writer.Write(*lightmapUV); + + value = output; + break; + } default: break; }