Add Linear to sRGB and sRGB to Linear nodes to materials
This commit is contained in:
@@ -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),
|
||||
]
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user