ac-custom-shaders-patch / acc-extension-config

Configuration files for Assetto Corsa Custom Shaders Patch
227 stars 223 forks source link

Compatibility of new glass shaders for complexer materials #20

Closed Yeahone01 closed 4 years ago

Yeahone01 commented 5 years ago

Hello gro-ove,

First of all I want to thank you for contributing these extremely helpful files. Recently I began trying to apply the new shaders to other parts than just carpaint. I have found ways to make them adjust to pretty much any material but the glass shader is so complex I simply fail to replicate it. Would it be possible to make it usable for ksPerPixelNM ? A lot of the 'newer' Kunos cars have a secondary texture that is used for normal details. So far your new glass shaders can only be applied to glass types using just one texture file like f. e. ksPerPixelReflection .

CSP v.0.1.25-preview198, SOL 1.3.1

gro-ove commented 5 years ago

Hello, could you please name a car like this? Those are headlights, right?

Yeahone01 commented 5 years ago

Thank you for your answer. Actually ksPerPixelNM already is supported. The glass (yes, in most cases light glass) went black because of the alpha settings for the specific material. For example the 2015 Ford Mustang GT can be fixed with the following code fragment:

[SHADERREPLACEMENT...] MATERIALS = EXT_Windows PROP_0 = isAdditive, 2

Now the windows will not turn black, when their material is assigned to the new glass shader:

[INCLUDE: common/materials_glass.ini] ExteriorGlassTintedMaterials = EXT_Windows

Of course this depends on how Kunos has set up the alpha for materials. In some cases they just will be transparent and loose their normal detail. Then the isAdditive prop is unneccessary.

I also found out that some cars (so far I know about the vintage Abarth 595 and the Ford Escort MkI) the paint will not reflect the environment anymore, when one of the Carpaint shaders is applied. The following example is my current solution:

[INCLUDE: common/materials_carpaint.ini] CarPaintMaterial = EXT_Body_paint, INT_Occ_paint [Material_CarPaint_Solid] PROP_0 = isAdditive, 2

Now the car is supporting the new Carpaint shader and reflections on the bodywork will be working again.

Unfortunately the way Kunos configured materials on their cars differs a lot even when the effects they were trying to achieve are the same. It really is a mess.

There are even cars (f. e. Porsche Macan Turbo) where the headlights will loose their emissive when a chrome shader is applied to their surroundings because the mesh which is set to throw the beam (when headlights are switched on) often is using the same material like the chrome on trim parts. The only way I have found to make this work is by forging a new material with Content Manager for the mesh which is assigned to the emissive so that these few polygons will not be effected by the chrome shader.

Sorry for the late and long answer, I looked into this section every day but somehow your reply was not displayed.

gro-ove commented 4 years ago

Very sorry for the delay, glass will be fixed with the upcoming update! I tried to fix a lot of other issues appearing when SHADER_REPLACEMENT affects a mesh referenced somewhere else (the main problem was that during lights initialization, it would store a pointer to material’s ksEmissive variable, but changing shader later would invalidate all previous variables).

As for isAdditive, I’ll try to figure out what’s wrong with car paint shader so it acts like that with a non-two value, although, possibly, those templates could set it to 2 forcefully too, since it’s a common value for car paints.

Yeahone01 commented 4 years ago

No need to apologize, this became a huge project and overall it is just awesome, because it is lifting Assetto Corsa to a whole new level. I am slowly making progress understanding how this stuff works. So far I made different material configs for about 50 Kunos cars. Do you mind looking on some of them and share your opinion?

gro-ove commented 4 years ago

Oh, of course, that would be awesome! Also, if you want, I’d be glad to invite you in these repos.

Yeahone01 commented 4 years ago

Okay, so here is the first one: Alfa Romeo 33 Stradale ks_alfa_33_stradale.zip

(everything is adjusted for CSP 1.35 and SOL 1.4 beta 2)

I included your part for the refracting lights because I struggled to replicate that realistic look with the earlier shaders. Maybe you have the answer to why the brake lights do not work anymore? My edits start at the bracketed INCLUDE section. I tried to make material adjustments to pretty much everything except plastic.

