A nice shader for track materials

Hmm, if you have time, one interesting thing to try might be putting together a model of a paved surface and then doing AO + heightmap renders to see how the two compare. Just to get an idea of how accurate it is to be using the normalmap's alpha as both (wear takes off the top of the heightmap first presumably)

The issue I see on switching from envmap to ambient light is, ambient light doesn't have a direction to use in fresnel calculations - so you have to pick some model for the ambient light in the direction it should be coming from, or it'll look like there's sky everywhere. On upward facing surfaces like the road this is not a problem, any viewing angle will be seeing their sky reflection. Not sure it'll work as well on other props.
 
I'll give it a go this weekend.

I posted up the asphalt detail map earlier but really I could do with making a really good one and then we have it.

I can do a HQ AO map, and also a height map, as well as the usual normals map.

Getting rid of the wear/gloss influence is the main thing I want to change as although it works ok, it's limiting flexibility of the shader.
Since we throw in another channel to do that we may as well use the other colours to do the scale adjustment...

I'm quite excited to see how this might look...



As per the normal direction. I suppose a bit like the normal influence on the ambient shading (in lighting.cg)
Is there any way we can simply take ambient value when the normal is pointing in any positive 'up' direction, and then if it's pointing down it's lerping from ambient > 0 as the normal goes from pointing at the horizon to straight down?

Not sure how 'cheaply' that can be done but it might be a nice fix for plenty of fairly matte materials that still need this effect to look physically correct (at least more than no reflections at all from the ambient lighting)

Also this is 'AMD' card safe.

I'm using just ambient light on the road right now (works ok for stuff generally pointing upwards) as the ambient reflection and it looks fine in most cases. Yes the envmap mips are that bit more accurate but the real issue is that we get the double energy seeping in from the envmap sun spot and then specular here any way...
So really for now it's not ideal doing either solution.

Fingers crossed Ruud will move back to a sun flare system and dump the sun/sun spot technique :D

Flares just do better suns :D

Dave
 
Heh, the flare does look nice, but man, that road is low-poly >_> every time elevation changes you can see the car bumping over every quad.
 
Yeah it looks like it's in need of a spline system to smooth it out :D


Gonna test the road shader using those other control inputs this weekend.

If it works (pretty sure it will), I'll update Asphalt as a proper released track and add a nicely authored variable surface all the way around the course, along with my sky pack (so far) so you can try out different skies at the same time too.


It'll then be up to you Stereo to make sure it all makes sense in the cg files hehe... I've been doing lots of WYSIWYG tweaking so maybe I broke something :D

Pretty sure I haven't though ;)


It'll be nice for Exeter Road, and my own project road, and other such road projects, to have this kinda shader... never mind race tracks too I guess (could possibly make the shader simpler for tracks as they are not usually so variable as roads)

Cheers

Dave
 
Well scaling works, but the boundaries between colour changes don't appear so well inside Racer.

So even a sharp edge between scale values leaves a pixel wide or so line in the final rendered output that looks a bit iffy, but the areas around those changes in scale work fine.

Hmmm... not sure scale is gonna be workable without some magic in the way the scale values are passed in the tex coords. No idea what is going on at the points where there is a gradient in the requested scale.

If I apply a gradient across the width of the track currently it just goes weird all over hehe.


Code so far:
Code:
  // baseCol = diffuse colouring
  // surfCol = red - wear, green - gloss, blue - scale
  // bumpCol = normals + ao in alpha
 
  // Get texture map info
  float4 baseCol=tex2D(colMap,IN.tc0);
  float4 surfCol=tex2D(surfMap,IN.tc0);
 
  // Use world planar mapping for the texture
  float2 tcW=(float2(IN.Position.x,IN.Position.z))*(surfCol.b+0.06);

  float4 bumpCol=tex2D(normalMap,tcW);


I think all the other outputs are pretty straight forward. Lerping the normals to smooth while also lerping the AO out of all the other outputs vs wear is the way to go.

That way with a rough road we get the AO impacting spec, amb spec, ambient colour, and then with a smooth road we just remove the AO and normal influence of the normal map.

Seems a logic first approach. Maybe have AO at 50% on the diffuse colour at zero wear too, to add a bit more gritty feel to it (extra dirt etc?) that can then disappear as the surface smooths.

Hmmm

Dave
 
Not directly relevant but I was up a bit before sunrise and there was no traffic so I wandered into the middle of the road to get a better look at the painted line.
w9lTGrl.jpg

2 separate lines really - the older one at the top, newer one at the bottom. For scale, it's about 10cm across the newer one, 13 total.

I can see probably 3 different sources of wear and tear
1) it's pretty dirty in the indentations
2) the paint's wearing off the tops of some of the tallest rocks
3) when it was laid down there were loose stones which are gone now but left shadows. Probably some smaller grit too.

The older paint is mainly losing the 2nd way - very few rocks have paint on top. It's also visible that the edges of the line get thicker paint laid down, they're less worn.


