A nice shader for track materials

PSPS, the flare graphic seems way out of position vs the mie sun spot...

Also the mie sun spot often appears out vs the specular line drawn down onto surfaces.


Flare aside, even with the mie sun spot there can be a disparity in specular apparent source and the sun spot in the sky!

Really we just need to tie a better flare system to the actual sun position and then we can dump the mie sun spot (which appears a bit inaccurate depending on the sky dome size etc)

Dave
 
PSPSPS, the normal map bug isn't a simple transform, I've rotated it 90deg CW and now at another TOD the normal map appears 180deg out hehe...

Obviously an easy fix but bit busy for now to go hunt it down :D

Dave
 
Dave,

hope you don't mind my interrupting your brainstorm (great one), but one quick question:

could some of the issues be solved through post-processing shaders? Not exactly something I tend to favour but it may be of use.
 
Hmmm, I'm generally thinking something isn't ideal here now...

Right now we have only 20% max gloss (and thus specular power?) available on a non-worn asphalt material?

So basically we can only get to say '200' shininess with new asphalt? (assuming track.shd entry is set to 1000 for shininess)

And then as we add 'wear' we can get to 1000 shininess?

I think really we should be able to get something like 80% of the max shine on new asphalt if we want.


It might even be best to make both textures run from 0-1000 gloss, and then mix them appropriately.
We can then set a max amount in either map, but then saturate the values so if something is already at 1000 gloss in the detail map then it can't be pushed higher with wear?

That seems to make more sense... so the wear map just wears and adds gloss where it isn't already at the max value... rather than pushing it up to 4x higher all over the material...



Also I'm not sure how high shininess should go... the mie sun spot in the envmap can get very bright... but in theory isn't the sun diffuse TOD curve value (about 90klux peak) indicative of the klux value we should get from the specular at a glancing angle?

Setting the fresnel on specular so that it's a mirror (just to make colour picking easy), the klux values (with the mie sun spot off in the atmosphere shader) is way over 255klux (clamped in Racer.exe?)
That seems way too high? Or isn't it? If the sun TOD diffuse curve is at ~ 100klux then how can the reflection be over 2.5x brighter? Or is this a problem with incident vs reflected klux measurements?
Then again, surely reflected will always be a bit lower than incident?


Basically something still doesn't feel right here with the way gloss is defined. It felt more logical to get the look I wanted in my shader, although that wasn't perfect either and had it's problems :)

I like the advancements this shader is making though. It's clearly way ahead of any other approach for asphalt and you can really add some nice character into the surfaces etc!




For now the only tweaks I've made really are the ambientSpecular uses saturate(gloss)*ambient, rather than bumpCol.a*ambient which is wrong.

Also I removed a * from ambient*+Ke in the shadowColor calculation which I think was just a typo of mine from the initial release...


Stereo, let me know what you think to those last two tweaks... and then obviously to the whole gloss area hehe.


I think using a test material that is a glossy mirror block (a smooth "chrome" road in essence), will allow us to sense check the extreme values better.

Just that specular intensity on super glossy stuff that seems off to me, and that is throwing off the tuning right down the line to the initial values...

Hmmm

Dave
 
Dave,

hope you don't mind my interrupting your brainstorm (great one), but one quick question:

could some of the issues be solved through post-processing shaders? Not exactly something I tend to favour but it may be of use.

I'm not really sure at this point.

I'll be honest I'm in over my head to a certain extent hehe.

Where with something like Unity or UDK, or an app like Max with mental ray materials, here we are building the shading logic from scratch and so there is a lot I really am not familiar with.

I know how I want things to look though, and I have tools to check real life vs simulated (alongside my eyes/brain combo :) )


I think a big thing to think about is tone mapping and glare/bloom.

They are two variables that are also unclear at this point.

Looking at the roads through my polarised sun glasses shows how much glare makes up in the appearance of things, even if it's not whited out to our vision. Glare is all over the place, not just an 'effect' we get at the edges of whited out areas.

But then what is whited out to our vision? Since it changes dynamically nothing is whited out for long...
Auto-exposure does an ok job I guess but then what tone-mapping do we use... do we try fake a camera type look (4 stops or so wide with a bit of curve at each end), or do we go for 12 stops wide with a nice compression technique that moves the linear central 3 stops or so up/down with varying curve at each end?


So you are right, post-process will change the apparent look a whole load too...

