![]() |
|
Possible suggestion as to workaround shearing's lighting issues - Printable Version +- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk) +-- Forum: Feedback (https://teamscm.co.uk/forum-9.html) +--- Forum: Suggestions and improvements (https://teamscm.co.uk/forum-11.html) +--- Thread: Possible suggestion as to workaround shearing's lighting issues (/thread-3774.html) |
Possible suggestion as to workaround shearing's lighting issues - The17thDoctor - 20-01-2023 We've learned to just go by the fact that shearing modifies lighting in ways that are not necessarily wanted. I tried asking on the garrysmod-issues github for a possible fix with sadly no answer from facepunch. However, someone on my thread raised the interesting fact that it could be intentional if shearing (enableMatrix) also was shearing normals. So my thought was that if enableMatrix was shearing normals in a certain way, wouldnt recalculating the normals by multiplying them by the inverse matrix and feeding that to the entity as its new normals could potentially work around those lighting issues ? Purely a thought, there might be many strings attached that I dont see as I dont have much experience with GLua in general, but thought I'd put that here. Tell me what you think and if this would work. RE: Possible suggestion as to workaround shearing's lighting issues - Person8880 - 20-01-2023 The normals are only part of how VertexLitGeneric materials calculate lighting. There's also tangent data which is likely being modified by the shearing too. Inverting this back to the original wouldn't produce the right results, the surfaces have changed so their normals should point in the new direction and their tangents should also be updated. However, there's no easy way to alter the visual mesh of arbitrary entities in a way that properly respects lighting. Just drawing a mesh instead of the entity will likely still mess up lighting. There's an entity hook for it specifically to allow custom meshes to be lit properly, but that's only called for scripted entities, some of which will already be using it internally. Ideally there'd be an Entity:SetMesh() method to override any entity's model with a mesh, but that doesn't exist. There might be a few others things I could try, but it gets into the realms of major hacks pretty quickly. Maybe at some point I can try to see if I can correct the lighting on a dummy entity with shearing first, then if that works maybe it would be worth the hacks needed to override entity rendering. RE: Possible suggestion as to workaround shearing's lighting issues - The17thDoctor - 20-01-2023 (20-01-2023, 07:12 PM)Person8880 Wrote: [...] Ideally there'd be an Entity:SetMesh() method to override any entity's model with a mesh, but that doesn't exist. This might be something global enough and interesting enough for everyone (not TSCM alone) to suggest, I might suggest it on gmod's suggestion repo RE: Possible suggestion as to workaround shearing's lighting issues - mariofludd - 21-01-2023 (20-01-2023, 09:56 PM)The17thDoctor Wrote:(20-01-2023, 07:12 PM)Person8880 Wrote: [...] Ideally there'd be an Entity:SetMesh() method to override any entity's model with a mesh, but that doesn't exist. if you dont need to change gmod's binaries to do it, you can make it, and then make a PR in gmod's actual repo RE: Possible suggestion as to workaround shearing's lighting issues - The17thDoctor - 21-01-2023 (21-01-2023, 09:40 AM)mariofludd Wrote:(20-01-2023, 09:56 PM)The17thDoctor Wrote:(20-01-2023, 07:12 PM)Person8880 Wrote: [...] Ideally there'd be an Entity:SetMesh() method to override any entity's model with a mesh, but that doesn't exist. Sadly I think that the entity code is all in C++ so it means its FP's work to implement. |