The online racing simulator
The custom shaders thread
(108 posts, started , go to first unread)
#1 - nacim
The custom shaders thread
Hi everybody !

Recently, Scawen has opened car shaders to the community, and we started to see some cool shaders being developed. So I naturally thought that it could be cool to find them all on one thread. Smile

So people, show us your programming skills in HLSL ! Thumbs up

My shaders (version 1.2, compatible with 0.6R) (download in attachments):

Attached images
2016-11-25 19-08-34.441.jpg
2016-11-25 20-13-54.408.jpg
2016-11-25 20-34-38.691.jpg
2016-12-19 13-45-29.530.jpg
2016-12-19 13-56-10.662.jpg
Attached files - 14.1 KB - 364 views
I think it is too early to create a shader scene until we get a stable patch.
After few test patches Scawen will separate shaders to glossy\glass\matte, so it have to rewrite all of it.
#3 - nacim
Oh, okay

But where have you readed about differents shaders for differents parts ?
Quote from Scawen : My vague thoughts are to implement, as a first stage, three shaders for cars: paint / matt / glass. These are easily detectable for all cars without needing to start getting detailed in the editor.

In case someone is using test patch F3 and Keiichi's custom car shaders, here's a fixed version that shouldn't throw vector truncation errors (if I'm not the only one).
Attached files - 2.4 KB - 2096 views
#6 - nacim
Thanks, I've got this problem too when ALT+TAB
#7 - 5tag
Sorry, I'm probably missing something but I can't find Keiichi's shaders anywhere on this forum. halp
#9 - 5tag
Well, thanks. :0

I was looking for a post by Keiichi himself and I didn't know whether your fix contained all the necessary files.

Anyways I had a quick look but didn't end up keeping them. They give the paint a metallic yet oversaturated look and at shallow angles the reflections become too intense.
For example if you look at the XFG from the back, there are very bright reflections on the rear spoiler despite the roof/rear window being "in the way" of sky reflections.
The absence of self-reflections is not so obvious with the standard shaders.

Found this by accident
Sweet-FX is cool for screenshots, but not for racing.

Keiichi, I modified your shaders, to correct the Fresnel problem and reduce car and change some numbers. I tried to multiply specular by the lighting (so that the car doesn't relfect in dark), but I havnen't founded the correct input for it.

Screenshots : (1) yours (look at the bottom of the car), (2) mine, (3) yours (look at the excess of shinness), (4) mine

Guys, tell me what you think, I'm still n00b on HLSL.
Attached images
Attached files - 2.2 KB - 636 views
Well, multiplication of reflection by a specular is not quite correct solution, because after this calculations reflection will be visible only where is specular lighting is bright.
But surface should reflect environment almost everywhere.

Problem with this reflection in it's initial implementation. It's a hemisphere which in a bottom absolutley the same as on top.
By a default there was a solution for this in shader but I slightly eased it to have more work around with fresnel effect.
You can find the line
float3 Ref = envmap_col.rgb * min(1.0,In.EnvA.x+0.5);
and just remove this addition by 0.5. instead of rewriting final color blendings.
On the screenshots you can see the difference.
Attached images
LFS 2014-11-17 12-24-02-70.jpg
LFS 2014-11-17 12-24-25-06.jpg
I applied this modification, and it's slightly better in game.

What I really want to do, is real time reflections, but I don't know if the input contains everything that is needed.
Attached files - 2.2 KB - 843 views
Realtime reflection is not possible with shader only. It requires to render environment to cubemap texture and only after that we can apply this texture in the shader.
And LFS engine still use spherical environment mapping.
Quote from nacim :I applied this modification, and it's slightly better in game.

What I really want to do, is real time reflections, but I don't know if the input contains everything that is needed.

Can you post some comparison screenshots please?
Quote from Flame CZE :Can you post some comparison screenshots please?

That's for you :

(1) Without modification :
float3 Ref = envmap_col.rgb * min(1.0,In.EnvA.x+0.5);
Out.Colour.rgb += (envmap_col.rgb*Spec) * In.EnvA.x *0.5;

(2) With modification :
float3 Ref = envmap_col.rgb * min(1.0,In.EnvA.x);
Out.Colour.rgb += (envmap_col.rgb*Spec) * In.EnvA.x;

(3) Non-multiplied by specular lighting :
float3 Ref = envmap_col.rgb * min(1.0,In.EnvA.x);
Out.Colour.rgb += (envmap_col.rgb) * In.EnvA.x;

I personnally prefer the first and the second (the first is a bit less brighter), and the second one is real physicaly weird, car still shines at max even if it's in the dark. I know it create a mat paint effect on darker sides, but it's the only way I founded to correct this at this time.

EDIT : I think when I'll get more time, I'll work on a better one, but the current LFS inputs are too light to do complex and realistic effects.
Attached images
I tried to fix spherical projection mapping and found an intesting method that really works.
First of all, I captured a new texture to reflect environment in the new way:

After all transformations i got new sphere map which have a data below the horizon compared to the default one.


Now lets go to the shader.
The old one have pretty simple calculations an looks something like this:

float3 refv=reflect(In.EyeVec, In.Normal);
float2 coords = float2(refv.x/2+0.5,refv.y/2+0.5);
float4 envmap_col = tex2D(s_T2, coords);

New one looks like this:

float3 refv=reflect(In.EyeVec, In.Normal);
refv.z -= 1.0f;
float size = length( );
refv.x = refv.x / size;
refv.y = refv.y / size;
float2 coords;
coords.x = ( refv.x / 2 ) + 0.5;
coords.y = 1 - ( ( refv.y / 2 ) + 0.5);
float4 envmap_col = tex2D(s_T2, coords);

and difference is HUGE
Comparing screenshots(reflection only with new texture):


So now we have a reflection which quite similar to the old but without this mirrored bottom issue.

The main problem is that now I need to remake all reflection textures.

I've found that i was mistaken and used object normal instead of world normal, but it doesn't matter because this affects only during rotation of the vehicle.
Attached images
LFS 2014-11-18 20-16-52-57.jpg
LFS 2014-11-18 20-17-14-27.jpg
LFS 2014-11-18 20-30-44-61.jpg
Oh sweet, that's what I've been looking forward to

Keep it up!
By the way, since the texture require rework, I will try to pack HDR data there to get rid of the fake fresnel effect like is was in original textures. Unused alpha channel allows me to do that.
But there's huge problem with static objects that have reflection and haven't shader source (like windows in the buildings).
Who looks on windows of buildings while driving? Having a beautiful car is worth it!
Wow ! Nice job !

Quote from Keiichi_Tsuchiya :So now we have a reflection which WAY BETTER THAN THE old AND without this mirrored bottom issue.


The fact to capture environement map directly in LFS is logical, and more realistic, and with shaders to create a new relfection model, it's really nice, great idea !
why no more updates? :/
Keiichi_Tsuchiya is waiting for Scawen to give us the variables he need (like world position), see his thread about it. Wink
cool, i want to see more improvements because that little thing makes a huge difference in game

The custom shaders thread
(108 posts, started )