Since bloom right now seems non-dimensional and arbitrary then I'm not sure about that one.

Tone mapping I have no idea either. I guess quite often Racer seems to choose a bad exposure...
Indeed, thinking about it more, half the reason Racer picks a bad exposure is priority for the mie sun spot... once that gets in shot it can get very dark exposure...

Imo the sun mie spot is too bright and too big, and generally should be ignored for setting exposure as we are generally focussing not on the sun in Racer hehe...

So maybe having a flare type sun will improve exposure and apparent 'glare' as the scenes will generally be more brightly exposed at any given time.


Hmmmm...

Dave
 
PSPS, the flare graphic seems way out of position vs the mie sun spot...

Flare aside, even with the mie sun spot there can be a disparity in specular apparent source and the sun spot in the sky!
Yeah, I noticed that... I'm not sure if it's cause of the size of the skybox - technically if the sun was infinitely far away, there should be no parallax issues with using an envmap that was rendered somewhere else, but the closer the sun is, the more off the reflections will be when they're not on the material directly next to the car.


Hmm, if overall shininess caps at 1000 (with alpha=1 on both maps) then the 'shininess' variable could determine the relative contribution of the bumpmap - for example, when the top is at 1000 shininess, how sharp should the 'pits' between aggregate be? If you want them polishing up at a similar rate, set this variable to a similar value, if you want them dull, set it to 10 (or whatever).

Haven't yet worked through your flood of posts, will add more if I think of anything.
(ps. I have auto-exposure turned off and just send the console a command every time I change the TOD... sort of inconvenient but it never flares up. Would be nice to fix the exposure curve so this is mostly unnecessary.)
 
For your question about non-worn pavement only having 20% of the gloss, what alpha value were you putting in the basemap? My intention when tweaking values was to have 'unworn' be somewhere in the middle, with 'unused' going darker (accumulation of dirt) and 'worn' going lighter. There's definitely room to change how the gloss caps off but I'd like to make sure we're on the same page with what the shader can accomplish. I drew the area where bumpmap+basemap alpha is high enough that it caps the gloss, but didn't include code for that yet - on the principle that it's better to identify why it's wrong before changing it.

If you want to add that in, it would be lines 115 and 117:
Code:
 float gloss = 0.5f*bumpColor.a+2.0f*baseCol.a-1.5f;
//shininess*=1.0f-0.9f*gloss;
  shininess*=pow(10f,gloss-1f);
becomes
Code:
  float gloss = min(0.0,0.5f*bumpColor.a+2.0f*baseCol.a-1.5f);
//shininess*=1.0f-0.9f*gloss;
  shininess*=pow(10f,gloss);
This is gonna slide everything up the gloss scale, except for the top region, which is gonna have a fixed amount of gloss over a wider range. It'll also mean your saturate(gloss) line in ambientSpecular doesn't work; change that to saturate(gloss+1.0f) to compensate the +1 I added in the above code.
 
Your normal maps need the green channel inverted, I think; I compared it against the RX7's tire tread (which I know works ok) and flipping the green channel made road_nrm's bumps "bump" the right way for Racer (apparently 3d programs are half and half on green channel conventions... Maya and 3ds max do it one way, every game does it the other).

The shader also has an error in it; sorry about that.
Code:
IN.Position.zx*scale
Is what line 79 should have rather than .xz

Applying both gives the result I'd expect:
DxqTc0C.jpg

The side of the bumps facing the specular spot lights up.
 
Playing with the ambientSpecular, I'm not convinced it should work positively with this gloss variable. I tried inverting it, with ambient*saturate(-gloss) and it plays a lot more like I'd expect that way. Made a few other tweaks and I don't know about realism but I am getting a much nicer range of options now.

The main thing that's still looking funny to me is the level of variation in brightness at low gloss levels. Need to go take a look at some pavement I suppose but it feels like it's getting too muuch diffuse-style lighting and not enough ambient. Or maybe the ambientSpecular's just not playing right there.

EDIT: Um, could you do up a dds of the normal map, once you've got it set up right, with good mipmaps? The auto-generated ones make a really unpleasant 'crawl' in the transitions.

Also, today's revision of asphalt1_f.cg. Basically where I ended up after playing around with the things you mentioned. Also needs that green-inverted road_nrm.tga for completion.
 
Hi Stereo,

