specular highlight on a road - can it be done?

Blitz3D Forums/Blitz3D Programming/specular highlight on a road - can it be done?

Vorderman(Posted 2007) [#1]
I want to get a nice specular map effect on a road surface, but I can't find any way to do it, and all the forum search results are out of date with no accessible examples.

Like this :


HAs anyone managed this sort of thing?


big10p(Posted 2007) [#2]
That looks bump mapped to me. Not sure you could achieve that effect fully in B3D. Not sure, TBH.

Doesn't a regular spec map applied to the road mesh cut it, then?

[edit]I mean, a sphere map.


fredborg(Posted 2007) [#3]
It's very easy to do... Take a look here: http://www.blitzbasic.com/codearcs/codearcs.php?code=1928

You can also use a reflection map (instead of a light) for defining the specular effect. That way you can have street and car lights reflecting in the street.


puki(Posted 2007) [#4]
It's about time "fredborg" handed over his hard-drive.

I quite like 'LightColor light,100,100,0' - has a kind of warmth to it.


Vorderman(Posted 2007) [#5]
fredborg - thanks very much for that code, it ALMOST works - screenie below -



BUT there are 2 problems -

1. it needs quite a lot of polys in the road for the specular shine to work smoothly

2. it requires a point light - this is my major problem - my gameworld is lit by a directional which reduces this effect to a very tight and faint specular shine, so tight in fact it looks like a flash of light as you pan the camera around. I've tried (in the screenie above) to use a pointlight and move it with the camera, but the hills receive odd secondary lighting from it as they pass by, and of course with a directional and a point light everything is lit strangely and twice as brightly in places where the point light affects things.

So annoying because it almost works.

Would you be able to give me an example of the reflection map version instead? I've no idea what sort of refmap would produce this specular effect.


Nexus6(Posted 2007) [#6]
Fantastic effect, but I would also be interested in the reflection map approach that you mention.


Pinete(Posted 2007) [#7]
Vorderman, it's amazing, I hope you all the success! I'm not advanced coder as Fredborg, I cannot help you.. just to say go for it.
:)

regards!


big10p(Posted 2007) [#8]
Oooh, what game is that, Vorderman? A Blitz version of Ridge Racer? :)


D4NM4N(Posted 2007) [#9]
Sweet!! that lambo would look the biz with a sph/cubemap on it :)


Vorderman(Posted 2007) [#10]
It's a sort of Need For Speed (the original) but with lots more traffic, tokamak crashes, and best of all - motorbikes!
The road engine recycles parts of the road as the player progresses, so the road can be infinitely long and as varied as the number of track bits I can be bothered to build. Got to add some tunnels and hills next to spice it up a bit.

I knew that Ducati 916 model I made ages ago would come in handy for something, and the rider is the driver model from SRX, so he's getting some re-use also...





fredborg(Posted 2007) [#11]
Hi,

I updated the example to show how to achieve the same thing with a reflection map... Download the zip from here: http://www.blitzbasic.com/codearcs/codearcs.php?code=1928


Vorderman(Posted 2007) [#12]
Thanks Fredborg, with that cubemap you've supplied and a bit of editing I've got it pretty well sorted. I've toned the effect down so it's nice and sublte, but it does add quite a bit of depth to things.




Matthew Smith(Posted 2007) [#13]
Terrific stuff!


Vorderman(Posted 2007) [#14]
I forgot the effect the alpha would have, so I've added that back in and now it's working even better -



degac(Posted 2007) [#15]
slurp!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


John Blackledge(Posted 2007) [#16]
Wow! When?


bytecode77(Posted 2007) [#17]
cant wait to play it :D


puki(Posted 2007) [#18]
"Carol" considering we seem to helping you to program this game, how about handing over full source and media?

Seems fair to me. Plus, I'd like to check to see what other code of mine might be in there.

Email in sig.


Vorderman(Posted 2007) [#19]
The entire source code to my game is an fact composed of stuff that you've written Puki.

However rather inconsiderately you hadn't written it to my exact specification, so I had to make slight modifications which took up my valuable time, so I'll be sending you a bill shortly to cover my costs.

Next time, please make sure all your code is up to scratch, will you?

Ta
:)


Nexus6(Posted 2007) [#20]
@ Fredborg, thanks for sharing, thats a really simple but effective effect.
@ Vorderman, that looks really good, I presume that your roads are quite high polly to maintain a good effect. I dont presume to fully understand the above code but, did you have to create a duplicate road mesh to get the specular highlight to work?


Vorderman(Posted 2007) [#21]
The road mesh for the main visual tarmac is very low poly - one huge rectanglular poly the width of the tarmac, and twice as long.

For the specular effect yes you need a higher poly mesh because Blitz's specularity works on a poly basis, so to avoid really sharp jagged specular edges you need more polys to break it up. I'm using an overlaid mesh just above the tarmac that is 4x8 polys per single tarmac poly. Any lower res and the specular highlight breaks up badly.

Just added the first tunnel - it's quite un-nerving blatting through the curves not able to see past the walls -




Mustang(Posted 2007) [#22]
Speed ~39... not "top gear" exactly? :)

BTW, I'd change those tunnel lights to more yellow-green shade, that would be more "realistic" imo. Quick googling shows some quite reddish ones too, but I still think that yours are too red.

Otherwise nice job overall, like the "Coastal pacific" look of the road. Alright, I'll have nag about the shadows too, they are way too dark and sharp edged and the lambo's lighting in the screenshot doesn't quite match the very sunny and ambient environment.


Vorderman(Posted 2007) [#23]
Thanks for the comments.

The tunnel lighting is based from a reference pic I found that I quite liked ( http://flickr.com/photos/risumiru/113708255/ ) , so I'm not too worried about the colours at the moment. I want to avoid that "yellow/brown" look that most games seem to be developing (see the NFS Most Wanted screen right at the top of this thread).

re. 39 - well, it's not in mph, just in some unit I invented, so 39 is reasonably quick. Currently the bike will do about 70 flat out. I just need to add a proper speedo and calibrate it right.

The shadow of the bike is a polygon shadow, so it will be angular - I might swap to a single quad with a texture on it perhaps, to get smooth soft edges.

As far as the Lambo's lighting goes, in that screenshot I was testing the specular effect, so there was a point light as well as the main directional, which is why it looks a little odd. I'm back to one directional now so it looks accurate again.


Damien Sturdy(Posted 2007) [#24]
Awesome work! :)


Vorderman(Posted 2007) [#25]
Cheers, I always find it difficult to maintain any sort of momentum in these projects, but this one is holding my attention better than even SRX, but we'll see... :)


Pinete(Posted 2007) [#26]
Hi all,
First of all, congratulations for your game vorderman, great!

I've been following this post.. and as far as I can remember, vorderman included a specular function that worked depending on the light position, I guess was a modification of Fredborg..
Could you please point me where can I find that function and media? I would like to implement for the floors..

Thanks a lot!


Mustang(Posted 2007) [#27]
fredborg (Posted 1 month ago)
Hi,

I updated the example to show how to achieve the same thing with a reflection map... Download the zip from here:

www.blitzbasic.com/codearcs/codearcs.php?code=1928


Pinete(Posted 2007) [#28]
Thank you very much Mustang!
It seems is this version! :)

best regards!