You will notice that I commented out the leather shaders. The reason is that with interior masking active the environment reflection is just too powerful even with reflectance at almost 0. Once you hit any curb the colors wil flash over the leather parts. I do not consider this realistic and it also distracts a lot while driving at high speeds. Deactivating interior masking does not help either because than refracting headlights will only work at a certain distance. Even with the 3rd person camera the light clusters simply turn black.

I know, the coding can definitely be improved but for me the effect ingame is what counts. So, please, before you judge simply put the file into your loaded folder and lauch Assetto with the Alfa at Imola, Monza, Silverstone or Spa.

Thank you in advance.

gro-ove commented 4 years ago

Please try v0.1.36, I added proper IBL, now those PBR shaders should look much better when roughness is high. And I’ll fix the way it works with interior masking disabled, although I’d recommend to keep it on.

Not sure what’s wrong with rear lights, they seem to work here… Maybe I’m missing something?

As for config, I think it looks great! Although have to say, I feel a bit strange seeing car paint shaders used for metal parts outside. I’d want to try and keep new things more semantically accurate, but, on the other hand, maybe it could make sense to just use some car paint shader for all the exterior materials, so dirt and damages could appear all over the car… I’ll need to think about it some more, I think it’s either that or PBR shaders for exterior.

Yeahone01 commented 4 years ago

Thank you, the interior shaders seem to have been improved, have to test the leather shaders on more cars to make a final decision.

The rear lights on the Alfa Romeo 33 Stradale are fine, only the brake lights do not work (also with CSP v0.1.36).

Glad, that you like the new look. I try to replicate what we are used to by Gran Turismo Sport and Forza Horizon 4, also using a lot of real life pictures as reference. To be honest, vanilla AC shaders now look bland and too bright to me, so I try to adjust them one by one and am pretty satisfied with the results.

As I mentioned before, the coding is quite a mess. Honestly I would like to apply car paint shaders to pretty much any metal material. It just does not work because Kunos often uses simpler and therefore incompatible shaders like ksPerPixelReflection for chrome and other shiny stuff. Your interior shaders (PBR they are called?) are compatible with most of the vanilla materials. On the other hand they often simply appear to bright even with Brightnessadjustment at 0. Then I have to use the old fashioned [SHADERREPLACEMENT...] in order to achieve the desired visuals. I even sometimes apply the new glass shaders for metal materials. Questionable, but in my opinion the results speak for themselves.

Speaking of which, here are 3 additional cars for to judge if you like: (tested with CSP v0.1.36 and SOL 1.4 beta 3)

ks_alfa_giulia_qv, ks_corvette_c7_stingray, ks_porsche_911_gt3_rs (2).zip

Finally found a way to fix the outer rear light texture on the Porsche 911 GT3 RS. Should have been red from the beginning.

The Corvette Stingray appears like night and day compared to vanilla AC and is the most expiremental of the bunch.

Very proud about how the Alfa Romeo Giulia QV turned out. Making the headlight projector lenses less see-through and the window glasses more dark was a real challenge until I found out how to further exploit the glass shaders. The outer frames of the headlights (GEO_headlights_SUB1) should not be so shiny but unfortunately Kunos connected them with the (Alfa Romeo) engraved brace above the side reflector, which on the real life counterpart clearly is chromed. Also they seem to have forgotten to model the chrome rings which frame the procector lenses. The only way to fix this would be to open the KN5 file and edit the 3D model. I failed to apply seperated carpaint shaders to the different skins (Solid for gloss and Metallic for - well, metallic). Therefore, this is commented out. It worked on other cars in the past but I have not tried it in a long time.

gro-ove commented 4 years ago

Thank you! Got some news you might like: now glass can properly colorize stuff behind: https://acstuff.ru/u/comparison/JhP

Also, made a new license plate shader: https://i.imgur.com/k3InNXc.jpg https://i.imgur.com/S5k2D12.png

And now, reflective shaders got an option for colorized speculars and reflections, helping with some other things too: https://acstuff.ru/u/comparison/y7g

I’ll prepare detailed documentation on all that stuff tomorrow.

Yeahone01 commented 4 years ago

You are working on so many different features, so I am thankful for your replies even though there are some long periods of time in between them.

Checked the Alfa Stradale yesterday. Whatever you did, the brake lights are working now.

