Skip to content

Conversation

@Xenius97
Copy link
Contributor

This PR targets the fxAddShadow function.
Originally developed by CrosRoad95, the code was forgotten after he left, despite being very useful. I have reassembled the function based on the original PR, fixing the known issues (#1003).

Key Changes:

  • Modernized parts of the code, currently, no crashes or issues have been observed.
  • Removed the plane shadow type, which previously caused crashes. Based on my research, such a texture does not exist.
  • According to GTA Reversed and the original SA code, only the following shadow textures exist:
ShadowCarTex = *(RwTexture**)0xC403E0;
ShadowPedTex = *(RwTexture**)0xC403E4;
ShadowHeliTex = *(RwTexture**)0xC403E8;
ShadowBikeTex = *(RwTexture**)0xC403EC;
ShadowBaronTex = *(RwTexture**)0xC403F0;
ShadowExplosionTex = *(RwTexture**)0xC403F4;
ShadowHeadLightsTex = *(RwTexture**)0xC403F8;
ShadowHeadLightsTex2 = *(RwTexture**)0xC403FC;
gpBloodPoolTex = *(RwTexture**)0xC40400;
gpHandManTex = *(RwTexture**)0xC40404;
gpCrackedGlassTex = *(RwTexture**)0xC40408;
gpPostShadowTex = *(RwTexture**)0xC4040C;

Script syntax is the same as original:

bool fxAddShadow ( [ string shadowType, ] Vector3 position, Vector2 offsetA, Vector2 offsetB [, int color = 0x80FFFFFF, float zDistance = 4, bool drawOnWater = false, bool drawOnBuildings = true ] )

Test code:

local shadows = {
	"car", "ped", "heli", "bike", "rcbaron", "explosion", "headlight1", "headlight2", "blood", "handman", "wincrack", "lamp"
}

addEventHandler("onClientPreRender", root, function()
	local x, y, z = getElementPosition(localPlayer)
	for i, shadowType in ipairs(shadows) do
		fxAddShadow(shadowType, x + i * 2, y, z, -1, 0, 0, 1, tocolor(255, 255, 255, 255), "default", 10, false, false)
		fxAddShadow(shadowType, x + i * 2, y + 2, z, -1, 0, 0, 1, tocolor(255, 255, 255, 255), "default", 10, false, true)
		fxAddShadow(shadowType, x + i * 2, y + 4, z, -1, 0, 0, 1, tocolor(255, 255, 255, 255), "default", 10, false, true)
		fxAddShadow(shadowType, x + i * 2, y + 6, z, -1, 0, 0, 1, tocolor(255, 255, 255, 255), "default", 10, false, true)
		fxAddShadow(shadowType, x + i * 2, y + 8, z, -1, 0, 0, 1, tocolor(255, 255, 255, 255), "default", 10, false, true)
		fxAddShadow(shadowType, x + i * 2, y + 10, z, -1, 0, 0, 1, tocolor(255, 255, 255, 255), "default", 10, false, true)
	end
end)

@tederis
Copy link
Member

tederis commented Nov 19, 2025

It would be great to have an ability to draw a custom texture. I have already added it, but did not have time to create a PR. You could try to add it yourself or it can be added later.

@Xenius97
Copy link
Contributor Author

It would be great to have an ability to draw a custom texture.

It's possible, but i need to figure out how it works. All this needs is an RwTexture.

@tederis
Copy link
Member

tederis commented Nov 20, 2025

It's possible, but i need to figure out how it works. All this needs is an RwTexture.

RwTexture internally holds a pointer to DX9 texture. So you can create a fake RwTexture instance and assign any DX9 texture(and even RT) to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants