multitheftauto / mtasa-blue

Multi Theft Auto is a game engine that incorporates an extendable network play element into a proprietary commercial single-player game.
https://multitheftauto.com
GNU General Public License v3.0
1.41k stars 438 forks source link

engineApplyShaderToWorldTexture targetElement not working on every texture #2725

Open etrnl1337 opened 2 years ago

etrnl1337 commented 2 years ago

Describe the bug

can't apply engineApplyShaderToWorldTexture "shad_ped" texture for specific player, only for everyone.

Probably this works like that on other shadow's like for example car shadow, my question is why?

Code in steps to reproduce.

Steps to reproduce

  1. shadow.fx

texture reTexture;

technique ly
{
    pass P0
    {
        Texture[0] = reTexture;
    }
}
  1. Working code:

local texture = dxCreateTexture(1, 1)

local shader = dxCreateShader("shadow.fx")

engineApplyShaderToWorldTexture(shader, "shad_ped")

dxSetShaderValue(shader, "reTexture", texture)
  1. Not working code:

for i,v in ipairs(getElementsByType("player")) do

    if v and isElement(v) and getElementAlpha(v) == 0 then -- you can delete this to reproduce because that's my code that i need to work.

        engineApplyShaderToWorldTexture(shader, "shad_ped", v) -- returns true, but not applying...
        dxSetShaderValue(shader, "reTexture", texture)

    end

end

Version

cver: Multi Theft Auto v1.5.9-release-21261 sinfo: Server info for x.x.x.x Ver: 1.5.9-9.21238.0 AC: [Allowed client files: None] [Disabled AC: None] [Enabled SD: None] Voice: Disabled Glitches: None Bullet sync weapons: 22,23,24,25,26,27,28,29,30,31,32,33,34 Vehicle extrapolation: Disabled Tick rates: Plr:75 Cam:400 Ped:300 UnocVeh:300 KeyRot:75 KeyJoy:200 Syncer distances: Ped:100 UnoccupiedVehicle:130

Additional context

No response

Relevant log output

No response

Security Policy

PlatinMTA commented 2 years ago
dxCreateShader("shader.fx", 0, 0, false, "ped")

That should do it, by default shaders don't apply to peds.

etrnl1337 commented 2 years ago
dxCreateShader("shader.fx", 0, 0, false, "ped")

Doesn't change anything.

PlatinMTA commented 2 years ago

Well, I know for a fact that shaders do apply to players, so this is a non-issue. There is something wrong with your script.

etrnl1337 commented 2 years ago

Well, I know for a fact that shaders do apply to players, so this is a non-issue. There is something wrong with your script.

How can this work for everyone but when i indicate targetElement this doesn't work?

Someone was talking about this on mta forum a long time ago, i've double checked everything and it's MTA fault. If you don't believe my script just copy paste it and reproduce it and make it work 🥇

I'am saying that something is wrong when applying shader to shadow - not to player only.

PlatinMTA commented 2 years ago

Then it's the same thing with nitro, smokes and particles in general, they are from the world hence they aren't related to any element, so you can't do that to eliminate shadows sadly.

I don't think this can be solved easily, performance could be a concern. Someone from MTA Staff should know better. If this is looked into, then it would be nice to also look for other particles.

etrnl1337 commented 2 years ago

Then it's the same thing with nitro, smokes and particles in general, they are from the world hence they aren't related to any element, so you can't do that to eliminate shadows sadly.

I don't think this can be solved easily, performance could be a concern. Someone from MTA Staff should know better. If this is looked into, then it would be nice to also look for other particles.

I deduced this myself but wasn't sure if that's the reason, waiting for staff to answer with this.

Einheit-101 commented 1 year ago

We would need a function "getElementEffects" that returns all effects that are related to certain elements, for example chimney smoke, nitro, fire, shadows...