Looks like great progress judging by the comparison pictures you posted above. License plates are another weak spot on ACs vanilla road cars. Seems like you added the third dimension depth they sorely needed. I guess the only difference on the Maserati Quattroporte GTS is the amber side reflector, correct? Eagerly waiting for the aforementioned documentation but please take your time.

I am not quite gifted at taking screenshots but can provide you the configs for 3 more Kunos cars. Even if you might not like the way how I currently handle the shader assignments, the results look very good in my eyes. Nevertheless I am open for feedback and improvement suggestions. Mainly I use the content manager showroom (to get the correct material and mesh names) and replay files to tweak the shaders. It would be awesome beeing able to use the same (or similar) ingame app which already is available to setup headlights refraction for all types of car shaders (materials).

ks_lamborghini_aventador_sv, ks_ferrari_812_superfast, ks_ruf_rt12r.zip

gro-ove commented 4 years ago

I’m so sorry about another delay… I hope recent PBR update didn’t mess things up too badly. Sorry, a bit later I’ll prepare detailed description of how it’s better to prepare those configs, but right now, I’m trying to get rain working asap.

There is object inspector app for selecting and inspecting meshes quickly, in Patch Apps section. As for feedback, I recently realized I was wrong suggesting to use 1 for fresnelMaxLevel (while working on PBR update), now I have to go and rethink optimal parameters. And maybe prepare PBR materials for exterior too, although first I need to be sure PBR is more or less correct. Not like it was before.

Yeahone01 commented 4 years ago

As I mentioned earlier, there is no need to apologize. I hope you're all right. At first I was a bit annoyed when v0.1.47 (and that includes v0.1.48) came out and had to rework my last finished cars. Then I realized the improvements. The interior masking now does work much more smoothly. But there are some things that were better before: - Glass shaders: When used for light covers, the ksAmbient value must be increased, otherwise they look tinted from certain angles. - Carbon fiber shaders: Too dark and (sorry) too bland now on most cars, especially in the interior view. Also, the effect of brightly highlighting certain checkers in direct sunlight was honestly better before. -Leather shaders: Difficult to handle. Maybe too complex for my skill level. Mostly went back to the use of shaders from the time before the v2 and increasing reflection by a factor of 5 or 10 to achieve a smooth and soft surface. -Metal shaders: Please keep the pre-V2 materials (and also my favorite metal shaders in the car paint file). I still have to find the twist when using v2. Their additional texture does not work well with factory fresh metal materials on Kunos cars. On the other hand, your recently released interior shaders for used metal look add a nice patina on certain parts of vintage cars like f. e. exhaust pipes or steering wheel center plates (BMW E30 M3 Group A, f. e.)
One thing I noticed with carbon and glass shaders which I sometimes used on parts like brake calipers (my mistake, you mentioned your opinion on this in your post of December 25th): Unfortunately since v1.47 they both overwrite textures, so that color and details (like written text on a brake caliper) get lost. Granted, there are still options like HasDetailNormals, OcclusionSource or UseCarbonDetails to take this into account, but it has become much harder to figure this out and I still do not like the results. It simply looked better until v0.1.46

Again, I respect your work absolutely, please consider what I have written as constructive feedback. As far as I am concerned, there was no need to rewrite the shaders that much, even before v0.1.47 I found ways to make pretty much any material appear the way I intended it to.

gro-ove commented 4 years ago

Thank you for the feedback!

There were a couple of major issues with old PBR shaders causing that change. Main one, I mistakenly thought F90 refers to reflection intensity for grazing angles, and I saw that F90 = F0 × 50 formula in a couple of presentations, which threw me off and lead me to that idea that any material should be pretty much fully reflective, and 1 is a valid value for fresnelMaxLevel (for PBRing original shaders) in most cases. I started working on that update trying to find a good way to take roughness into account for calculating ambient lighting, and hoping to tie it together with Stereo’s ambient specular, and when looking for solution, found a bunch of articles, including these brilliant docs by Google, describing that in PBR, apparently, ambient lighting works together with reflections (and before I was just using F0/F90/fresnel to calculate reflections). Now I use their DFG map to calculate reflections and that caused the main change, making everything much more sane, although somewhat boring (comparison images).

