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
 
If decals are just offset polys in Racer, they're always rendered on top of terrain, so no worries. I'm thinking more about projecting/painting my HM (heightmaps) with some decals & then split/optimize the scene for track export in Modeler/Tracked. That's really what Ruud was advising earlier.

Good question, in which order 3D objects are rendered in Racer for cars (in cockpit / outside) & tracks ?



Flickering means interpenetration of meshes.

@gtpdzbiz

Great !

I can put the polys 5cm above the track and they flicker at large distances from the helicopter view, for example.

I'm not sure how/why exactly, but it's depth calculation related. You need to force things to get rendered later if they have co-incident normals with one face on top of the other...

There are no interpenetrating meshes.

Hmmm

Dave
 
Hmmm, I thought that is what the sort-offset or depthwrite were designed to avoid, if you were willing to author these details in.

Hey ho, it's not a huge problem I just thought the above controls made it so it wasn't evident, and thus was it a bug I was seeing :D

From 95% of driving cameras etc it's not evident, just very slight from helicopter view mainly!


Main thing is, at 5mm off the track surface the car will drive onto them and detect their slightly slippier material, but you can't sense it in the car... this should make the white lines more interesting during racing, especially in the wet where the grip is significantly reduced :D


Still can't get shadows appearing on them. Even with ambient off and diffuse at 1.0, they are fully illuminated in the shadows :( (using DDS if that makes a difference)


Was semi-tempted to cut into my track polygons, then use the new 'mix' materials, and have the world mapped part for the paint, and simply draw in the lines/markings in the alpha map... avoids Z issues, bumps in the track polygons and all that kinda stuff... just is quite destructive in nature!
Not sure which way Ruud would suggest is ideal?!
Decal runway markings, or cut into the mesh and use the new mix materials?

Dave
 
Hehe, Cam has kept telling me to cut into meshes :D

I guess using the new mix maps will work then, using the UVW coords for the surrounding material we still get to see, and then a world mapped 'lumpy paint' material for the paint itself, and then just use the alpha mask for marking down where the paint actually goes.

I guess it is also good to make sure that skidmarks get laid down properly too, not sure if they do on decals etc... and clearly my shadow problem will go away...

Hmmmmm

Dave
 
Mr Whippy you're free to choose, both ways works. In Shift (I just gave a look at Alpental Track), you'll find some decal polys with alfa texture working with a normal (basic) shader on top of the road with a slightly "simplified" mesh => 2 triangles only overlapping the good tessellated road mesh...

The shadows should work if they're working elsewhere in Racer...but didn't yet give a deeper look.

FUTURE UPDATES IN EDITORS [TODS] + [SHADERS]

Concerning shaders & future updates of Racer, what about integrating a nice Material/Shader Editor inside Modeler & Tracked with some real-time/dynamic view when tweaking the shaders & the params. This tool would then output the car.shd file which will hold every custom params, shaders & textures paths/maps. The same already exists somehow in Tracked > Make Track_Template.shd. That would seriously boost our production & we could finally concentrate more time in compiling new shaders for new projects/tests.

About TOD management, why not using simply Curved & Tracked. On the X axis, you'll have the time represented & on the y axis, you'll split in different sections (HDR, Fog, Sun Intensity...) & each section has its min./max. values. Almost like Crytek Engine TOD amazing editor, hope you know what I'm talking about. Using the fast_time & time commands to control speed & time, we would then just sit back & admire our new TODs dynamically inside Tacked for example. All I can say, Crytek TODs Editor is one of the best I've been using lately, Ruud you should give a look at it !

Have a lot ideas & future for Racer looks great !
DIRT2, Shift & F1 2010 are all games which can be reproduced with ease.

Here's a link after some research for vertex/fragment shaders :

http://www.google.fr/url?sa=t&sourc...m72MgP&usg=AFQjCNFM5pQZtwHhN8SSyeJVvR1MncRfuA

Basically, vertex shaders are more used in 3D animation & fragment shaders are more suited for static meshes for what I understood...Read the pdf if you want to know more...

Another question, quite important, is there a way of making the driver hand bones rotating along with the steering wheel using some constraints ? Looking to give Racer more realism like Shift or DIRT2....
Anyone manage a full driver ?
 
I'll have a look at Carlswood's decal, see if/why they don't shadow. I think they should, although perhaps since they output transparency it might not work, as the alpha channel of one of the output render buffers is used to indicate shadow state. Hm.

Doing driver hands is possible, but undocumented yet, not sure if Mitch already had docs on that, I think not. It's quite involved though; doing animations in Max, splitting the animation in Modeler (ASE exports a big stretch of animation), then defining sequences in car.ini for the animations. It does do steering, shifting up & down, and even mixing those.

Haven't seen Crytek's TOD editor, does it come with the game or is there a separate link?

A general note on utitilies; our roadmap tries to capture more of the editing directly inside Racer, instead of offloading to editors. Editors are a pain to maintain, and we have very limited time. But I do agree to dedicate a few .crv files to most of the TOD parameters. Currently at 'time 1400' you need to lower exposure for example.
 
