Texture specular highlights

Blitz3D Forums/Blitz3D Programming/Texture specular highlights

JoshK(Posted 2004) [#1]
Anyone done anything like this. I can think of a number of ways (From Spacechimp's site):



Picklesworth(Posted 2004) [#2]
Loki_uk did this over at blitzcoder. The whole thing kind of disappeared though.
Pretty sure he just used two layers - a sphere-mapped light layer, and a specular map layer on top. Not the best method probably, but it works for simple uses.
http://www.blitzcoder.com/cgi-bin/ubb-cgi/postdisplay.cgi?forum=Forum14&topic=001492


Uber Lieutenant(Posted 2004) [#3]
Yea, Loki accomplished this a while ago, but either his technique is simpler or it was just never put to practical use like this example. Excellent work, Halo (as usual)!


JoshK(Posted 2004) [#4]
I didn't do anything.


Picklesworth(Posted 2004) [#5]
HAHHAHAHA!
Shame, shame, shame.


MSW(Posted 2004) [#6]
Well, you can use a greyscale cubemap to generate the highlight areas, then put the mask atop that. that would at least generate the specular highlights as intended

I'd imagine something like this:

texturelayer 0 = a color cubemap used to calculate surface normals for DOT3 (setcubemode 2, blending with multiply on a white fullbright model)...can also be done through verticy coloring, or even a seperate "light map" containing normals converted to colors

texturelayer 1 = the normal map DOT3 blending...see this thread: http://www.blitzbasic.com/Community/posts.php?topic=39353 which has my normalmapped animated mesh example that used cubemaps

texturelayer 2 = a color cubemap (setcubemode 2, multiply or mod2 blending) to generate the effect of colored lighting (agin see how that works in the link above)...this could also be a conventional "lightmap"...or not used at all

Texturelayer 3 = normal diffuse color layer

Texturelayer 4 = a greyscale cubemap for spectral highlights (setcubemode 1 or even 3, additive blending)...either store in a file or modified when loading by reduceing the brightness to half or less...basicly no RGB color value greater then 127 ...basicly you want this to be pretty dark (may have to play a bit with how dark it should be)

texturelayer 5 = the greyscale spectoral highlight mask (multiply blending)...again like the cubemap...either store it in a file or modify it at runtime so no RGB color value is less then 127...basicly you want this to be fairly bright (again, you would likely half to play with it a bit)

colors are in the range of 0 to 1.0 on the GFX card...which can work to your advantage...as long as you realise that anything over 1.0 is truncated, you can use the textureblending settings to do all sorts of things.

say you have a RGB color value of 32,32,32 (or about .125,.125,.125) a very dark grey...the spectoral highlight cubemap has an RGB pixel color of 8,8,8 (or .03125,.03125,.03125) at that particular pixel location when rendered...as the cube map is additve blended the result would be an RGB value of about 40,40,40 (.125 + .03125 = .15625)...then the spectoral mask is multiplied atop that...say the RGB pixel color at that location is 235,235,235 (or about .9179688,.9179688,.9179688) and the resulting RGB color would be about 37,37,37 (.9179688 * .15625 = .1434326) slightly brighter then before..which might be exactly what you want...on the other hand if you didn't want that particular pixel to be brightened at all, effectively remaining the same 32,32,32 RGB color...if the spectoral mask RGB color for that location were 209,209,209 or .81641,.81641,.81641) then multiplying it with .15625 (the surface grey with the additve blended spectoral highlight) results in .127564 or RGB values of about 32,32,32 takeing you right back to where you started...which again, might just be what you wanted.

The darker the spectoral cubemap and the lighter the spectoral mask, the more subtle the effect...at least in theory :P


JoshK(Posted 2004) [#7]
I can't think of any way to make a spectral highlight cubemap that will look right. What you want is a light that kind of follows you around, and cubemaps would just look like a skybox in the wall, or else a weird stretchy shiny metallic reflection.


MSW(Posted 2004) [#8]
yeah, cubemaps can look like reflections...but thier ability to do so is exactly what you want.

spectral highlights occur due to the light from a strong lightsource being reflected off the surface directly into the camera and/or viewers eyes.

say you have a nightime skybox with a full moon in it...the spectral highlight cubemap would be completely black, except for the moon...then additvely applying this cubemap to the ground (setcubemode 1 ... see: http://www.blitzbasic.com/b3ddocs/command.php?name=SetCubeMode&ref=3d_a-z ) it would produce the desired effect.

this is because setcubemode 1 gives the illusion of depth when moveing...load a level mesh into blitz, load a cubemap, setcubemode 1 and apply it to the mesh...then move around, bits of the cubemap will seem to travel with you...just like your discription of setting up a light to follow the camera around.

setcubemode 2 doesn't work that way, re-run the same level mesh and cubemap, changeing the cubemode...and the result looks a bit like lightmapping...as you move around the cubemap highlights and such stay planted in place...

try it again with setcubemode 3, which has a completely different effect.


JoshK(Posted 2004) [#9]
What I am saying is you want that light-traveling-with-you look, but there is no way to do that where the light will appear correct for all orientations a surface might be.


JoshK(Posted 2004) [#10]
What I am saying is you want that light-traveling-with-you look, but there is no way to do that where the light will appear correct for all orientations a surface might be.

It's easier just to map a sphere hightlight on the wall and update texture position as you move the camera.


Damien Sturdy(Posted 2004) [#11]
Hey, should i be able to multitexture when using a cubemap? if so, my current drivers are fooooooooooxxored


@rtur(Posted 2004) [#12]
Did someone cracked this?


AntonyWells(Posted 2004) [#13]
From extensive research(yeah, research..) playing counsterstrike source, It appears the specular map is projected from the centre of the camera position, using a 3dsquare projection that is not dependent on the view.

Which suggests a cube map that is not being tex-gened from the entity's model viewmatrix, but is actually using the cameras positional matrix(Not rotation, otherwise it would warp when the camera turned), probably feed into a vertex/pixel shader. (You can pass 4x4 matrix pars, so doesn't matter if it's a built in feature, it's still possible.)


@rtur(Posted 2004) [#14]
>Texturelayer 4 = a greyscale cubemap for spectral highlights (setcubemode 1 or even 3, additive blending)...either store in a file or modified when loading by reduceing the brightness to half or less...basicly no RGB color value greater then 127 ...basicly you want this to be pretty dark (may have to play a bit with how dark it should be)


Can someone give example of this cubemap,please?
Cubemap will be better than sphere hightlight for car, imfo...


JoshK(Posted 2004) [#15]
[quote]From extensive research(yeah, research..) playing counsterstrike source, It appears the specular map is projected from the centre of the camera position, using a 3dsquare projection that is not dependent on the view.

Which suggests a cube map that is not being tex-gened from the entity's model viewmatrix, but is actually using the cameras positional matrix(Not rotation, otherwise it would warp when the camera turned), probably feed into a vertex/pixel shader. (You can pass 4x4 matrix pars, so doesn't matter if it's a built in feature, it's still possible.)[quote]


Exactly. I think you would get better results just using a circular gradient texture and mapping it yourself, like what I did in one demo before CubeMapping came out.

Play some Doom 3, and you will see a circle like this following you around on the walls.


AdrianT(Posted 2004) [#16]
I kind of did it in a test terrain using 2 layers aof geometry and some multitexturing between the two. An example can be seen here:

http://s93153354.onlinehome.us/rot.wmv

doesn't have the detail, and you will probably have alpha problems but it still looks cool. About 512k in WMV format