mtasa-blue
mtasa-blue copied to clipboard
Created objects don't reflect lights / shadows
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:
Vehicle light in a created object:
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:
Object light in a created object:
Additional context From https://bugs.mtasa.com/view.php?id=6576
@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:
- 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.
- Performance - Maybe only do effect if fx quality is not low, or add an option in the video tab.
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
Look at 0x70ACB2. It explicitly selects buildings to draw shadows on.
CWorld::ms_aSectors.m_buildings
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.
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
is there any way to fix this problem?
Screenshot
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
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
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
Okay so it's probably some per-object thing, rather than a ModelInfo
one.
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.
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.
I see 2 possible ways to fix this issue:
- 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.
- 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...).
I think that the first option would be prefered. I still cant understand why we cant create "buildings".
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
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 CObject
s).
The game however does store the list of CObject
s in the repeat sectors, so adding some extra code should [possibly] solve the issue.