Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The problem with the gloss, shaders on cars in TOCA Race Driver 2 (2004) in all versions d3d8to9 #60

Closed
wetcoder opened this issue Jan 19, 2018 · 12 comments · Fixed by #62

Comments

@wetcoder
Copy link

wetcoder commented Jan 19, 2018

Intel(R) HD Graphics (Gen7LP) - Intel(R) Atom(TM) CPU Z3795
Microsoft Windows 10 Home (64-bit) v1709 build 10.0.16299.192 (Win10 RS3)

TOCA Race Driver 2 v1.2

this error occurs only in this game, using d3d8to9 in other games (there is no such problem)
please fix this "error" in d3d8to9

a
a2
a4
a5
b
b1
b2
b5

@wetcoder wetcoder changed the title The problem with the gloss on cars in TOCA Race Driver 2 (2004) The problem with the gloss, shaders on cars in TOCA Race Driver 2 (2004) in all versions d3d8to9 Jan 19, 2018
@elishacloud
Copy link
Contributor

@wetcoder, I have had some problem getting the game to work on Windows 10 and so have not looked into the issue yet. Can you tell me how you got it working on Windows 10?

Also can you send me a copy of the log file?

@wetcoder
Copy link
Author

wetcoder commented Feb 27, 2018

@elishacloud

bandicam 2018-02-27 22-42-02-847

TOCA Race Driver 2 v1.2 works on Windows 10 without any problems with NOCD
(works even without any compatibility modes)
The retail version has StarForce DRM that needs to be removed using NOCD

Here is my d3d8.log (d3d8to9 v1.7.0)

default

@elishacloud
Copy link
Contributor

Thanks, I was able to get the game to run once I patched it to version 1.2. :-)

I can reproduce the issue now.

@elishacloud
Copy link
Contributor

elishacloud commented Feb 28, 2018

The reason v1.4.0 and v1.5.0 look different is because of an issue with the CreatePixelShader where the PixelShader failed to compile. The issue was introduced in v1.4.0 with check-in 5d3fb1a line 1756 and was fixed in v1.6.0 with check-in 26f482b line 1699-1700.

As far as the missing gloss on cars that has existed in all versions of d3d8to9 as far back as v1.3.0 (probably back to v1.0.0). More work needs to be done to figure out why the gloss is missing.

@elishacloud
Copy link
Contributor

The issue is with the very first PixelShader created. It looks like this:

    ps_1_1
    tex t0
    tex t1
    tex t2
    mul r0.xyz, v0, t1
  + mov_sat r0.w, c0.w
    mul r0.xyz, t0, r0
  + add_sat r1.w, t0.w, 1-c2.w /* this line has the issue */
    mul_x2 r1.xyz, t2, t0
  + mul_sat r1.w, r1.w, v0.w
    lrp r0.xyz, r0.w, r1, r0
  + mul r0.w, 1-t0.w, 1-r1.w
    lrp_x2 r0.xyz, r1.w, t2, r0
  + mov_sat t3.w, c0.z
    lrp r0.w, t3.w, 1-r0.w, t0.w

The problem is with the 8th line that says + add_sat r1.w, t0.w, 1-c2.w. In this line the constant c2 has the 1- modifier on it, which is not allowed in d3d9. In older versions (prior to v1.4.0) of d3d8to9 the modifier was simply dropped. In the latest version (v1.7.0) this shader is converted to ps_1_4 and the modifier remains. However in both cases the glossy finish is lost.

I am not sure why converting to ps_1_4 does not fix this. Below is the converted ps_1_4 code. If anyone sees an issue here let me know.

    ps_1_4 /* converted */
    def c1, 0, 0, 0, 0 /* added line */
    phase
    texld r2, t2
    texld r1, t1
    texld r0, t0
    mov r3, c2
    mul r1.xyz, v0, r1
  + mov_sat r4.w, c0.w
    mul r1.xyz, r0, r1
  + add_sat r5.w, r0.w, 1-r3.w
    mul_x2 r5.xyz, r2, r0
  + mul_sat r5.w, r5.w, v0.w
    lrp r1.xyz, r1.w, r5, r1
  + mul r1.w, 1-r0.w, 1-r5.w
    lrp_x2 r1.xyz, r5.w, r2, r1
  + mov_sat r3.w, c0.z
    lrp r1.w, r3.w, 1-r1.w, r0.w

