mastercomfig / tf2-patches

Team Fortress 2, but with a lot of fixes, QoL improvements and performance optimizations!
Other
216 stars 26 forks source link

set $raytracesphere to 0 on any eye_refract material #11

Open Xephobia opened 4 years ago

Xephobia commented 4 years ago

Hi, I don't know where to look to see game materials, but the $raytracesphere material is useless and ruin performance, it has been disabled on openfortress and team fortress 2 classic

Zionner commented 3 years ago

Would we want to leave this functionality in, for later, but disable the effect? Or remove this outright from the shaders?

Zionner commented 3 years ago

I've had a look into this. It seems easy enough to completely strip out, if that's the route we want to take. The only rough part we might run into is we'll likely need to recompile some shaders. Is that a big problem for us? Also, I don't know how engine tools would handle materials with shader params that no longer exist.

int-72h commented 3 years ago

Well we could try. Maybe a stub shader which does nothing would solve the latter issue.

Zionner commented 3 years ago

I've stripped out the related code from the engine & shaders. I've been having some trouble recompiling the shaders so far, as the shader compiler crashes often. I haven't found any helpful logs or errors yet to go with that.

Running the engine changes without the shader changes hasn't made any obvious rendering changes, though there is now an error in the console for failing to load a shader bundle.

Right now I'm continuing to look at the shader changes, and trying to figure out why the shader compilers are crashing.

Yttrium-tYcLief commented 3 years ago

Can anyone document what this shader actually does (looks like), exactly where it's used, and how much of a performance hit it provides?

Arbitrarily removing/disabling shaders seems like a bad idea and can cause plenty of unforeseen regressions. It might be better to just fix the performance problems in the first place.

Zionner commented 3 years ago

From what I've read inside the shaders, while investigating this. The shader mentions this is a fix for some kind of artifacting that can occur with non-spherical eye geometry. The comment reads as:

// Ray cast against sphere representing eyeball to reduce artifacts from non-spherical morphed eye geometry //

I can't comment on exact performance hits yet, but I will point out that enabling this parameter introduces a Sphere-Ray intersection in a pixel shader, which seems pretty slow to me. At least for older hardware. Another thing to note, is this is compile d out for shader model 2.0.