Like I mentioned I think there is a delicate relationship in how the environment is reflected at different gloss levels.
Ambient colour * diffuse intensity at the gloss end >> ambient intensity * diffuse colour at the matte end... right now it's just straight environment pasted over the top with no consideration of the underlying diffuse element.


My implement was only really ever intended for the rougher end of the spectrum, so going way into the glossy end too and offering up the envmap reflections at lower mip levels suddenly makes life harder.
Not least because you are blending the TOD values into live envmap values... where maybe there is a discrepancy in consistency already?

I take it you have disabled the sun in the atmosphere.cg while testing too? At the glossy end of all the materials you'll have double energy otherwise.


As per bump map, I'm pretty sure my TGA is correct... I used the vf_bump with 'dome' type shapes to clearly determine the directions were correct.
I'll take another look at it tonight hopefully and update with a decent DDS (agree that the TGA are horrible for mipping normals!)



Going back to gloss, I'm not sure what the answer is but it just feels like we are getting it going too mirror like. As that happens it appears darker than it should I think, and only 'glares' when we get at the perfect angle for the specular reflection.
Yet at the other end of the gloss scale (more rough), it's too rough and just looks lit all over at a fairly high intensity (like the specular power isn't dying away and turning into diffuse)
Maybe the energy conserving approach needs us to turn off diffuse, or set diffuse+specular = 1 total (I saw Ruud mention this on Racer.nl but who knows when that was written or updated etc)

Who knows what that then means for ambient/ambient specular hehe :D


Basically I feel materials need more specular power at lower gloss values, Right now I can't seem to get anything like my original materials which looked and responded about right at different TOD's... they are either always too matte looking, and as soon as you creep the gloss up to get some specular, the material then appears very dark most of the time except for the rare occasion the sun is reflecting in it.


Part of me thinks that shininess=1000 is too high and is causing the whole gradient of spec vs gloss values to sit out of balance... but I'm not sure how the whole spec energy is generated to start with in lighting.cg.
How can shininess=1000 get a metered value over 255klux when the sun diffuse energy is under 100klux? Energy conserving is already waaayyy out at that point :D


Lastly, I took these photos yesterday while out driving.

asphalt1.jpg


asphalt2.jpg


asphalt3.jpg



Notice how the worn down areas get a blue tint (probably from the sky), while the fresh areas are still darker and less colourful.

The sun is still at maybe 30deg above the horizon here, about 5pm in the UK.

Also note that although the gloss/spec is quite dramatic into the sun, when we look down the road the glossy shiny areas don't go black, they are quite blue but almost blend perfectly with the rough road centreline.

I think that is a reflection characteristic since these areas are also the ones which light up a lot when getting the sun reflection.

Also notice the flattening out of the aggregate to smooth in these areas. But notice how even where it's entirely flat the diffuse appearance is still clear, and the specular is still soft.


I just feel our scale is way too high for smoothing/glossing. Can asphalt ever get so smooth it becomes a mirror? Maybe this is the problem, the super glossy response is noted as ambient colour * diffuse intensity, not just ambient reflection as we have it now.
Do we need to multiply the reflection envmap back down with the diffuse channel for glossy materials?

Flat aggregate should maybe be a variable using one of the free'd up coefficients. Ie, how quickly do we LERP between normal detail map and mesh up normals?
That way we can tweak the 'wear' appearance a bit at least... maybe have a default value of 1, and expect users only to go up/down 10-20% tops as I think the wear is quite nicely linked to the gloss performance of the material once we start wearing it at least.


But it's clear in the photos here that we can get apparently fairly noticeable spec levels at fairly low gloss values, noted by the specular sun reflection that is soft, but that doesn't then result in a dark smooth areas when looking down the road (maybe that is partially due to the in-fill of ambientSpecular from the sky though, which is still wrong in our shader?)



Hmmm...

Dave
 
Just thinking again haha.

-gloss for ambient specular seems really wrong. It makes no sense on reading. Rough areas thus get more ambient specular? Surely rough areas should become more ambiently lit? Then smooth areas are more ambient reflection?

This is probably that weird inverse mixing gloss/intensity thing I keep mentioning that is missing?



Also, just try a coloured asphalt, or just a coloured red road. My 1-kd approach might not be optimum.
I seem to get heavily tinted specular (coloured), which is wrong obviously.

I almost get a nice white specular if I halve the diffuse map value before having it subtracted from 1.

So maybe we need to halve the diffuse, and then set specular to 0.5 too, and in doing so it'll balance the specular colour properly and also get the proper energy conservation?