And another thing is that before that, I was setting reflectance — which is pretty much just a F0 parameter — into whatever I thought of during setup, but with v2 update, I decided to keep it more accurate and use IOR-to-F0 formula. Thing is, for most dielectric materials, including glass, IOR is about 1.5, meaning F0 should be about 4%. It all makes sense on paper, but I have to say, I don’t really like that solution. Like, there is that thing called single side mirror, working because one room is lit well and other is too dark, right? Surely it wouldn’t work with F0 being 4%, when only 4% of light would bounce back to well lit room if viewer would look straight at glass, with direction to eyes being perpendicular to the surface.

That’s why PBR glass has that FilmIOR parameter, by the way, it’s like a quick fix to add more reflections without changing glass index of refraction (which is used to estimate light absorption, taking into account how much distance light would have to travel within glass). So, yeah, still thinking about all that, I think I’m missing something.

Glass shaders Right, I’ll try and rework glass shaders a bit later, in a similar way, trying to keep them compatible with configs made before v2 PBR update.

Carbon fiber shaders Have you tried something like ClearCoatF0 = 0.2? Same as that FilmIOR fix for the glass. As far as I know, clear coat would only have same IOR≈1.5, F0=4%, but I can clearly see on some photos, some carbon has clear coat which is way more reflective.

As for brightness, why not just raise BrightnessAdjustment? Another change was, I tried to balance PBR shaders for their brightness a bit more, I think original lighting in AC is not quite well suited for it (with all materials having ksDiffuse set to 0.4–0.5 by default, it sort of means lighting in AC is two times too bright).

Leather shaders Sorry, but why are they difficult? To me, they’re pretty much plug-and-use, only requiring to adjust brightness. Maybe DetailNormalPBRSmoothnessGamma = 2 would help?

Metal shaders Oh, of course I’ll keep those. Those new v2 materials are mainly just another experiment with accurate PBR textures. And, of course, metal and plastic ones might need a new texture, those were the cleanest I could find which would also have some sort of details in them.

As for using carbon without overriding textures, maybe add something like this to either car config or even materials_interior.ini?

[TEMPLATE: Material_Own_Shiny EXTENDS Material_InteriorPBR]
HasDetailNormals = 1
Smoothness = 0.9
Reflectance = 0.2
CubemapReflectionBlur = 0.35
UseClearCoat = 1
ClearCoatSmoothness = 1.0
ClearCoatF0 = 0.2
ClearCoatIntensity = 1.0
DetailNormalBlend = 1
DetailScale = 420

And then use [Material_Own_Shiny] instead of [Material_Carbon].

Trava715 commented 4 years ago

Their additional texture does not work well with factory fresh metal materials on Kunos cars

DetailScale = 0

As for losing TxDetail you can simply use [Material_InteriorPBRDetail]

Yeahone01 commented 4 years ago

Hello guys, I hope you are all right.

@ Trava715, thank you for the suggestion. I will try it in the future.

@ gro-ove Sorry, this time it is me to be late to reply. I know that you are always trying to get the best results with the changes you make with the config templates. Unfortunately, when I wrote my last reply your new PBR shaders messed up the car I was working on just before (Lotus Exige S), in particular the brake calipers, filler cap and the interior carbon. You wrote that you plan on reworking the basic brightness and so I decided to wait a few weeks in order to not having to start over every time a new CSP version is released. I even got to the point of thinking about scrapping my project and using the Horizon Shades 2.5 mod from Racedepartment instead. But that did not work for me. It destroyed my framerate, added a constant blur and some ugly overblooming. So I went back to use SOL version 1.5.1 with almost all suggested settings by peterboese. After updating to CSP v0.1.52 I realized that most of my shader adjustments still are working and decided to continue my project.

I suppose PBR glass has already been reworked by now? Regarding carbon fibre, increasing brightness does not do the trick. It is hard to explain but when conventional carbon fibre gets hit by light, some of the checkers (mostly in diagonal lines) get highlighted. I really liked this effect but it is not working anymore.
Also interior masking is a double-edged sword: It works great in most cases, especially with your PBR materials applied, but on some cars the interior becomes a dark cave, even when there is plenty of glass on the greenhouse (f.e. Porsche Panamera Turbo). Interior masking also seems to reduce the power of reflections and that makes carbon look even more bland.

