Add Linear to sRGB and sRGB to Linear nodes to materials

This commit is contained in:
Wojtek Figat
2026-01-12 15:54:52 +01:00
parent b834dddb11
commit 69c5d65318
2 changed files with 42 additions and 0 deletions

View File

@@ -1347,6 +1347,32 @@ namespace FlaxEditor.Surface.Archetypes
NodeElementArchetype.Factory.Output(0, "Result", typeof(Float4), 3),
}
},
new NodeArchetype
{
TypeID = 52,
Title = "Linear to sRGB",
Description = "Converts linear color into sRGB.",
Flags = NodeFlags.MaterialGraph,
Size = new Float2(150, 20),
Elements =
[
NodeElementArchetype.Factory.Input(0, "Linear", true, typeof(Float3), 0),
NodeElementArchetype.Factory.Output(0, "sRGB", typeof(Float3), 1),
]
},
new NodeArchetype
{
TypeID = 53,
Title = "sRGB to Linear",
Description = "Converts sRGB color into linear.",
Flags = NodeFlags.MaterialGraph,
Size = new Float2(150, 20),
Elements =
[
NodeElementArchetype.Factory.Input(0, "sRGB", true, typeof(Float3), 0),
NodeElementArchetype.Factory.Output(0, "Linear", typeof(Float3), 1),
]
},
};
}
}

View File

@@ -778,6 +778,22 @@ void MaterialGenerator::ProcessGroupMaterial(Box* box, Node* node, Value& value)
value = result;
break;
}
// Linear to sRGB
case 52:
{
const auto linear = tryGetValue(node->GetBox(0), Value::Zero).AsFloat3();
value = writeLocal(linear.Type, String::Format(TEXT("LinearToSrgb({0})"), linear.Value), node);
_includes.Add(TEXT("./Flax/GammaCorrectionCommon.hlsl"));
break;
}
// sRGB to Linear
case 53:
{
const auto sRGB = tryGetValue(node->GetBox(0), Value::Zero).AsFloat3();
value = writeLocal(sRGB.Type, String::Format(TEXT("sRGBToLinear({0})"), sRGB.Value), node);
_includes.Add(TEXT("./Flax/GammaCorrectionCommon.hlsl"));
break;
}
default:
break;
}