Again, all this stuff is now entering the lighting.cg and Ruuds energy conservation implement which might be fighting against us here somewhat.

But at least we have some good logic down here so far. It's all feeling intuitive and worthwhile to do. It's just tidying up these energies mainly it seems hehe.

Dave
 
a4Ne1FY.jpg


Hmm, the main place I see it falling down is, actual asphalt gets far less 'sides of the aggregate' specular, and this factor is ruining a lot of the effect. Maybe the normalMap's contribution to cutting back on specular needs to be stronger? Or the normalMap's alpha should fall off more sharply? At low glosses, ambient occlusion will also come into play - even if the specular spot is theoretically large, half the sky is occluded by pavement.

Same issue seems to apply at the dull end of the spectrum, the sides of the bumps are way brighter than the tops, which never seems to happen in photos.

Probably right about the gloss being better positive, will go with that.

Interesting that the wear pattern goes reverse to intuition; untouched pavement is darker than worn pavement.

I tried a coloured pavement and couldn't tell that it was 'too far' the opposite way. White balance seems to come into play, the eyes automatically make it look opposite just by contrast with the red pavement.
 
Yeah I know what you mean.

In my original shader (Gallardo videos) the diffuse channel was obviously set at a very high resolution so the 'wear' map was really an AO map, but AO in the sense it occluded ambient lighting term and the specular output result.

But now we have a low-res diffuse and then 'detail' the aggregate it's impossible to achieve that.

