A nice shader for track materials

Yeah that makes a lot of sense to do things like that.

I've read that mipping also causes some worries maybe, and it will do more so with TGA formats... but all in I think the added realism of doing things right will offset artefacts mostly.


Here are updates for the asphalt test track.

Obviously users will need the PBL shader from just above (or ideally below once it's fixed because currently it crashes)

Textures are flat normals rgb.
Diffuse rgb, and a reference UV chart in alpha.
Spec rgb and alpha are the same gradients are diffuse.

So it just runs from 0 > 255, in 9 jumps of 28, well the last jump is a bit more to get to 255 hehe...

So 10x10 balls from matte black rough balls to what should be smooth chrome at the other end I think!

Plenty of scope to play around with settings.


A perfect opportunity to export a cube map too, then we can have a play with using the output amount of the cube map to match the envmap... OK it might not be perfect vs proper cube maps, but we can make them generally ok for most track type stuff in Racer I'm sure. Ie, drop the res a bit blur them properly etc.
Also it gets the pesky envmap mie spot out of the envmap they will use too, so we can keep the mie sun spot for other stuff but keep it away from PBL materials :D


Dave
 
Asphalt

Grab the latest version at the link above.

Note, it needs the PBL shader fixing before it'll even work. Look out for the balls on the side of the track :D

Also note TOD updated and some colour gradient mapping in use etc.

Dave
 
Working now.

Maybe one of the black > white gradient maps needs flipping. I'm not really sure what I was meant to be doing here but it's easy enough to change to suit your needs :D

Ah yes, just done it, flip the spec map in horizontal axis.

We get a nice blend of materials now it seems.

Though the lack of blurring on the mip map is pretty obvious.


Test now is to make a cube map that looks the same but is using LDR static LUT :D


Cheers

Dave
 
Ah, no specular though it seems?

The mie sun appears to have kinda made up for that missing element at my end hehe.


Damn that mie sun :D


Maybe it's also worth removing the Kr factor in this shader too? Since we always want it at 1?

That way we can use the Kr to amplify up the cube map envmaps (LDR) to appropriate levels. Currently I'm having to hard-code that adjustment into the shader for testing.

Dave
 
Ks apparently defaults to 0 and I didn't get rid of the copy in LightingSun, so. You need to set specular=1 1 1 in the shader_test3 to get the specular spot to show.

3IvmXsN.jpg

The lit/unlit line is pretty sharp, I assume because it's passed like that. Should consider borrowing whatever the diffuse light does to smooth that transition out.

Anyway this is basically my equivalent to
result.png

Clearly there are some differences... the spec spot is smaller for me. Looks like the linearity of my horizontal gradient is different (or Racer's environment is just brighter compared to the light source). And I haven't investigated why the last row of balls doesn't get an envmap on my end.
 
Hmmm...

I notice in the envmap inputs Ruud's shaders say IN.R, while yours say R only... any significant reason why etc?

I only ask because the cube maps I've loaded in are flipped around a bit. Down seems ok, the rest are all flipped vertically it seems... maybe shuffled too. Hmmm...


LDR isn't so nice though haha... mainly it seems the mips don't work for cube maps which totally ruins that idea :(

And they are stuck as TGA only too, so no way to do blurred mips in DDS which would have really helped us to get the full range of reflections we want.



It'd be nice if Ruud could either allow DDS so we can do mips, or if we are stuck with TGA allow us to have the mips used.

But ideally it'd be really nice to call $trackenvmap >> $carenvmap (because that is what it is!), and then define a point on the track (xyz) which is $trackenvmap and is rendered in HDR at say 256px per side so it's only small, and is only updated at TOD change.
It can then make it's mips and maybe even blur them when it does it.


Please Ruud :D


As much as using the current car centric envmap is ok for now for testing etc, it's nowhere near ideal really, and probably costing much more FPS than this effect really needs vs just a nice smaller static HDR envmap :D

Unless of course there is a way in cg to 'grab' a copy of the envmap, process it (blur etc), and then store it for repeated use by the shaders?

Hmmm

Dave
 
Ks apparently defaults to 0 and I didn't get rid of the copy in LightingSun, so. You need to set specular=1 1 1 in the shader_test3 to get the specular spot to show.

3IvmXsN.jpg

The lit/unlit line is pretty sharp, I assume because it's passed like that.

Anyway this is basically my equivalent to
result.png

Clearly there are some differences... the spec spot is smaller for me. Looks like the linearity of my horizontal gradient is different (or Racer's environment is just brighter compared to the light source). And I haven't investigated why the last row of balls doesn't get an envmap on my end.


Hmmm, I'm not sure what the reference image is actually showing.

Do they really go to blacks or not? Maybe just tweak the levels to bring the blacks up a bit in diffuse at least, since the lowest value is ideally 50rgb or so in gamma space (charcoal)


The lit/unlit line is probably the sign of an error I guess. It seems to be multiplying against the ambientSpecular value somehow.



Either way it's nice to see this kind of range of materials in Racer renderer, all reacting as you would expect (almost haha)





I might bung Ruud an email and see what his thoughts are.

It'd be nice to have the flare option working reliably so we can turn off the mie sun and get a good reliably positioned result via the flare method I posted earlier.

Dave
 
Probably typical of bump_reflect shaders to use R instead of IN.R - although some might not, it has to do that to reflect properly on the bumps.

Only time I've played with my own cubemap I did have to shuffle the faces around a bit to get it to match how Racer expects it.

Can probably multiply LDR maps by lightColor to bring it up to the right illumination levels? I forget exactly what I did to make my cubemap look ok.


Reference image has horizontal variation in specular response (bias, in Racer terms), vertical variation in gloss. So it's just showing off the range of possibilities.
 
Ah I got the balls looking right here.

Change the spec gloss map to be vertical bands of the colours.

Change the spec IOR map to go from 5-255 (so 0.02 > 1)

Change the diffuse map to go from 50 > 240 or so rgb.


That is all now in normal realistic ranges and seems to give the spread of ball materials we expect.

balls2.JPG



Ah, but that said, note that the top right colour of the diffuse map needs to be black to line up with being a chrome material... ideally.

In any case it's working in principle.

Just need to alleviate that hard line in lit/shaded ambientSpecular response I guess :D


This shader will be nice for cars though.

In theory you can do all the rubber, plastics and such like with this shader.

Then all you'd need is a similar shader tweaked for car paint (lacquer over it with fixed properties)

It'd also do car interior materials very nicely too... just you'd really need a $incarnevmap for that haha... or a way to mask out the $trackenvmap elegantly so you didn't reflect the sky through the roof :D


Dave
 
Reference image has horizontal variation in specular response (bias, in Racer terms), vertical variation in gloss. So it's just showing off the range of possibilities.


So it's all dark balls then, tweak the diffuse map to suit since mine is white to black etc.

Also when you say bias, I assume that is what is in essence the IOR map.


If we stick to diffuse, bump, IOR, gloss, then I think it's all logical, well to me at least :D

So this is all dark black balls with IOR across, and gloss top to bottom...

They must have some kind of gradient in diffuse though to go from ~ 50rgb (lowest possible diffuse colour, give or take) to pure black for the chrome...


Either way I'm sure what you have got there is right now bar that issue with ambientSpec.


Dave
 
I suspect that diffuse + spec IOR should not sum to more than 1 - direct light absorbed by diffuse won't be reflected in specular. Not sure if the conservation option verifies this, since the IOR code is kinda new.

Then again, maybe diffuse and specular should be lerped together using fresnel, instead of added. Hmmm...

Does look like a good range of responses though. I suppose next would be setting rows of balls equal to various materials' diffuse+IOR data and seeing which gloss map values are correct.

Aside from the cubeMAPbias_soft and the need to make ambientSpecular fall off more smoothly from lit to unlit, do you see any issues with the shader?
 
Yeah the diffuse + spec balance is important. I'm not sure if your new approach avoids the conservation adjustments going on in lighting.cg now or not... but remember that diffuse/specular are internally adjusted with energy conserve turned on to make sure they don't sum more than the input energy iirc.

Then assuming the envmap has no mie sun in it the ambient energy is conserved too within it's own system... so no need to try balance that out with other things in this case.



The banding/harsh line is an oddity to me at this stage, though I have a feeling it's the mix of litColor/shadowColor we have going on perhaps?

Easy to test but I have no time to get stuck into this till tonight again hehe.



The range of responses seems pretty wide to me. It should suit most homogeneous materials for track objects etc.

I suppose for us the main need for now is the base materials use this shader, so most stuff isn't super high gloss, so a pre-blurred low-res, level/colour adjusted cube map in LDR will probably be ok for a given fixed TOD.

But checking against the live envmap now and again is a good sense check to make sure our cube maps look similar, and thus we are reliably tuning our materials.


So everything looks ok for now I think. Any troubles we are having are a feature of our engine limitations or some tweakery to the code required.


Cheers

Dave
 
Was busy yesterday, had some time today so here's the pbr shader without all the annoying sharp edges:
http://nmurdoch.ca/cg/dyn_pbl_bump_reflect_f.cg
Because I changed how the amount of ambient specular works I'll just run through the figures:
straight on, direction of sun: 1 (unchanged)
straight on, no sun (due to shadows): 0.69 (was 0.32)
edge between sun and no sun: 0.46 (was a sudden jump, 0.32 to 1)
opposite the sun: 0.23 (was 0.32)

Mostly I just bumped up the amount in shadowColor to compensate for not having it in litColor, while still allowing shadows to be visibly affecting it.

It also needs that utils.cg from the track now since it uses the soft reflections, but that's not likely to be a problem.
 
Hmmm I'll try get some reference imagery for finding a suitable balance value.

The shaded/lit interface is always gonna be a hard edge on a model like this.

Also not ideal to split ambient energy, we should multiply it down being in shadow, then when sunny = 0 the ambient spec is at full power not a fraction of it.

Also its more being in shadow that is important, rather than being unlit by diffuse. These balls are not in shadow so need full envambient, it'd be a road in shadow that we treat differently. Not sure if we can make that differentiation though... Hmmm.

Multiply envamb down with shadow mask only?

Dave
 
Haha.

These materials are really good if you use them.

But they just need a different approach to how you'd normally author textures.

On a car these should be able to cover off everything that isn't either the paint or transparent...

Your main car should use three shaders really, paint, this PBL one, and the glass one we have with several control textures.

Interior probably just needs paint, this PBL one, and transparency ones.


Best bit is that diffuse can be lower res, and then use higher res for the IOR/gloss map where the details are.

The only real change I'd make is to put an AO map in with the diffuse map.



As for the asphalt material, well it's kinda there but I've been too busy with other stuff to make some really good texture sets for it.

But technically it looks great, but you need a good sky/TOD settings for these shaders to fall into place properly.


Hopefully the Exeter Road project will bring these things together so we get nice shaders in a nicely lit environment that all complement each other properly! Then when we drop in cars made with the same shading logic they should look really really good too :D


Just have a few little bits to fix up wrt the sun/flare and energy conservation and where it all fits in the pipeline to get it working well.

Dave
 
The screenshots are looking pretty good! It would be nice to have 1 shader for most materials.
Usally materials need color, specular, bump and reflections maps. AFAIK there is no capable shader in the default set with all 4 attributes.
I was playing with some infrastructure models like houses and similar buildings and didn't get a decent looking texture with reflecting windows and good looking metal parts working.

metal+glas-shading.jpg
 

Latest News

Are you buying car setups?

  • Yes

  • No


Results are only viewable after voting.
Back
Top