Leather: maybe I was not specific enough about this. Some materials get ugly texture issues when you try to apply PBR leather to them (f.e. Lotus Exige S secondary color leather on steering wheel). I was unable to find a way to fix this (tried shadow bias and tiling fix, but nothing worked). I guess this is strongly depending on the type of shader Kunos originally applied (in this case ksPerPixelNM_UVMult). Also you have to be very careful with reflections. Even when the leather does not appear too shiny in cockpit view, in Real Mirrors they look like they have been coated in vaseline. But I guess this is on Real Mirrors. Probably trying to fix this will decrease the reflections on paint and metal in mirror view.

Thank you for Shiny Material template, I used it on the brake calipers of the Lotus Evora GTE and it looks good.

RustyChest commented 4 years ago

I even got to the point of thinking about scrapping my project and using the Horizon Shades 2.5 mod from Racedepartment instead. But that did not work for me. It destroyed my framerate, added a constant blur and some ugly overblooming. So I went back to use SOL version 1.5.1 with almost all suggested settings by peterboese. After updating to CSP v0.1.52 I realized that most of my shader adjustments still are working and decided to continue my project.

There is a lot wrong with these sentences. You're confusing the Shaders Patch with a Post-Process Filter? or at least that's what it sounds like. Horizon is a post-process filter meaning it's only use and purpose is to alter the visual appearance of the game, which is very far from what the patch does. Horizon PP-Filter will not make your PBR Materials better or worse. It'd only affect the YEBIS post-processing of the game (altering glare, brightness, saturation, contrast). Not the actual inner-workings of the game.

Regarding carbon fibre, increasing brightness does not do the trick. It is hard to explain but when conventional carbon fibre gets hit by light, some of the checkers (mostly in diagonal lines) get highlighted. I really liked this effect but it is not working anymore.

It never was really a thing far as I remember as carbon fiber simply doesn't work that way in Assetto, it's just a texture and a normalmap, it cannot react to light in the way you're describing (at least to my knowledge). But here's an old demo from x4's initial implementation of carbon PBR I believe image

