|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
thugorgibson How do I cheat? Reputation: 0
Joined: 29 Jul 2021 Posts: 2
|
Posted: Thu Jul 29, 2021 10:43 am Post subject: Can a stencil buffer be used to draw shadows on screen ? |
|
|
I'm currently playing the original Just Cause on pc but, after seeing what the Xbox360 version has better than it, I decided to try and improve upon its look. The major issue I see in it is a shadow issue of some sort (maybe intended somehow): shadows are rendered much lighter on top of grass than on the roads. And at night time they completely vanish from any textures but the roads. This leads them to be almost unnoticeable, leaving the game world very bland and with low contrast.
While messing with Reshade and Special K, i've noticed the game renders shadows in the game world via a 1024x1024 "vertex buffer(?)" of some sort. Changing random values in Cheat Engine from "1024" to "2048" or "4096" was what eventually led me to this finding. When this "buffer"s width or height resolution gets changed, the shadows get completely misaligned from the world objects and move around with the camera perspective. I eventually stumbled upon the d3d9 tab on the top menu of Reshade, where this particular "buffer" shows up. Also, this "buffer" shows up in Special K under the "Live Render Target View" with a D24S8 format.
To the main question:
Would it be possible, either with Cheat Engine, a modified .dll or any other tool (e.g. Reshade), to use this "buffer"'s information to render new shadows in screen space atop the old ones or even replace them altogether?
Here's a link to an album with captioned images to better demonstrate my points, Just in Cause: imgur . com/a/rIirvl0
Thanks for reading!
|
|
Back to top |
|
|
atom0s Moderator Reputation: 198
Joined: 25 Jan 2006 Posts: 8518 Location: 127.0.0.1
|
Posted: Fri Jul 30, 2021 2:08 pm Post subject: |
|
|
I'll use Direct3D 9 as an example, but I'm not sure what that game uses specifically. Vertex buffers are a block of memory allocated for the GPU to make use of that holds vertices to be drawn. The way they are drawn is then up to the developer if it's just going to be drawn with a texture applied to it or ran through any number of shaders/passes. Vertices will vary in size based on their definition.
They are drawn by a call that can be made to several of D3D9's APIs such as:
- DrawPrimitive
- DrawPrimitiveUP
- DrawIndexedPrimitive
- DrawIndexedPrimitiveUP
When these are called, you tell the rendering API what is contained in the buffer that is being used to draw at the time. The 'PrimitiveType' param tells the API which type of entries are within the buffer, and then the remaining arguments for each call tell the API how to use the buffer properly.
The more common types used would be:
- D3DPT_TRIANGLELIST
- D3DPT_TRIANGLESTRIP
- D3DPT_TRIANGLEFAN
That means that each primitive would be constructed of points that make up a triangle, and then 'x' number of triangles are contained within the buffer.
When you increase the buffer size without actually adding more data, you shift the expected number of triangles in the buffer, without having any there to be drawn. So the API will land up applying the data to the wrong areas in the game, or culling things altogether depending on where they should have been applied.
Quote: | Would it be possible, either with Cheat Engine, a modified .dll or any other tool (e.g. Reshade), to use this "buffer"'s information to render new shadows in screen space atop the old ones or even replace them altogether? |
Possible, yes. But it wouldn't be as performant as it could be if you just disable the game's shadow system altogether and make your own. Trying to recreate better shadows in place of the old ones would require a ton of work/math/recreation in place to take what the game generated and make it look better. Shadows are generally done as a technique that uses parts of the scene during the rendering pipeline to be created. You would want to redo those same steps with better processing/techniques, and not just use the pre-genned information from their setup.
Depending on how things are being done, you could also potentially just fix/tweak their shadow generation to fix the problems without having to recreate/redo anything too. Or mod it to force the game to make bigger/higher quality shadows. Again this depends on how it's coded in the first place and if altering some settings/values would be possible.
The means of doing the shadows, in general, will also depend on how the game is designed and what methods they are rendering the shadows themselves. There's a handful of different ways shadows can be done, each with their own ups and downs, and in some cases, some may not be possible based on how the rest of the game is rendering.
_________________
- Retired. |
|
Back to top |
|
|
thugorgibson How do I cheat? Reputation: 0
Joined: 29 Jul 2021 Posts: 2
|
Posted: Sat Jul 31, 2021 9:59 am Post subject: |
|
|
Thanks for taking the time right such a detailed asnwer!
The game does happen to be using dx9, dunno if you took a look at the screens but the shadows appear to be laid out on said buffer and applied with a simple texture over the geometry. I thought going for a post processing route would be less taxing because my only gripe is with the shadows not being opaque enough - the thought ocurred to me that the info on the buffer could be intercepted and rendered on top of the final frame, maybe even with control on this new shadow's opacity through a Reshade like interface. Plus the game is compiled in such a way that accessing the mains files is impossible. Found a couple of ways to uncompress the arc files but only 4/5 can accessed, the main one, not being one of them. Would an approach like a d3d9 renderhook work ?
Thanks!
|
|
Back to top |
|
|
atom0s Moderator Reputation: 198
Joined: 25 Jan 2006 Posts: 8518 Location: 127.0.0.1
|
Posted: Sat Jul 31, 2021 10:40 pm Post subject: |
|
|
Quote: | my only gripe is with the shadows not being opaque enough |
If this is what you're looking to alter, then I'd suggest modifying the shadow texture(s) and altering their opacity, or hooking to the games rendering system and find where its handling shadows and alter how they are drawn there. Changing the color applied against the texture or the opacity itself shouldn't be that much trouble.
The shadow texture is more than likely either a basic square that has 2 colors or a gradient 'ball' that fades from white to black which is then applied to the vertex buffer when drawn. Altering the texture should be enough to change how the opacity is though or just hooking onto the vertex definition setup and altering the color if its using that part in the definition.
_________________
- Retired. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|