From 6cbdf12bcc78f9e8146e4c0aee60230f7b1035a6 Mon Sep 17 00:00:00 2001 From: Yum1x Date: Mon, 28 Apr 2025 05:18:05 -0300 Subject: [PATCH] feat(extra-natives/five): add support for configurable outline render technique Introduce `SET_ENTITY_DRAW_OUTLINE_RENDER_TECHNIQUE` to allow specifying custom shader technique groups for entity outlines, with a fallback to the default "unlit" technique. Introduce `RESET_ENTITY_DRAW_OUTLINE_RENDER_TECHNIQUE` native to restore the outline render technique to the default value. --- .../src/GamePrimitives_Outlines.cpp | 21 +++++- .../ResetEntityDrawOutlineRenderTechnique.md | 11 ++++ .../SetEntityDrawOutlineRenderTechnique.md | 64 +++++++++++++++++++ 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 ext/native-decls/sdk/ResetEntityDrawOutlineRenderTechnique.md create mode 100644 ext/native-decls/sdk/SetEntityDrawOutlineRenderTechnique.md diff --git a/code/components/extra-natives-five/src/GamePrimitives_Outlines.cpp b/code/components/extra-natives-five/src/GamePrimitives_Outlines.cpp index 066af7298a..f516061834 100644 --- a/code/components/extra-natives-five/src/GamePrimitives_Outlines.cpp +++ b/code/components/extra-natives-five/src/GamePrimitives_Outlines.cpp @@ -34,6 +34,10 @@ static int* currentShader; static int* g_currentDrawBucket; static CRGBA outlineColor{ 255, 0, 255, 255 }; + +constexpr const char* DEFAULT_SHADER_TECHNIQUE_GROUP = "unlit"; +static std::string g_shaderTechniqueGroupId = DEFAULT_SHADER_TECHNIQUE_GROUP; + class OutlineRenderer { @@ -432,7 +436,7 @@ static InitFunction initFunctionBuffers([]() SetBlendState(GetStockStateIdentifier(BlendStateDefault)); last = *currentShader; - *currentShader = _getTechniqueDrawName("unlit"); + *currentShader = _getTechniqueDrawName(g_shaderTechniqueGroupId.c_str()); // draw bucket 0 pls, not 1 // #TODO: set via DC? @@ -604,6 +608,21 @@ static InitFunction initFunctionScriptBind([]() } }); + fx::ScriptEngine::RegisterNativeHandler("SET_ENTITY_DRAW_OUTLINE_RENDER_TECHNIQUE", [](fx::ScriptContext& context) + { + std::string techniqueGroupId = context.GetArgument(0); + if (techniqueGroupId.empty()) + { + return; + } + g_shaderTechniqueGroupId = techniqueGroupId; + }); + + fx::ScriptEngine::RegisterNativeHandler("RESET_ENTITY_DRAW_OUTLINE_RENDER_TECHNIQUE", [](fx::ScriptContext& context) + { + g_shaderTechniqueGroupId = DEFAULT_SHADER_TECHNIQUE_GROUP; + }); + fx::ScriptEngine::RegisterNativeHandler("SET_ENTITY_MATRIX", [](fx::ScriptContext& context) { fwEntity* entity = rage::fwScriptGuid::GetBaseFromGuid(context.GetArgument(0)); diff --git a/ext/native-decls/sdk/ResetEntityDrawOutlineRenderTechnique.md b/ext/native-decls/sdk/ResetEntityDrawOutlineRenderTechnique.md new file mode 100644 index 0000000000..d04b3bf600 --- /dev/null +++ b/ext/native-decls/sdk/ResetEntityDrawOutlineRenderTechnique.md @@ -0,0 +1,11 @@ +--- +ns: CFX +apiset: client +game: gta5 +--- +## RESET_ENTITY_DRAW_OUTLINE_RENDER_TECHNIQUE + +```c +void RESET_ENTITY_DRAW_OUTLINE_RENDER_TECHNIQUE(); +``` +This function undoes changes made by [`SET_ENTITY_DRAW_OUTLINE_RENDER_TECHNIQUE`](#_0x68DFF2DD), restoring the original outline rendering behavior. The default render technique group is `unlit`. diff --git a/ext/native-decls/sdk/SetEntityDrawOutlineRenderTechnique.md b/ext/native-decls/sdk/SetEntityDrawOutlineRenderTechnique.md new file mode 100644 index 0000000000..a5eb1b50ac --- /dev/null +++ b/ext/native-decls/sdk/SetEntityDrawOutlineRenderTechnique.md @@ -0,0 +1,64 @@ +--- +ns: CFX +apiset: client +game: gta5 +--- +## SET_ENTITY_DRAW_OUTLINE_RENDER_TECHNIQUE + +```c +void SET_ENTITY_DRAW_OUTLINE_RENDER_TECHNIQUE(char* techniqueGroup); +``` +Sets the render technique for drawing an entity's outline. This function allows you to specify a technique group name to control how the entity's outline is rendered in the game. + +List of known technique group's: +``` +alt0 +alt1 +alt2 +alt3 +alt4 +alt5 +alt6 +alt7 +alt8 +blit +cube +default +geometry +imposter +imposterdeferred +lightweight0 +lightweight0CutOut +lightweight0CutOutTint +lightweight0WaterRefractionAlpha +lightweight4 +lightweight4CutOut +lightweight4CutOutTint +lightweight4WaterRefractionAlpha +lightweight8 +lightweight8CutOut +lightweight8CutOutTint +lightweight8WaterRefractionAlpha +lightweightHighQuality0 +lightweightHighQuality0CutOut +lightweightHighQuality0WaterRefractionAlpha +lightweightHighQuality4 +lightweightHighQuality4CutOut +lightweightHighQuality4WaterRefractionAlpha +lightweightHighQuality8 +lightweightHighQuality8CutOut +lightweightHighQuality8WaterRefractionAlpha +lightweightNoCapsule4 +lightweightNoCapsule8 +multilight +tessellate +ui +unlit +waterreflection +waterreflectionalphaclip +waterreflectionalphacliptint +wdcascade +``` + +## Parameters +* **techniqueGroup**: Technique group name.