I've spent the last few days reworking some of the core shaders in my XNA games and in particular working on the shaders that render the cars in our racing game Shadow Racers.
I've managed to get it all working just as I want now except for the reflections and I've spent the last few days wondering how best to calculate and combine the reflection with the diffuse colour. This morning I was searching again and found some information about the Fresnel Term (and I had infact seen it in an XNA sample yesterday but didn't realise what it was).
Basically the dilemma I had was that the cars contain painted parts and black/grey parts (the windows) with a mask texture defining how reflective those parts should be.
I couldn't quite figure out the best way to combine the diffuse colour and the reflection but having now read about the Fresnel Term I think that should work.
Basically you take the dot product of your surface normal and your view vector then use that to lerp the diffuse and reflection maps. When done correctly, looking directly at the surface should yield no reflection and looking parallel to the surface should yield 100% reflectivity.
I'm going to have to see how this looks tonight but if it works then I think I'll finally be happy with the way the cars look and will get some screenshots ready for those who're interested.
If you found this post helpful please leave a comment below: