Allow more element types as engineApplyShaderToWorldTexture targets - #5328
Open
Flashmyname wants to merge 4 commits into
Open
Allow more element types as engineApplyShaderToWorldTexture targets#5328Flashmyname wants to merge 4 commits into
Flashmyname wants to merge 4 commits into
Conversation
The objects behind pickups and projectiles are never registered in the object pool, so the render hook could not resolve them and a shader targeted at one matched nothing while the call still returned true. Resolve them in the entity render handler when the pool lookup misses. CPools::GetClientEntity is left alone, its other callers rely on getting NULL for these objects. Element types the render hooks cannot tell apart now fail with a script warning instead of silently returning true. Part of multitheftauto#1111.
Searchlights are not game entities, so the entity render hook never saw them. The cone is drawn by MTA itself, so tag that draw with the element around the RenderHeliLight call. The cone binds no texture and fell into the generic unnamed bucket together with every other untextured draw, so it gets a name of its own, "searchlight". The ground spot is stored with the texture the game also uses for the light pools of street lamps, so a copy of it is registered as "shad_searchlight" and a shader on the spots leaves the lamps alone. Part of multitheftauto#1111.
Radar blips are drawn one sprite at a time by CRadar::DrawCoordBlip with no game entity behind them. Hook both call sites, the regular pass and the one for the waypoint icon, and tag the draw through a game marker to element map kept by CClientRadarMarkerManager. Not covered: icons 0 and 1, which are drawn without a texture, blips the game creates itself, and the F11 map, which has its own textures. Part of multitheftauto#1111.
Markers have no game entity behind them either. Cylinders, arrows, rings and the checkpoint tube are C3dMarker objects, corona markers are registered coronas, and both carry the identifier MTA gave them, so hook the per-marker draw in the two render loops and resolve that identifier back to the element. The same corona hook, together with one on CHeli::RenderAllHeliSearchLights, covers the searchlight of a game helicopter, which is registered with the vehicle pointer plus 0xB as its id. Part of multitheftauto#1111.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
engineApplyShaderToWorldTextureaccepts any element astargetElement, but only vehicles, objects, peds and buildings could ever match, because the render hook resolves the drawn entity throughCPools::GetClientEntity. For everything else the call returnedtrueand did nothing. This PR adds the element types MTA draws itself, one commit per type:CClientSearchLight::Renderis tagged with the element. The cone binds no texture and used to fall into the generic unnamed bucket with every other untextured draw, so it gets a name of its own,searchlight. The ground spot shares the texture the game uses for street lamp light pools, so a copy is registered asshad_searchlight.CRadar::DrawCoordBlipcall sites are hooked and the draw is tagged through a game marker to element map.CHeli::RenderAllHeliSearchLights, also covers the searchlight of a game helicopter, resolved to its vehicle.Element types the render hooks cannot tell apart, colshapes and sounds for example, now return
falsewith a script warning instead of silently succeeding.Motivation
Fixes #1111. A shader can currently only be limited to a vehicle, object, ped or building. Tinting one pickup, one blip or one marker without touching every other element sharing the texture is not possible, and nothing tells the script that the call did nothing.
Behaviour worth noting: searchlight cones used to be reachable through the
unnamedtexture name, which matched every other untextured draw as well. They are nowsearchlight, andengineGetVisibleTextureNamesreports it.*keeps working.Test plan
Test resource attached, it spawns two of every element type in front of the player and tints the left one of each pair:
shadertargettest.zip
engineRemoveShaderFromWorldTexturerestores it.falseand logs a warning.The ground spot of a searchlight cannot be targeted per element. It is stored as a shadow and drawn later in one batch, when the owner is no longer known, so a shader on
shad_searchlighttints every spot at once. That is what the separate texture name is for.Checklist