Fairly typical for around here there's a lot of variation in the crushed rock, from light to dark, with some red/brown scattered in. This is ~12 year old pavement on a 2 lane street with reasonable amounts of traffic. I'd guess the older line is from when it was new, newer line is several years old. End of the line before it enters an intersection, so there's a reasonable number of people running over it as they turn.
 
Last edited:
Yeah this is the hard part because ideally we want to decal our yellow lines etc, but in practice they also need to pick up the details from underneath.

So maybe our decals then need to run off the bump/AO detail map. Then we use a wear map to actually paint in the thickness of the paint.
Since the decals need colour and alpha, we are onto a 2nd texture to get the wear, so maybe another rgb with wear/gloss.

Since the detail map is globally mapped then we can do this nicely.


Getting quite complicated now though, but still the only truly powerful way to do things.

Baking lines into textures is ok I guess but it can get really messy as soon as you have a junction or anything like a wider bit of road etc.

Hmmm

Dave
 
I don't expect to put a bunch of variations into the decals (at least not to the extent of what happens on asphalt which does need wear, smoothness, etc. separate for best results). Probably keying everything off alpha, and just using 100% opacity for new, lower for worn stuff, would look okay. Like you say, the detail normal+occlusion map can be used to add to it.

Really, nobody's going to zoom in on the lines like I did in the photo, it just needs the suggestions of the right thing happening to look right. Picking up the detail map's normals will help. So if we pick a few important points (eg. at 100% opacity it looks like fresh paint, at 75% it looks like dirty paint, 50% it looks like worn paint, 25% it's very worn, 0% it's not rendered) then there's enough flexibility to put down some different lines.

In reality gloss and wear are still separate concerns from alpha (like the groove in the pavement, well-traveled lines are shinier cause they aren't dusty) but there's a point where adding textures to attack the problem doesn't make a visible difference. The asphalt's got those details under the paint anyway, it can just be mixed in more strongly if necessary.

The painted details need a separate map anyway (to add retroreflective shader) so treating them differently from manholes, etc. is fine. Those can have the standard PBL shader, transparency, and so on.
 
I was thinking about this the other day. Surely there's a way to use the old shader system (detached from CG) to just colour/tint the surface below.
I'm yet to test it out but surely it's possible. I don't know what can of worms it opens up with TOD, etc. but I'm interested in trying it.
 
I don't think the blendfuncs available are complicated enough - they all mix based on the two alpha channels, ending up with out.rgb = a*front.rgb + b*back.rgb.
eg. with 'blend' you have a = front.alpha, b = 1-front.alpha. iirc other options are things like a = front.alpha, b = 1.

If the cg fragment shaders took as an argument the existing rgba at that pixel you could do some neat stuff. No idea how feasible that is on Ruud's side, I'm not sure how the render pipeline works. Like, it renders stuff in sequence based on their sort_offset but I dunno how much control there is between each offset in sequence.
 
In the end if you really need some fantastic details then I guess you can get in there and add resolution and detail into the control maps.

What really matters is making a good rounded shader that can do everything 'ok' with energy conserve, proper specular/gloss control, and enough control for authors to realise their visions or needs.

I think the shader tweaks I did get it close enough for that task. The only thing that was a bit unfortunate was the scaling parameter didn't seem to want to play nicely.

If there were a way to fix the weird scaling artifacts brought about by gradients in the texture LUT (solid colours work fine, but where the transition point is the UV's are not good) then that would be really really nice indeed.

I've tested here quite a bit and performance and capability is just amazing really.

Brand new tarmac, dusty new tarmac, old rough tarmac, small grain versions of those, big grained ones, yadda yadda yadda. You can do everything.

The only thing missing for a perfectionist might be an IOR map (greyscale) so that they can add dirt/mud/dust areas and kill back the specular power a bit (I think if we can't get the scale map working you could just use that channel for IOR).


I think at this point for white lines etc, if you use the detail map from the road shader, then you can just use an rgb for colour, alpha for transparency, then use another rgb for gloss/ior/wear (where wear map just brings back in the underlying detail map normals?)


Hopefully over Christmas we can progress all this on Exeter Roads :D

To showcase what Racer is really capable of would be nice, and also to show that we should always set higher expectations than just 'ok'... everything we do should push boundaries otherwise we never move.

Dave
 

Latest News

How long have you been simracing

  • < 1 year

    Votes: 215 14.4%
  • < 2 years

    Votes: 154 10.3%
  • < 3 years

    Votes: 149 10.0%
  • < 4 years

    Votes: 115 7.7%
  • < 5 years

    Votes: 215 14.4%
  • < 10 years

    Votes: 179 12.0%
  • < 15 years

    Votes: 118 7.9%
  • < 20 years

    Votes: 80 5.3%
  • < 25 years

    Votes: 64 4.3%
  • Ok, I am a dinosaur

    Votes: 208 13.9%
Back
Top