isle-portable icon indicating copy to clipboard operation
isle-portable copied to clipboard

Incorrect material/lighting in race track

Open itsmattkc opened this issue 6 months ago • 43 comments

isle-portable's race track (at least on isle.pizza) features dirt that is too shiny: Image

How it is expected to look: Image

itsmattkc avatar Jun 06 '25 18:06 itsmattkc

Is your 2nd screenshot using SW or HW rendering?

foxtacles avatar Jun 06 '25 19:06 foxtacles

It is HW rendering (since that's all the works on Wine).

For reference, here's software rendering (RGB Emulation) on Windows:

Image

itsmattkc avatar Jun 06 '25 19:06 itsmattkc

Could you provide a save game that takes us to this section?

A shot from OpenGL would also be useful.

AJenbo avatar Jun 07 '25 00:06 AJenbo

There isn't really a save file that gets you here, you just have to go to the race track, build the car, and enter it.

itsmattkc avatar Jun 07 '25 00:06 itsmattkc

I think a similar artifact is the too extreme shininess on the Infomaniacs hat:

Image

If we can get that looking right then maybe that takes care of the race track.

foxtacles avatar Jun 07 '25 01:06 foxtacles

I think some of the grey walls around the island are also affected

Image

kernaltrap8 avatar Jun 07 '25 01:06 kernaltrap8

I'm not sure what exact values should be used to match how DirectX 5 did it's highlights and it's hard for me to adjust as I don't have the original game running anywhere.

You can adjust the formula for the highlights for the software renderer here and see if you can get results that match the original better: https://github.com/isledecomp/isle-portable/blob/bf24fa4a5791097544237be7ce14e2eaa5c10f49/miniwin/src/d3drm/backends/software/renderer.cpp#L206

AJenbo avatar Jun 07 '25 04:06 AJenbo

I think some of the grey walls around the island are also affected

Image

This appears to be the OpenGL 1.5 renderer? Note that it uses fixed function rendering meaning we do not have fine grained controls

You can adjust the lights specular color here:

https://github.com/isledecomp/isle-portable/blob/bf24fa4a5791097544237be7ce14e2eaa5c10f49/miniwin/src/d3drm/backends/opengl15/renderer.cpp#L277

And for the materials here: https://github.com/isledecomp/isle-portable/blob/bf24fa4a5791097544237be7ce14e2eaa5c10f49/miniwin/src/d3drm/backends/opengl15/renderer.cpp#L339

AJenbo avatar Jun 07 '25 04:06 AJenbo

I think a similar artifact is the too extreme shininess on the Infomaniacs hat:

Image

If we can get that looking right then maybe that takes care of the race track.

I did my best to match the highlights in that scene based on screen shots by others with what appeared to me as a sensible formula while referencing some technician details regarding d3drm lighting. I don't think I can do much better with what I have as I never played the game and do not have a good feel for what it should look like.

Maybe it's related to the fixed DirectX 5 highlights it wasn't really clear what they where supposed to be doing, just that they where not realistic.

AJenbo avatar Jun 07 '25 04:06 AJenbo

I think some of the grey walls around the island are also affected Image

This appears to be the OpenGL 1.5 renderer? Note that it uses fixed function rendering meaning we do not have fine grained controls

Oh, I must have forgotten to change config.

kernaltrap8 avatar Jun 07 '25 06:06 kernaltrap8

Well if any of you can try and tweak the highlight that would be appreciated 🙂

AJenbo avatar Jun 07 '25 13:06 AJenbo

If someone figures out the correct value for highlights in one of the 3 I'm happy to translate it to the two others.

AJenbo avatar Jun 07 '25 22:06 AJenbo

Perhaps it would be possible to make these variables configurable though the debug interface?

madebr avatar Jun 08 '25 20:06 madebr

Something like that could be a good idea, but right now there is only the material power value (appearance.shininess), but you could sure adjust the forumla to have a few properties that could be adjusted that way and make it easier find something suitable in real time. Would you be up for that? I don't really know how to integrate with the debug interface and I don't have any real idea of what to change about the formula either, it's really basic.

specular = angle of light ^ shininess * light color

AJenbo avatar Jun 08 '25 21:06 AJenbo

You can now modify the shininess in real time to help find the right value.

Just start the game with --debug and adjust the slider to a value where things look right. Please make sure to test your value in more then one context and let me know if there are different cases.

If you are unable to dial in the correct value it's also helpful if you can describe in what regards it's not modifying that needs to change.

The preferred driver to do this on is Software emulation, SDL_GPU should also be fairly accurate.

Image

AJenbo avatar Jun 10 '25 01:06 AJenbo

This would probably be the best scene to use for comparison (easy to get to and replicate, big shiny object with some curve), could some one get me a screen shot from the original of this?

Image

AJenbo avatar Jun 10 '25 02:06 AJenbo

software render d3drm

https://github.com/user-attachments/assets/fe6c2aa5-fa07-469f-a87b-fec2d023c81d

foxtacles avatar Jun 10 '25 02:06 foxtacles

Image

foxtacles avatar Jun 10 '25 02:06 foxtacles

Image

foxtacles avatar Jun 10 '25 02:06 foxtacles

Image

foxtacles avatar Jun 10 '25 02:06 foxtacles

Are the 3 shots all from the director software renderer? It looks like maybe it's more about angle then brightness?

AJenbo avatar Jun 10 '25 02:06 AJenbo

Are the 3 shots all from the director software renderer? It looks like maybe it's more about angle then brightness?

Yes all same software renderer, DirectX RGB. Yeah depending on the angle the light/shininess is very different

foxtacles avatar Jun 10 '25 03:06 foxtacles

https://github.com/user-attachments/assets/1b2bf999-e24c-47c5-9f3a-4f2f7080a37c

foxtacles avatar Jun 10 '25 03:06 foxtacles

I wonder if the DirectX 5 lighting model got broken at some point and running the game on newer systems causes it to produce DirectX 6+ style lighting.

AJenbo avatar Jun 10 '25 04:06 AJenbo

I think Matt has a windows 95 setup - maybe he can check

foxtacles avatar Jun 10 '25 04:06 foxtacles

Here's LEGO Island using RGB Emulation with DX5:

https://github.com/user-attachments/assets/cb0e3bf5-aa42-49a0-a8c6-e86cdec8863d

...and DX8:

https://github.com/user-attachments/assets/931bc3d4-c50f-48b5-9149-e55fa11fec92

StevenSYS avatar Jun 10 '25 05:06 StevenSYS

oh wow so there really is a difference depending on which version of DirectX you have, now I don't feel so bad for not exactly matching it :D

AJenbo avatar Jun 10 '25 07:06 AJenbo

In case anyone is good with shaders the implementatino used for the SDL_GPU is written in HLSL and the highlight portion can be found here:

https://github.com/isledecomp/isle-portable/blob/cb199a87282028351f03ed37ba48546e84ea55d6/miniwin/src/d3drm/backends/sdl3gpu/shaders/src/SolidColor.frag.hlsl#L67

AJenbo avatar Jun 11 '25 00:06 AJenbo

Reading a bit the difference of Ram and RGB emulation is that RGB does colored lights and Ramp doesn't, so there would be a difference there as well.

AJenbo avatar Jun 14 '25 01:06 AJenbo

I think I have gotten very close, it's not a perfect match for either but with there being multiple different ways they where implemented originally and vary sparse details regarding it I think this is the beset I can do: Image

Image

The highlight also behaves more like you would expect based on the viewing angle, my previous attempt was based on documentation that seems to have been more misleading then helpful.

For flat surfaces it looks very close to DirectX 8 and for small curves it's matching DirectX 5

AJenbo avatar Jun 14 '25 03:06 AJenbo