The shader thread?

I'm messing with shaders a bit right now.

Right now I am looking specifically at adding control for specular to the existing reflect shader... on Deyan's Murcielago the unified wheel/tyre texturing poses some problems.

I have to control reflection strength with an alpha map, so use the old trick of adding a syntax in the reflection shader so if we define reflection = -1, the baseCol.a is used to control reflection strength.

ambientColor=FresnelMix(ambientColor,envColor.rgb,(Kr>0?Kr:-Kr*baseCol.a),fresnel);


The problem now is that I have no spare texture slot for specular/shininess control.

So I have added this little fragment of code (from the bump speca shader)

Ks=baseCol*Ks;

This now allows the colouring of the outside of the tyre in the diffuse (rgb) channels, to do some work.



However, because the tyre is still dark in the diffuse texture (near black as it is a tyre), it doesn't have much effect on it's own.

I need to somehow increase the brightness of the texture so Racer pumps up the specular we see.

So I added a *5 multiplier to the Ks as you can see in the image attached.

shader_01.gif




Now what I don't understand is why the two images look different.

First case:
Ks in car.shd is 8, while Ks = baseCol * Ks * 5 essentially gives us Ks = baseCol * 40

Second case:
Ks in car.shd is 40, while Ks = baseCol * Ks essentially gives us Ks = baseCol * 40


Now, I don't get why they look different. Ks is meant to control the size of the specular too, but in either case they both calculate out to a peak shininess of 40, because the baseCol lookup isn't changing.
The specular settings remain the same.

It appears that multiplying by 5 in the shader means the specular level is pumped up 5x, while the shininess (size of the specular) is retained at 8 in the car.shd...

That is the effect I wanted to achieve, pumping up the actual output of the specular blob, while keeping it soft at a value of 8, but it seems un-intuitive/wrong because the value that really needs bumping up is the specular value, not shininess? (though the specular being multiplied by 5x (2.5 2.5 2.5) looked awful)

Am I missing something obvious here?




Ideally I'd like to control reflection amount, specular AND shininess using one shader here...

Probably using rgb.a for diffuse.reflection strength, and then another 3 channel texture for spec/shine and leaving another slot free for something else (perhaps transparrency?)

Specular/shininess maps add so much to these kinds of materials, so it is a shame that they haven't really been considered in the default shaders very much. I think they should almost be defaults in all materials that err away from being generally reflective (ie, using the envmap)


Bodging in the code I have for the Lambo works quite nicely in this case, but it's obviously not ideal to use the diffuse channel to control specular in this way.



Hmmmm

Dave
 
Quantum Field Theory? :D


Anisotropic shader? What did that do exactly?
Haha surely you know what QFT means :p

The anisotropic shader basically made carbon fibre look good, instead of the specular going across the whole object (imagine a sphere) it'll work with the fibers of the CF. Look at a pic of some cf if you don't get my explanation.