Here's how Kunos carbon fiber looks without any PBR materials or additional config. image and here's how that would look with a PBR config image (mind you that x4 himself said that PBR shouldn't even exist outside of the interior of cars, and that exterior PBR is currently unsupported) This is how the above PBR config would look without any clearcoat and brightness set to 0 image and this is what PBR carbon looks like with image BrightnessAdjustment = 0.7 ClearCoatF0 = 0.35 DetailScale = 250

Also interior masking is a double-edged sword: It works great in most cases, especially with your PBR materials applied, but on some cars the interior becomes a dark cave, even when there is plenty of glass on the greenhouse (f.e. Porsche Panamera Turbo). Interior masking also seems to reduce the power of reflections and that makes carbon look even more bland.

Screenshots would help here, but PBR cannot accurately bounce light like you're expecting it to without SSGI I believe, and even that is not supported. You are more than able to use the BrightnessAdjustment= parameter to adjust the ambient and diffuse of your preferred material(s).

Leather: maybe I was not specific enough about this. Some materials get ugly texture issues when you try to apply PBR leather to them (f.e. Lotus Exige S secondary color leather on steering wheel). I was unable to find a way to fix this (tried shadow bias and tiling fix, but nothing worked). I guess this is strongly depending on the type of shader Kunos originally applied (in this case ksPerPixelNM_UVMult).

Excuse me, what? Some materials may "get ugly textures" if the UV mapping isn't read right by PBR, which is a common trope among certain Kunos cars such as the BMW GT2 car having a bit of a wonky UV map, causing the texture to be applied poorly. Screenshots would aid my understanding of your issue with this.

If you would like further assistance with PBR I would suggest posting your config so far so I can take a look at it, I've been hard at work retrofitting most Kunos cars with it and have found little to no issues like the ones you've had. But maybe I've been doing things wrong, y'know?

RustyChest commented 4 years ago

Upon trying my hand at making a PBR config for the Lotus Exige, it came to my attention that the car is so old that Kunos at this point didn't even UV Map it, which explains why the center console doesn't, or rather can't receive proper PBR while the rest of the car seems to accept it just fine. I hope you analyze and choose the cars you wish to work with more closely next time as not all cars are worth the trouble. I'll be posting a PBR config for the Lotus here soon, along with screenshots of a VAO Patch for it.

Yeahone01 commented 4 years ago

Hello RustyChest,

I think I need to clarify a few things here:

The Horizon Shades mod is quite a bit more than just a pp filter, it alters a lot of the CSP settings (customized preset) and even contains Reshade. Also I do know that it is designed as an addon to CSP and SOL. My hope was that these effects would make the shader adjustments obsolete because the SOL filter in general made materials (most of all paint) look a bit bland compared to vanilla AC with the default pp filter. A result of finding the best compromise between realistic weather and stunning visuals, I totally understand that. What I wanted to point out before is that when you combine SOL with the new shaders for paint, interior and glass it simply makes AC look the best.

I do not blame CSP in any way for the issues I experienced, apart from the latest changes which caused the carbon shader to mess up in a few cases. And I do not choose the cars but try to create a customized config to every of them - if possible - without editing the KN5 files. My knowledge is not developed enough to create VAO patches, so thank you for your work on them. Even though there are a lot of cars which already received a config in this repository, I like to create a certain look, that is totally a thing of personal preferences.

Originally I created this thread because I thought there was a problem with the glass shaders. But then it turned out that the majority of issues are being caused by the fact that Kunos used a ton of different shaders which differ from car to car, basically a result of their own learning curve over the years I guess.
Honestly I simply began pointing out a few of the issues I experienced because I was hoping that gro-ove may have some workarounds for the messy Kunos materials (a bit selfish but I plan on sharing my work later on), not in order to critisize anybodys work. I do have deep respect for Kunos and every mod creator so please do not get me wrong.
The image of the Maserati Quattroporte GTS interior and the last of the wing recreate the effect I mentioned, thank you for the example and explanations.

The reason I did not post any screenshots yet is that I do not know how to make them with the exact same setting and angle for comparison purposes. Maybe you can tell me how to do this.

Thank you in advance

Marocco2 commented 4 years ago

Upon trying my hand at making a PBR config for the Lotus Exige, it came to my attention that the car is so old that Kunos at this point didn't even UV Map it, which explains why the center console doesn't, or rather can't receive proper PBR while the rest of the car seems to accept it just fine. I hope you analyze and choose the cars you wish to work with more closely next time as not all cars are worth the trouble. I'll be posting a PBR config for the Lotus here soon, along with screenshots of a VAO Patch for it.

Could a KN5 addon file could fix this?

Trava715 commented 4 years ago

Could a KN5 addon file could fix this?

Technically yes, but it would be better to redo the entire car in updated and proper manner according to new standards. But then you run into problems with redistributing KS content, even though it's largely updated.

Yeahone01 commented 4 years ago

Okay guys, maybe I was a bit whiny yesterday. I think it is time to finally show some results:

All screenshots have been taken from the same replay, with CSP 1.52 and SOL 1.5.1 activated. Suggested settings from peterboese manual, apart from antialiasing. The first image always displays vanilla Lotus Exige S, the second my custom config: lotus_exige_s.zip

Interior: Lotus_Exige_S_vanilla_02 Lotus_Exige_S_Y_02 Front wheel: Lotus_Exige_S_vanilla_04 Lotus_Exige_S_Y_04 Front 3-Quarter: Lotus_Exige_S_vanilla_06 Lotus_Exige_S_Y_06 Rear 3-Quarter: Lotus_Exige_S_vanilla_07 Lotus_Exige_S_Y_07 Headlight detail: Lotus_Exige_S_vanilla_08 Lotus_Exige_S_Y_08 Taillight detail: Lotus_Exige_S_vanilla_09 Lotus_Exige_S_Y_09

A few notes: The paint is much more dark because I tried to replicate the Lotus Starlight Black . I decided to change the carbon fibre side covers and rear diffusor to black plastic because the Kunos Shader is much more simplistic compared to the one they used for the interior carbon. My main focus originally was on the lights and rims, but in the end almost every material apart from leather and velvet received a makeover. What you see is is the best result I was able to achieve with just a config file, for anything more we would need to edit the KN5, or at least create a VAO patch like RustyChest explained before.