mtasa-blue icon indicating copy to clipboard operation
mtasa-blue copied to clipboard

Created objects don't reflect lights / shadows

Open ArranTuna opened this issue 5 years ago • 16 comments

Describe the bug Created objects (as maps) don't reflect objects light as world objects do, here go some examples:

Vehicle light in a world object: image

Vehicle light in a created object: image

Object (that's also created; it proves that the problem is with the object which should reflect the light, not the vehicle/object that produce the light) light in a world object:

image

Object light in a created object:

image

Additional context From https://bugs.mtasa.com/view.php?id=6576

ArranTuna avatar Sep 11 '18 21:09 ArranTuna

@ccw808 made the following comment:

As custom objects are movable, they seem to be treated like peds and vehicles. i.e. No projected textures such as headlight beams, blob and square shadows, blood etc.

Followed by a later comment:

Should be possible, I'll look into it soon.

Problems might be:

  1. GTA buildings only have z rotation (no x/y axis tilting), so the shadow/light effect may not work correctly for MTA objects which have x/y rotations.
  2. Performance - Maybe only do effect if fx quality is not low, or add an option in the video tab.

qaisjp avatar Sep 20 '18 21:09 qaisjp

i made an investigation and i found that function: CShadows::StoreShadowToBeRendered(uchar,RwTexture *,CVector *,float,float,float,float,short,uchar,uchar,uchar,float,bool,float,CRealTimeShadow *,bool) offset 0x707390

Last argument is bDrawOnBuildings and almost all time is 0 except for vehicles, where is set 1 is you're drive ( but this also not casting shadows ). i tried change this byte to 1 while calling function

MemSet((void*)0x7081A4, 0x1, 1);
MemSet((void*)0x536241, 0x1, 1);
MemSet((void*)0x707EBD, 0x1, 1);

but still ped/vehicle shadows not working on object created by createObject ( i tested with rotation x,y,z = 0 )

Performance - Maybe only do effect if fx quality is not low, or add an option in the video tab. there is condition in this function if ( CShadows::ShadowsStoredToBeRendered < 48u ) so you can't draw over 48 shadows

CrosRoad95 avatar Nov 03 '18 14:11 CrosRoad95

Look at 0x70ACB2. It explicitly selects buildings to draw shadows on.

CWorld::ms_aSectors.m_buildings

lopezloo avatar Nov 03 '18 14:11 lopezloo

I think I just found another problem that may be related to this.

The rain also doesn't collide with any object created by the createObject function.

To reproduce:

start the runcode resource /srun setRainLevel(3) under a normal GTA object, you will not see the rain. under an object placed by map editor or createObject function, the rain will be there.

Maybe this is also related to the camera clipping when we are inside vehicles (#1921), and deserves a little more attention?

Also, I already tried to flip all the faces of the object to see if it's the root problem but had the same results.

stoneage-mta avatar May 22 '21 14:05 stoneage-mta

The rain also doesn't collide with any object created by the createObject function.

That's because GTASA uses CULL zones to disable rain on certain parts of the map #1192

PlatinMTA avatar Sep 07 '21 18:09 PlatinMTA

is there any way to fix this problem?

BenhurPaz avatar Dec 22 '21 20:12 BenhurPaz

Screenshot

QQ截图20220104214809

It might be related to some flags, I just noticed not all the world objects will have 2dfx light cast on.

gta191977649 avatar Jan 04 '22 13:01 gta191977649

I just found some object that seems able to bypass this issue, try model 1719 It works on both SA exiting & MTA created object lighting.

Screenshots

1 unknown

gta191977649 avatar Jan 04 '22 19:01 gta191977649

the biggest problem is the map editor, below is an object in its original position, above the same object but created by the map editor. In this case only the native object receives the projection:

Screenshot

download

and this happens with new objects too, if you just replace the original model but keep its position without it being moved with the map editor you will continue to receive projections, however if you create this object with the map editor you lose the projections completely

Screenshot

download

pedrohenryz avatar Jan 19 '22 17:01 pedrohenryz

Okay so it's probably some per-object thing, rather than a ModelInfo one.

Pirulax avatar Jan 20 '22 19:01 Pirulax

Have any idea when this bug will be fixed? my team and I are developing a map from scratch and no objects in the scene receive light from vehicles or any light source, there are other problems like grass not being generated even when setting the col as it should but that is a problem for another topic.

BenhurPaz avatar Jul 25 '22 23:07 BenhurPaz

The bug will be fixed once the discussion leads to some kind of epiphany about what the issue is or someone decides to actually investigate and contribute with the solution (yourself included!) - MTA is an open source project.

Lpsd avatar Jul 26 '22 08:07 Lpsd

I see 2 possible ways to fix this issue:

  1. Add an option to create object as building, or even do it automatically basing on something (ID, mass, some flag...?). It would also fix #1921.
  2. Modify (hook into) shadow rendering function to make it also looking up for objects, which are either marked by script as supposed to be reflecting shadows or again - automatically basing on something (ID, mass, flag...).

lopezloo avatar Sep 16 '22 08:09 lopezloo

I think that the first option would be prefered. I still cant understand why we cant create "buildings".

PlatinMTA avatar Sep 16 '22 14:09 PlatinMTA

hello! , today I noticed something and then it came to my mind, I don't know how the engine works. however I believe it works like this, the weapons are nothing more than objects that when the player pulls it creates the object and attaches it correctly. and in this I believe that the parent of the object is set as the player who pulled it (I could be wrong, I don't know.) something else that I noticed that these objects, even modified, have 2dfx properties and I believe that even shadow properties.

I'm thinking of it as a possible solution by tut text that talked about not being able to reflect because of the objects created by mta being relatives and not supporting receiving the light property

Print: https://imgur.com/a/gc66W67 https://imgur.com/a/wL53ltR

iEriic avatar Jan 12 '23 09:01 iEriic

Look at 0x70ACB2. It explicitly selects buildings to draw shadows on.

CWorld::ms_aSectors.m_buildings

Yeah that's pretty much the issue I believe. m_buildings stores a list of CBuilding objects, not CObject (and createObject creates CObjects). The game however does store the list of CObjects in the repeat sectors, so adding some extra code should [possibly] solve the issue.

Pirulax avatar Oct 07 '23 20:10 Pirulax