Alex - you might need to check the alpha of the body shader. The alpha controls reflection.
My car is white in the preview (I assume ruud hasn't changed the preview to include shafted etc. yet) but fine in-game.

Looking to a release soonish so it might help with some standards for racer and maybe something for reference when upgrading cars. We'll see.

At work right now so I'll have a look when I get home to see if I can successfully update a car and post the results. Maybe a tute too since there is a LOT to change.
 
Haha surely you know what QFT means :p

Actually, I had to google it :p

The anisotropic shader basically made carbon fibre look good, instead of the specular going across the whole object (imagine a sphere) it'll work with the fibers of the CF. Look at a pic of some cf if you don't get my explanation.

Alex - you might need to check the alpha of the body shader. The alpha controls reflection.
My car is white in the preview (I assume ruud hasn't changed the preview to include shafted etc. yet) but fine in-game.

Looking to a release soonish so it might help with some standards for racer and maybe something for reference when upgrading cars. We'll see.

At work right now so I'll have a look when I get home to see if I can successfully update a car and post the results. Maybe a tute too since there is a LOT to change.

I guess, the easiest solution would be to have specular map which determines the amount of specular?
In that case, no special shader would be needed, just a "dyn_*_spec*.cg" something.
 
Got the files Mr Whippy, thanks, I'll try them out. I may have tried to get them while you were updating them.

The darkening is now gone after I adjusted the racer.ini file to the settings I've used for a long time that work, Don't know which one did the trick. My racer.ini file is posted in the 0.018 thread.

I found a water cg file, can't remember where I got it but the reflections are terrible, otherwise works good on my SNS track.

If anyone wants to try it...
 

Attachments

  • water cg.7z
    1.4 KB · Views: 142
I'm beginning to think that Racers CG is seriously broken. I've tried everything to get some of my old shaders to look merely acceptable and have had no luck. It looks like when Ruud went to the K-lux system the shaders were somehow left out. Some cars will look fine in the preview window but look blown out ingame(pics 1.2.), others appear totally white in the preview and look like a toon shader ingame.(pics3.4)

Alex Forbin

I think it's all about using real values now.

Ie, quick fast rules I find work nice so far.

Nothing is black, nothing is white. 0-255 ~ 0-100%

Darkest objects are near 5% reflectance, say charcoal, most black car paint bases are near 10%.

Whitest white objects are about 90%, maybe 93% at a real push!



Next issue, clouds layers seem to not have been set up for HDR? With my fairly real curves for partial overcast sky, I need to use a setting of around 7 at midday, and that number nearing 0.5 at sunset/sunrise... right now the clouds value can really pump up scene intensity and mean odd exposures are used.

I'd prefer clouds to be changed, using rgb for normals, and alpha for the cloud density (black no cloud, white is solid cloud (possibly not real since all clouds are a bit transparrent)), and then let Racer do the rest.

These clouds should then persist into the night time, and the night time sky colour should be a function of the sky renderer (same mechanism used in the day time)
Not sure how you would do stars, perhaps another texture for the starfield?


I'm having difficulty understanding the night curve and how best to blend day to night. Right now it seems the night curve is defining the sky colour AND details, while when we move to the day time the mie/ray sky takes over... it's just not very elegant. Also, the LDR nature of the maps for the night time, and high exposures needed, means we get nasty gradients etc in the sky.
A clear day/night sky should all be done in Racer automatically. The star field should be done like clouds, but just a single 8 bit channel masking off a white emissive material for the stars?


Hmmmmm




As per curves generally, it seems the shape is fairly standard. In theory we could have a standard curve for diffuse, one for ambient, and scale it in vertical height for peak intensity, and width wise to match sunrise/set times automatically.
Then you could tint the curve with a simple warming/cooling slider curve, rather than having to maintain 3 curves. Cool the sky curve, warm the sun one.

It seems we only need to tweak perhaps a few things. Even the warming/cooling curves are probably a function of the mie/rayleigh we set.

Ultimately, I can see us only really needing to have curves for extinction factor, mie and rayleigh, and some kind of cloud controls... the rest of the curves seem to be impacted by those variables directly, or are fairly fixed (ie, before the sun hits the atmosphere it's power and colour are constant)
Everything that adjusts the basic parameters is atmosphere based and we can/should be defining just that.

That is how 3ds Max IES sky/sun work, and Maxwell renderers sky/sun... you define lat/long, cloud cover type if any, and then some atmos params (fog amount, turbidity, ozone, or ray/mie etc), and then the programs calculate the rest based on lat/long and time etc...


It's just getting to that optimum algorithm that is important and will take time to get working right :D


I'm happy, if wanted, to output some maxwell HDR's at 10min intervals for a 24hr period so the intensities can be assessed, and do it at a few places around the world etc...
I have no idea how to actually come up with the algorithm, but I guess it's out there.

Ie, when mie/ray make the sky go orange, scale the sun diffuse output colour towards orange?!

I dunno :D

Dave
 
In some other applications, the sun diffuse/ambient is handled by a CPU simulation of the mie/rayleigh scatter on a given direction so it could be updated automatically, but this is not an optimal solution as sky intensity and ground intensity is not the same as the atmospheric scatter model is not designed to handle that . Current TOD curve system is straight forward enough to tweak colors though...

The light map implementation is just an experiment to demonstrate what racer is capable of, no offence for using dynamic lighting here.

Anyway, for those who like to try it out, here is the test scene: http://www.mediafire.com/file/n97gd72dbr8dsvr/LightMap_test1.rar

Edited: turns out the encoded HDR texture is faster than conventional floating point textures...so it looks like there is no need for fp dds at the moment. The encode/decode technique can be also apply to render buffers to increase performance as modern gpus are always ROP/bandwidth bound than ALU bound
 
Yeah, intensities are a different matter for tweaking, aside from the colouring.

The main difficulty is tweaking the tint when hte values are tiny (ie, on a night time adjusting the intensity might see you add 25% more blue or red by accident)... you have to edit with curvEd to get really accurate colour tints imo... just a downside of having to edit RGB rather than a warm/cool tint slider perhaps?

Also, the curves are clearly very consistent in shape, so it might make sense to have a really nice curve and just scale it to fit sunrise/set times and then vertical scale for intensity (that is where we try get real values at midday for the desired conditions and then input that)

I guess ultimately there may be a trend that says intensity is a function of the sun angle in the sky, so that could be set automatically too.


These 3d apps clearly do lots of this automatically, so trying to go down that route is probably going to be easier for artists.

Of course, I still think that if users want to set them, then that is fine, but it's a big process. Sunset/sunrise times impact the curves massively, for the night curve, ambient curves, diffuse curves etc... not an easy change!
But for most people, I think mie/ray/extinction_factor are plenty to make our skies look how we like... and then have clouds as a variable to turn on/off like rain and snow.... just make sure that when we use them ALL the other things adjust properly in the background too (ie, sun intensity drops off loads, sky intensity goes up a bit (it seems)) etc etc...

Hmmm


No offence meant gtpdzbiz, I was perhaps a tad harsh. I'm just looking forward to V0.9 so the vast user base of Racer can start enjoying it again properly... any hold ups are hurting my brain more (more to think about haha), and Racer is becoming more and more forgotten I feel!

Dave
 
I too am looking forward to 0.9, but I don't want to be in such a hurry that we end up with a compromised version that is almost immediately outdated by a major advancement or that would make us need to wait forever for a new major feature.
I think once we get the TOD stable the wait won't be nearly as painful. I also like the current pace of development as opposed to the months of nothing we had for years.

Alex Forbin
 
I think right now we already have quite a lot of nice features in Racer for v0.9 final. So, any new betas would need to fix the existing bugs and finalize existing features and then we're golden.
 
It seems we only need to tweak perhaps a few things. Even the warming/cooling curves are probably a function of the mie/rayleigh we set.

I think until we understand the interrelations between the parameters better, it's more flexible to keep the current separated curves. After all, it should just be setting some atmosphere parameters like haziness and all should be calculated from that. But the thing is we don't really know how that works and even then it might not fit perfectly in the engine as it is, and some creative diversion is needed.

BTW when hovering above a control point in the TOD editor, press N to enter a value numerically. That's what I do to avoid log-based displaying right now. ;)
 
Hmmm...eight textures for a material??...that's insane...many of them can be group together to reduce the precious texture bandwidth though.

Anyway, here's the alpha version of the dynamic sky:
screenshot025.jpg


It takes advantage of racer's atmospheric scattering system so the colors are pretty good specially at dawn/dusk. And it's fully animated so you can watch the cloud scrolling across the sky with different shapes.

material:

vf_cloud
{
vertex_shader
{
file=clouds_v.cg

}
fragment_shader
{
file=clouds_f.cg

}
}


shader_cloud~vf_cloud
{

sky=1
cull=none

casr_shadow=0

layer0
{
map=cloud_normal5.dds

depthwrite=0
blendfunc=blend

}

}



It use a cloud dome so you got to modify geometry.ini too.

download:http://www.mediafire.com/?b4ma5hjse26mogb


Just wondering how hard it would be to tweak this gtpdzbiz?

I'm trying to make the current sky system use your normal map and alpha map for clouds, so not animated, but having the clouds light up and pick up the sky/sun colouring by using normal information...

BUT, I'm not having much luck :D

Any hints/tips to getting it to work?

Many thanks

Dave
http://www.racedepartment.com/members/gtpdzbiz.html
 
I think I prefer gtpdzbiz's method with seperate cloud dome, as it it is 'right' in that the sky is the sky, and clouds aren't part of the sky really, they are objects that from our earthly perspective appear in the sky. I think it also lends itself to more flexibilty, in that we don't have to alter the sky overall to change cloud effects etc which isn't realistic as the sky stays the same whether there are clouds or not, the clouds alter our view of the sky from our perspective on earth.

gtpdzbiz, can we make the clouds cast shadows? (cast_shadow=1 doesn't seem to work, also u typo'd casr_shadow above)
and the live envmap i.e. reflections stays static; reflections don't show the cloud movement. Any ideas?

Also, u should probably have mode=linear in layer0 as its a normal map.

Last edit, I tried adding alpha_to_coverage=1 to layer0 as well, and WOW, it makes the clouds perfect.
 
I agree.

I've been trying to make a second dome inside the sky dome, which has a shader like gtpdzbiz used, but simply applied to the static cloud transparrency we had before. OK, it's not animated, but we can define the normals really nicely so the clouds light up properly depending on the sun position.

Either way, the sky does need to be separated from the clouds so that they can be managed properly for lighting, colouring, shadowing etc... the current blend system just doesn't work nicely unfortunately.


Dave
 
Not that I know of, I will be looking into one soon to use for a fountain; I've been playing with a rework of Broken Springs including Cg and a better layout, and moveable's like shopping trolleys and industrial bins & trucks in the loading bay area.
I'll share the shader when i find something.
Collision sounds can be fun; I made the cows on swiss stroll scream like homer simpson when u hit them & fart if u scrape them. My boys loved it.

[edit] this water Cg http://www.torquepowered.com/community/resources/view/10357 looks interesting, colud be modified to work with Racer.
'
Known bugs/limitations:

- No refraction support;
- No specular;
- No fog (at most times it looks like the water is fogged, because the reflected scene is fogged);
- No proper support for using a static envornment map instead of a full reflection (it does use the texture, but it remains fixed, and won't rotate along the view, as the original did);
- Sometimes the reflection can go strange and "melt away". Something to do with clip planes;
'
 
@DavidI: Ok, thanks. I used the vf_chrome shader and did some tweaking in the shd instead.. looks semi-real, but not perfect. See the attach. About sounds, Racer really does need more sounds, Tibs pointed that out a long time ago. I have added some really nice sounds to Badlands Revisited: Distant hawks and eagles, soft winds and dogs barking.. it makes a difference for sure, and the environment comes alive, and makes it much more fun to drive around. Now I just have to figure out how to do lightning flashes..

PS: For those who want to add sounds, there is a huge library here: http://www.sounddogs.com/
 

Attachments

  • pond2.jpg
    pond2.jpg
    96.7 KB · Views: 233

Latest News

How often do you meet up (IRL) with your simracing friends?

  • Weekly

    Votes: 59 9.3%
  • Monthly

    Votes: 32 5.1%
  • Yearly

    Votes: 39 6.2%
  • Weekly at lan events

    Votes: 3 0.5%
  • Monthly at lan events

    Votes: 2 0.3%
  • Yearly at lan events

    Votes: 14 2.2%
  • Never have

    Votes: 495 78.2%
Back
Top