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
 
Any shader improvements for the future ?

Did anyone working on custom shaders, please report your wishes & bugs, so we know what's must be done !

Actually, I've created 'real fire' with particle effects using the particle_vf shader, which doesn't look bad, but I could really use some animated billboarding going on, so please if you have something that iterates thru a UV grid/cell along time, that would rock.

I'll write a list of all issues actually encountered in 0.8.32 with shaders so we know what's need to be 'definitely' fixed.
 


Here's an issue I can't resolve, I actually tried to play with the uniform scale param inside the mix2_f, but I came to no results at all !
Please if someone could give a little look....for night tracks all shaders need to work with the bounce & bounce_alpha shader param...

On the picture, I'm using the standard_mix2_f cg shader.
 
QCM,
I have problems with the mix shader at night also and posted it in another thread. Rud needs to review both day and night conditions and fix.

I remember, since this is a terrain, I re-sized my UV proportionally & abusively to get some resolution when near clipping. Hm, was thinking maybe that's the reason...hm, not sure

Did you by chance play with the projective shader to get some light in night ?

I notice the texture matrix & some more cool things inside it, I tried to map that shader to an object, but had no real results....still I believe we can use it, to lighten our night tracks.
 
QCM,
I did take the alpha channels out of the textures used in the two mix.cg's used and they are posted in the technical thred as .jpgs as .tga's can't be posted.
Here are the shaders used.
 

Attachments

  • _watkins.txt
    210 bytes · Views: 291
Either in your track.ini take out the colorgrade=....tga or just delete that colorgrade.tga image in the track directory.
Deleting the image might give you a QLOG error though, so make sure boomer doesn't see you do it!!
 
Does anyone know of a way to define your own envmaps?

Ie, you have a bunch of cube maps and want to use them for certain track object shaders?

Now we have HDR imagery, how can we define these cube maps/envmaps as HDR?


Tempted to render some out around my track and use them as envmaps for specific things, but they don't need to be using the HQ live envmap (nor will they look best with the live map anyway)

Thanks

Dave
 
I think you can do a transformation to a cube map from a spherical in Photoshop or GIMP if needed.

It's a shame we can't use mipmaps of the live envmap yet, they would be useful for what you are probably going to be trying.


I'm sure there is a way to define a cube-map, we did it back in the old shader system, but I'm not sure we have done it yet in this new one. Seems silly using the high quality live envmap when a static pre-generated cube map will look better and perform better for the required purpose :D

Dave
 
There's a console command to generate a cubemap:
trackmap save

It doesn't seem to work though, in any of the 0.8.x versions I tried.

And the contents of the env-map layer in the shader don't seem to matter either... when I comment it out on track materials, it still gets the right (trackenvmap) response. Hmm.

Can't find any reference to it ever being possible to load a cube map through the shaders, either.
 
Hmmm, would be nice though.

Just trying to get a nice glass effect on the side of a building, but when it uses the envmap of the car it's obviously looking a bit odd. If I could just generate an envmap from the buildings POV and use that it'd be much more useful :D

Time to pester Ruud/Mitch then ;) :D

Dave
 

Latest News

How long have you been simracing

  • < 1 year

    Votes: 329 15.4%
  • < 2 years

    Votes: 226 10.6%
  • < 3 years

    Votes: 223 10.5%
  • < 4 years

    Votes: 166 7.8%
  • < 5 years

    Votes: 288 13.5%
  • < 10 years

    Votes: 247 11.6%
  • < 15 years

    Votes: 159 7.5%
  • < 20 years

    Votes: 121 5.7%
  • < 25 years

    Votes: 96 4.5%
  • Ok, I am a dinosaur

    Votes: 276 13.0%
Back
Top