Well, we could use the detail map alpha as a specular map too (did that a bit for the ambientSpecular, but it's too dramatic, maybe have a second blend with 50% of the wear map to use as a specular multiplier?



So I guess we maybe come back to an earlier suggestion that we have a diffuse/ao and normal/gloss detail map set...?

That way we can add the subtle diffuse details without the fudge effect currently in litColor, and we gain an alpha to use for the detailed AO that seems so important.

It's starting to bump up the overall texture load, but still it's way off the texture load you'd use if you tried to get a similar look with HD textures (my original video has a texture size of 2048px wide and 4096px long, with 4 channels a piece! 64mb!) and as soon as you'd want to do a different 'tarmac' you'd have to use a whole new set again...

So I still think having a 2048x2048px detail set = 32mb, but with a lot of diffuse map variations you could probably cover enough different looking tarmac to cover most of your track... even in the worst case a race track with two varieties of detail map and then a load of diffuse map fragments you'd still be coming in under 128mb probably for amazing looking asphalt.


Hopefully I'll get the time later tonight to try author a new detail texture, but I'll author them in DDS and with a diffuse and AO map too.
Then we can dump a load of fudged effects and just multiply stuff properly the way it should be :D


I think if we get this right, all the hard work is in the detail set, if a user wants to produce one and not use an existing one.
Once that is right and the hard-coded shader is 'right' then most authors can just literally copy/paste the shader entry (no real tuning options) and then author just their diffuse maps and get some great results, at a low GPU cost :D

That is the dream any way haha.



PS, I was on a newly surface road tonight. I was driving around a bend waiting for the 'specular' but it never came. It was loose chippings type over wet tar that cars will roll in over time.
The specular into the sun was so subtle... just the odd grain of aggregate was sparkling but there was no overall sheen.
Interestingly too, driving into the sun it was dark coloured, and away from the sun was probably twice as bright looking!

It was weird to see such a behaviour. I guess this is where a detail map set for that type of road would be needed. Very dramatic normals and tight gloss and deep AO, and then as the 'wear' map bites hard it can smooth it out and subdue the AO cutting back the specular, and also make it look smoother, and up the sheen from specular.

I could see the concept of this shader working in my head really well... it's just getting it there from a functional point of view :D


Do you have a preference for the detail map set I make? I'll probably make something like the first video again but if you want something more like what I described above I'll happily have a go :D

Cheers

Dave
 
It is fairly easy to insert normalmap-based AO... probably not exact, but I don't know how far wrong it is.
After line 89 (which adjusts the normals for wear patterns)
Code:
  float ao = dot(bumpColor.xyz,float3(0f,0f,1.0f));
Then, for a direct influence on specular, you'd just need to make line 114 (or 115)
Code:
  Ks*=reflectiveNess*ao;
Or multiply it in wherever else, too.

My drivers just crashed again so I can't make a screenshot of what this 'ao' looks like as a texture but it's not extremely wrong. The main flaw is that the 'pits' don't get shaded by the nearby bumps.
 
With that use of AO and some other tuning, I'm a lot happier with how the specular spreads:
8wUMkhZ.jpg

(this is probably a lower alpha than the wear level on the roads you took pictures of - it's certainly a fair distance from maxed out)

The big thing now is, I think, getting specular colour to match ambient colour in a smoother way. Specular feels too white, ambient too blue, so it sorta does a spotty dance between the two as the specular gets wider. Gonna give this:
That on a rough surface we use ambient light intensity * base colour (diffuse map) for ambient influence (specular?) and then as we get more glossy we use ambient light colour * base colour intensity
Some thought, maybe try to figure out where it fits in.

I haven't got any particular thoughts on control map needs. Might be helpful to set a benchmark of 'this texture corresponds to this picture, change the shader to best reproduce it' with regard to what alpha values should be. Probably a normalMap that's not asphalt, but has "this bit is dirty tar, this bit is aggregate" too.

If you're sure the normalmap is right, I guess the texture lookup needs to be tweaked to match it. Flipping axes is just a matter of changing the signs on the Position.xz.
 
Hmmm, I put that AO result to the output and it seemed to just be very much like the detail map alpha channel anyway.

I've had a play again based on what you are saying is missing in appearance and I'm fairly happy with this approach.

I'm not sure what I've changed really but I took out the -gloss element in the ambient specular. I'm not sure exactly why that needs to be in there. Ambient specular covers gloss reflections through to 'diffuse' rough reflections from the ambient environment light.
Since we already have taken into account the gloss influence on that via the LERP from envmap > TOD ambient colour then I'm not sure why gloss is important again.

It just felt like a way to try keep spec power down in rough areas more but instead it just seemed to exacerbate the problem which is probably alleviated IRL by en-mass occlusion of the rougher areas.


Code:
//
// Dynamic model, bump+reflection
// In world space (more like the other shaders, and gives a chance to modify reflection vectors)
// RvG, 19-11-2010
//
 
#include "atmosphere.cg"
#include "lighting.cg"
#include "fresnel.cg"
#include "shadowmapping.cg"
#include "../common/utils.cg"
 
// Vertex to pixel shader structure
struct v2p
{
  float  extinction     : COLOR;
  float2 tc0            : TEXCOORD0;
  float3 Direction      : TEXCOORD1;
  float4 RayleighColor  : TEXCOORD2;
  float4 MieColor       : TEXCOORD3;
  float4 Position       : TEXCOORD4;    // For fragment shader
  float3 normal         : TEXCOORD5;
  // Fresnel in pixel shader
  float3 I              : TEXCOORD6;
  //float  fresnel        : TEXCOORD6;
  //float3 R              : TEXCOORD7;    // Reflection vector
 
  float4 tangent        : TEXCOORD7;
};
 
void main(
  // In
  in v2p IN,
 
  // Out
  out float4 out0 : COLOR0,
#ifdef CSM_MRT
  out float4 out1 : COLOR1,
#endif
 
  // Constants
  uniform sampler2D   baseMap   : TEXUNIT0,
  uniform sampler2D   normalMap : TEXUNIT1,
  uniform samplerCUBE envMap    : TEXUNIT2,
  uniform float3    lightDirection,
  uniform float3    lightColor,
  uniform float3    lightAmbient,
  uniform float3    ambientSpecular,
  uniform float3    eyePosW,
  uniform float     atmosRayleigh,
  uniform float     atmosMie,
  uniform float3    Ke,
  uniform float3    Ka,
  uniform float3    Kd,
  uniform float3    Ks,
  uniform float     Kr,
  uniform float     shininess,
  uniform float     far,
#ifdef USE_CUBEMAP_MIPMAPS
  uniform float     mipmap,         // Mipmap level of reflection map (blurry if >0)
#endif
  uniform float     sunny,
  uniform float     scale,
  uniform float     exposure,
#ifdef CSM
uniform sampler2D    shadowArray  : TEXUNIT7,
  uniform float4x4     smTexMatArray[SM_MAX_SPLITS],
  uniform float smSplits,
#endif
  uniform float    fresnelBias,
  uniform float    fresnelScale,
  uniform float    fresnelPower
)
{
  float3 skyColor;
 
  // Get texture map info
  float4 baseCol=tex2D(baseMap,IN.tc0);
  float4 bumpColor=tex2D(normalMap,IN.Position.zx*scale);
 
  // Texture space axes
  float4 tangent=IN.tangent;
  float3 N=normalize(IN.normal);
  float3 binormal=cross(tangent.xyz,N)*tangent.w;
 
  // Expand normal
  bumpColor.xyz=UnpackNormal(bumpColor.xyz);
  // Mix to 'flat and shiny' based on the interaction of the two values
  bumpColor=normalize(lerp(bumpColor,float4(0f,0f,1.0f,sqrt(bumpColor.a)),saturate(2.0f*baseCol.a+bumpColor.a-1.0f)));
  
  // Calculate new normal in world space
  float3 bumpNormal=N+(bumpColor.x*tangent+bumpColor.y*binormal);
  N=normalize(bumpNormal);
 
  // Reflection vector
  float3 R=reflect(IN.I,N);
 
#ifdef CSM
  // Output shadowing
  float lit = GetShadowFactor(IN.Position, IN.normal,shadowArray, smTexMatArray, smSplits, lightDirection)*sunny;
#else
  const float lit=sunny;
#endif
 
//lightAmbient = texCUBElod_soft(envMap,float4(R,12.0f));
 
  // Get sky gradient color
  skyColor.rgb=GetSkyColor(lightDirection,IN.Direction,IN.RayleighColor,IN.MieColor,atmosRayleigh,atmosMie,lightColor,lightAmbient);
 
 
//baseCol=float4(0.5,0,0,0);
 
  // Specular map
  float3 reflectiveNess=1-(baseCol.rgb*0.5);
  Ks*=reflectiveNess*((0.25f*baseCol.a+0.75f*bumpColor.a));
  float gloss = min(0.0,1.0f*bumpColor.a+2.0f*baseCol.a-2.5f);
  shininess=pow(10f,gloss+3.0f);
 
  // only load an envMap if we have soft mipmaps
  // note: the 7.5f corresponds to shininess and really should depend on it.
#ifdef USE_CUBEMAP_MIPMAPS
  float3 envColor=texCUBElod_soft(envMap,float4(R,7.5f-4.0f*gloss));
#endif
 
 
  // Lighting
  float3 ambient,diffuse,specular;
  LightingSun(Ke,Ka,Kd,Ks,shininess,lightDirection,lightColor,lightAmbient,IN.Position,N,eyePosW,
    ambient,diffuse,specular);
 
  //FresnelMix2 lets us mix using lerp vs fresnel, so we can go from black to white and vice versa, rather than FresnelMix which just does additive blend vs fresnel
  //define fresnel
  float fresnel=Fresnel(fresnelBias,fresnelScale,fresnelPower,normalize(IN.I),normalize(N));
 
  // fresnel on specular, yay!
  specular=FresnelMix(0,specular,Kr,fresnel);
 
  // ambient specular options
  // really the cubemap mipmap is a more accurate representation of the 'ambient' light.
  #ifdef USE_CUBEMAP_MIPMAPS
    // the higher the gloss, the more it should use the reflective color.
    ambient=lerp(ambient,envColor,saturate(gloss+1.0f));
  #endif
  ambientSpecular=FresnelMix(0,(ambient*(0.25f*baseCol.a+0.75f*bumpColor.a)),Kr,fresnel);
  //ambientSpecular=0;
 
  float3 litColor=(baseCol*(0.6f+0.4*bumpColor.a))*(diffuse)+specular*reflectiveNess+(ambientSpecular*0.6817);
  //float3 litColor=baseCol*diffuse+specular*reflectiveNess+(ambientSpecular*0.6817);
  float3 shadowColor=((baseCol*(0.6f+0.4*bumpColor.a))*(ambient+Ke))+ambientSpecular*0.3183;
 
 
#ifdef CSM_MRT
  // Mix sky with texture color based on atmospheric influence
  out0.rgb=lerp(skyColor,shadowColor,IN.extinction);
  //outShadow.rgb=lerp(skyColor,litColor,IN.extinction);
  out1.rgb=litColor*IN.extinction;
  out1.a=lit;
 
  // Blending
  out0.a=baseCol.a;
#else
  // Mix sky with texture color based on atmospheric influence
  float3 finalColor=lerp(skyColor,shadowColor+litColor*lit,IN.extinction);
  // Need to clamp output - my nVidia GTX285 only handles colors upto 255, then makes them +Inf!
  finalColor=min(finalColor,255);
  //out0.rgb=ao;
  //out0.rgb=saturate(bumpColor.a+baseCol.a);
  out0.rgb=finalColor;
 
  // Blending
  out0.a=baseCol.a;
 
#endif
}
Basically I've pumped up the detail alpha influence on diffuse, and used the same influence on ambient which makes sense... just adding the extra details into the diffuse/ambient channels seems to help a bit.
I've then made a mix of the alpha gloss from both textures to be used as a specular power multiplier for both ambientSpecular and specular.
This gives it an ok look I think.
Ideally these 'mixers' should probably be turned into float constants to be referenced rather than calculated several times through the shader.
The nice thing is because the wear map is used then as the wear values are higher the appearance and balance of the added AO and diffuse/ambient colour alteration will change to suit.
Ie, diffuse colour will get lighter = correct for the worn surface (so maybe less need to author it in the diffuse colour map?)
Also the apparent 'AO' will reduce as the wear map intensifies.
Just noticed your latest additions. Yeah, I think the ambientSpecular is suffering a lot due to bad colour tinting and values.
Fundamentally the only 'wrong' thing I think I see in the shader as you have it is the -gloss addition for ambient specular multiplication... but as said I guess it was a cover-up feature to try impact a problem that is probably best dealt with via AO type approaches to the diffuse/spec elements?
At this stage I think we are both dancing around the same kind of thing, just using different macro control maps (i've tweaked mine loads by now), and different intermediate mixings.
Perhaps with hard-coding for the shader, we can free up some of the inputs to control the base mixing coefficients for the AO effect and the diffuse/ambient base map 'detail' influence on their contrast.
asphalt4.jpg

I'd really love to be able to abandon the mie sun and move back to a flare/decal sun... it's critical for this kind of shader that will be utilising both specular and envmap in unison... but it's annoying that they don't line up half the time which then makes you think things look wrong even more hehe :D
So far for a 15min hack job the flare sun looks and works better (bar positioning) than the mie sun, which suggests it's a better way to go with some effort re-invested in the technique :)
Dave
 
And the corresponding away from the sun shot.

asphalt5.jpg



As per the right appearance/checking vs my photos. I asked Ruud about the EV/Racer exposure setting earlier. I'm not sure if/when I'll get a response but wanted to try get an idea of checking values via the images.

If we could shoot a real life image at say f8, 1/100th and ISO100, and know what exposure setting that corresponded to in Racer, it'd be getting a nice starting point at least.

I know we also need to think about glare and also the tone mapping too which might change things.


Infact, in theory, if we know the exposure > EV curve, would it be fairly easy to write a 'camera' tone mapper that basically took a 4 stop wide EV range and then black or whites out pixels at each end?
It might get us to a nice place for at least comparing photos?


I think we are rapidly approaching a point where the shader is close enough, it's the balance of values we feed it via textures etc that will make it look right or wrong... so being able to author nice textures and check the results against photos will be useful too I guess.



Cheers

Dave
 
OK I added back in your -gloss...

It doesn't seem to do too much... I'll just go with your logic for now hehe.




But I still feel the gloss vs spec balance is out.

It feels like the spec power should be say twice as high at any given gloss level.


Getting a road to feel worn without it looking like you are driving on patches of glass is quite impossible.

It's like as soon as you get the characteristic blue reflection in the wear marks the gloss is too sharp for the level of specular you get.

It's subtle. I can get an ok looking result in certain conditions, but then it doesn't change nicely at other times of day or driving directions etc...

It's almost like I want to amp up the specular power when heading into the sun, but then I also want to amp up the gloss value when looking for ambient specular 'blue' reflection in the glossy worn road surface.

But if I amp specular into the sun then it looks silly when the gloss gets high which I want to do to get the blue reflection from ambient specular.


My only feeling is that I want to use higher gloss values because it feels like I should, but the specular is getting too tight a spot when I do so.


Is there any elegant or easy way to just have a control that *only* changes the specular spot size but leaves the power of the specular the same?


Hmmm

Dave
 
PS, the normal map is being weird here.

On one track it's right, on another it's wrong. I wonder if it's to do with the coord mapping?

Even on the asphalt test track it seems to change from one shader to the next.

Dave
 

Latest News

Are you buying car setups?

  • Yes

  • No


Results are only viewable after voting.
Back
Top