Skip to content

Commit 405cf06

Browse files
committed
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.
1 parent 1eed77d commit 405cf06

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

code/components/extra-natives-five/src/GamePrimitives_Outlines.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ static int* currentShader;
3434
static int* g_currentDrawBucket;
3535

3636
static CRGBA outlineColor{ 255, 0, 255, 255 };
37+
38+
#define DEFAULT_SHADER_TECHNIQUE_GROUP "unlit"
39+
static std::string g_shaderTechniqueGroupId = DEFAULT_SHADER_TECHNIQUE_GROUP;
40+
3741

3842
class OutlineRenderer
3943
{
@@ -412,6 +416,9 @@ static InitFunction initFunctionBuffers([]()
412416
return;
413417
}
414418

419+
420+
static const char* chTechniqueGroupId = g_shaderTechniqueGroupId.c_str();
421+
415422
EnqueueGenericDrawCommand([](uintptr_t bucket, uintptr_t)
416423
{
417424
rage::grcTextureFactory::getInstance()->PushRenderTarget(nullptr, maskRenderTarget, nullptr, 0, true, 0);
@@ -432,7 +439,7 @@ static InitFunction initFunctionBuffers([]()
432439
SetBlendState(GetStockStateIdentifier(BlendStateDefault));
433440

434441
last = *currentShader;
435-
*currentShader = _getTechniqueDrawName("unlit");
442+
*currentShader = _getTechniqueDrawName(chTechniqueGroupId);
436443

437444
// draw bucket 0 pls, not 1
438445
// #TODO: set via DC?
@@ -604,6 +611,12 @@ static InitFunction initFunctionScriptBind([]()
604611
}
605612
});
606613

614+
fx::ScriptEngine::RegisterNativeHandler("SET_ENTITY_DRAW_OUTLINE_RENDER_TECHNIQUE", [](fx::ScriptContext& context)
615+
{
616+
std::string techniqueGroupId = context.GetArgument<const char*>(0);
617+
g_shaderTechniqueGroupId = techniqueGroupId.empty() ? DEFAULT_SHADER_TECHNIQUE_GROUP : techniqueGroupId;
618+
});
619+
607620
fx::ScriptEngine::RegisterNativeHandler("SET_ENTITY_MATRIX", [](fx::ScriptContext& context)
608621
{
609622
fwEntity* entity = rage::fwScriptGuid::GetBaseFromGuid(context.GetArgument<int>(0));
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
ns: CFX
3+
apiset: client
4+
game: gta5
5+
---
6+
## SET_ENTITY_DRAW_OUTLINE_RENDER_TECHNIQUE
7+
8+
```c
9+
void SET_ENTITY_DRAW_OUTLINE_RENDER_TECHNIQUE(char* techniqueGroup);
10+
```
11+
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.
12+
13+
Passing an empty string as the `techniqueGroup` parameter will reset the render technique to its default value.
14+
## Parameters
15+
* **techniqueGroup**: Technique group name.

0 commit comments

Comments
 (0)