Transparent object with shadow is weird now, have u tried alpha_to_coverage=1 in the main shader? It works for car decal with proper shadows.

In the standard_transparent.cg shader, the GetShadowFactor line has been commented out so it can't receive any shadow.



And improved the volumetric smoke shader a bit so it now receive shadow~which helps it blends in the environment.:)

SC50631.jpg
 

Attachments

  • smoke_volum_fake_lighting_shadow.rar
    20 KB · Views: 147
The editor came along with the game + the official free SDK tools are downloadable.
Here's a picture, compared to Racer, Play speed is fast_time & current time is time in Racer.



Full image :

http://img94.imageshack.us/img94/5670/crytektodeditor.jpg

In tod files, it looks like that :

<TimeOfDay Time="10.059999" TimeStart="0" TimeEnd="24" TimeAnimSpeed="0">
<Variable Name="HDR dynamic power factor" Value="1.8814473">
<Spline Keys="0:0,0.410101:2.065,0.445417:0.444,0.472:0,1:0,"/>
</Variable>
<Variable Name="Sky brightening (terrain occlusion)" Value="0">
<Spline Keys="0:0.3,0.438735:0,0.473389:0.428571,1:0.3,"/>
</Variable>
etc...
Thx for animation info, I'll do some testing, just need to know how to trigger the sequence once a specific event occurs (like steeringwheel rotation left / right..etc..) ? We could theorically cut the animation is some sequences in Max to boost/gain some more time ?
 
It looks good, but I'm sure it could be much better. From here, it's too uniform & adding some randomness would be great.
Here's 2 textures used by Shift tyre smoke, as you can see, we would need a shader that randomize all smoke variations from the map...

Any shader capable of doing this ?

For clouds, you could use a dynamic particle effect emitting smoke/clouds which could be also dynamically moved by ingame forces/constraints. Or just the easy way, fake the sky with some poly alpha textured planes moving around by animation....Got even more ideas for clouds using skeletons & morphing of shapes, for sure you would need some good shader with it.

Same for water, I'm projecting of creating my own waters with this technique, I originally wanted to test it in CE2 (Crytek Engine 2)...

P.S.: Tell me if you want to see the Shift shaders that go with it, & all related files for better understanding how we could simulate the best illusion for real smoke...

I'll re-give also a look at CE2 Particle Editor, which is also one amazing tool with all values that you will re-find in other sim racing games like DIRT2...same way/technique



http://img10.imageshack.us/img10/5301/crytekparticleseditor.jpg
 

Attachments

  • Smoke_Textures_01.jpg
    Smoke_Textures_01.jpg
    48.8 KB · Views: 272
  • Smoke_Textures_02.jpg
    Smoke_Textures_02.jpg
    22.1 KB · Views: 252
Here is the PCF shadow shader, should have got rid of the flickering in screen-filtered one. Tested with 1024*1024 shadowmap size. It also utilizes some fake penumbra effect. Will add PCSS in the future to produce proper penumbra shadows. Feel free to try it out~

SC58631.jpg
 

Attachments

  • PCF.rar
    3.9 KB · Views: 165
How is PCF different to the one we have as default?

Dave

Firstly, It blurs the shadow in texture space rather than in screen space so there is no flickering or light bleeding when you rotate the camera, and it won't need an extra FBO for shadow so we may get some performance boost if Ruud is kindly enough to change the code a little bit and disable the shadow FBO.(Current deferred shadow technique can not generate accurate bloom effect as shadow FBO is not taken into account during the bright pass)

It can also produce some nice fake penumbra and if you have a decent GPU you can even use PCSS(a little bit advanced than PCF, generates real penumbra, so shadow blurs less near shadow caster, though not yet implemented)

Hope that helped
 
Tested the new shader and it is awesome! Certainly an improvement over the default one, I really hated how the default shader did the blurring in screen space.

The most significant benefit is the fact that the shadow is blurred in texture space as gtpdzbiz mentioned. Now, If the blurring could be improved to be less blocky at close distance, it would be really great.

Ruud should certainly use gtpdzbiz's shader!
 
Now, If the blurring could be improved to be less blocky at close distance, it would be really great.

As you wish, increased the sampling number, should be better now(however, too much sampling = performance drop). Just replace "constants.cg" in the renderer/common folder.

Edited* Now the latest one shrinks the blur size a bit but complitely gets rid of the 'blocky shade',

replace the orignal 'shadowmapping.cg' in data/renderer/shaders and set shadowmap size = 1024 in racer.ini(otherwise the filter will fail).
 

Attachments

  • shadowmapping.rar
    2.1 KB · Views: 165
Looks pretty good :D

I still have a feeling the fresnel or mixing isn't right or something, but things are just getting better and better generally! Racer looks fantastic, and is only getting better and faster :)

Dave
 

Latest News

Are you buying car setups?

  • Yes

  • No


Results are only viewable after voting.
Back
Top