I created a quick hack for Race Driver 2 by manually hard coding ps_1_1 PixelShaders that work. Below is the patch. However this only fixes the issue for this one game. I need to figure out a better generic solution.

Here is the patch for Race Driver 2: d3d8.zip

@wetcoder
Copy link
Author

wetcoder commented Mar 1, 2018

@elishacloud
Thank you so much!
The colors on the windshield and the body of the car differ slightly.
Such a feeling that there is not enough of a layer and because of this the color / reflection effect is slightly different (but this is a trifle)

rd2 2018-03-01 19-55-47-485
rd2 2018-03-01 19-55-47-486
rd2 2018-03-01 19-55-54-998
rd2 2018-03-01 19-56-32-015

Is it possible to somehow disable log file creation when using d3d8tо9.dll?

@CookiePLMonster
Copy link
Contributor

Logs don't feel useful for end users at this point, I vote for them to be disabled by default IMO.

@wetcoder
Copy link
Author

wetcoder commented Mar 1, 2018

Simply, I run games from compressed images (ISZ - UltraISO compressed ISO image format) in which the log file can not be written.
And when I start the game, I get the corresponding error about creating a log file

@CookiePLMonster
Copy link
Contributor

Anyway, it is possible to opt-out of logging by defining D3D8TO9NOLOG in the code.

@elishacloud
Copy link
Contributor

I created a tool called dxwrapper and while it does not have the logs fully disabled it does log less data. Also it has a feature to automatically load the ISO when the game starts and automatically unload the ISO when the game ends. No need to use UltraISO!

  1. Unzip these 3 files to the Race Driver 2 folder where RD2.exe exists: d3d8.zip
  2. Copy the Race Driver 2 ISO file into this folder and rename it to rld-toc2.iso.
  3. Start the game and enjoy.

Note: this already has the glossy finish fix.

As far as the color issue, I don't believe that is related to this fix. The same issue happens with True Crime: New York City, see here. I suspect it has something to do with the D3DFORMAT being different in d3d9. I am planning to look into the color issue when I look into issue #42.

@wetcoder
Copy link
Author

wetcoder commented Mar 1, 2018

@elishacloud
I meant that I store and run games directly from compressed iso files (ISZ) (to save space on the hard drive). Ie, I do not need original disks to run games - in my case, games do not have any DRM.
Approximately as disks with games for consoles, where games are started directly from disks.

I do not have installation iso with distributions - I have (ISZ) that I myself create from folders with already installed games in the UltraIso
I just mount the ISZ file with WinMount, it opens as a folder in the explorer (essentially a virtual disk) and then i just run the exe file of the game.
For example, Cuphead after installation takes 11 GB, but if you compress it into ISZ, it weighs only 2.29 GB
The point is that most games have gaming archives with little compression, and some even gaming archives without compression - both can be compressed even more and after compression (up to 10 times) weigh approximately as a repack version - well, in any case, less than the distribution with the game
And since the games are already installed and compressed (no need to store distributions and reinstall them, this is very convenient especially for old games), they can be run from any storage device and computer (in some cases it is required to add certain entries to the registry created after the installation of the game and which require some games)
This works with all games that do not save settings and save files to the game folder (with the exe file)

bandicam 2018-03-02 03-27-30-376

As an option I will use dxwrapper which does not create a log file
if you added support for ISZ files in dxwrapper (automatically load the ISZ when the game starts and automatically unload the ISZ when the game ends. No need to use UltraISO! OR ANY similar tool), I could definitely use it.
It would be cool

crosire added a commit that referenced this issue Mar 1, 2018
crosire added a commit that referenced this issue Mar 1, 2018
@elishacloud
Copy link
Contributor

You could try using the new LZX compression in Windows 10. It is not quite as good compression as compressed iso file (ISZ) but much easier to manage and no need for UltraISO.

if you added support for ISZ files in dxwrapper (automatically load the ISZ when the game starts and automatically unload the ISZ when the game ends. No need to use UltraISO! OR ANY similar tool), I could definitely use it.

DxWrapper can run any CLI. So if you have a CLI (or a batch file) that can load UltraISO and then unload it when done, this should work already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants