I was fiddling around with editing the normals on a model to help the light play off a spinning wheel. It picks up the specular fine, but it's a pain to work with and apparently can't be done in Blender.
So I looked through how bumpmaps work, and made one that's physically impossible as a flat surface, to produce the effect I wanted.
This texture, used as a bumpmap, represents a 45 degree slope at every point on the plane.
Interestingly, the way this texture is rotated changes the direction of the slope. The way it is now, or a 180 degree rotation, are clockwise/counterclockwise slopes around the centre. Rotating it 90 degrees in either direction produces inward/outward slopes. Other angles end up somewhere in between.
This, for example, is the counterclockwise slope. Since it's angled toward the light at the top right, it's brighter, and it's dimmer on the bottom left since it's facing away from the light. The object it's mapped to is flat - the "point" at the centre is entirely a result of the texture.
This is useful, because on a blurred wheel, you effectively have the angled parts of the spokes spreading out into a flat surface, that reflects as if it were at an angle. (I note that brushed metal can also have reflections like this, so maybe this has other applications).
In order to use the effect ingame, I split the wheel into a few layers. The first is plain and simple - flat surfaces. The tire and outer rim of the wheel, as well as the face of the spokes, are flat.
A radial blur in the GIMP produces the texture.
Slightly behind that (at roughly the average depth of the sides of the spokes) is the interesting layer. It's mapped to another circular flat surface.
(this one might be hard to see on the forum, since it's light gray and mostly transparent)
This is a picture of the clockwise-facing polygons of the wheel, flattened out to face the viewer more directly (mostly a matter of making them wider), and blurred similarly to the previous image. This layer gets the bumpmapping from earlier applied - there are actually a pair of these, one clockwise and one counterclockwise, representing the corresponding sides of the spokes. When they catch the light, as in the earlier image of the composite wheel, they light up at an angle from the surface's normals, so you get the proper lighting on the spokes even though they're mapped to a flat object.
Behind these would be the brakes, axle, etc.. - which I didn't model.
The shaders are pretty easy - standard_f/v for the regular surfaces, bump_f/v for the angled ones. I haven't tried with reflections but I expect they would work.
I hope this makes sense, and is useful to someone.
(and then there was more)
To produce the radial gradient, there are 4 compass colours - +red, +green, -red, -green.
Since the bumpmap is expected to be normalized, step 1 is to decide the angle you want (eg. 45 degrees). Take sin/cosine of that angle -> .707/.707. Assuming 0 degrees to be normal (and 90 at a right angle to that), blue is cos and red/green are sin.
rgb triplets for the 4 points are:
+red: (128+128*sin(a), 128, 128+128*cos(a)) = (219, 128, 219)
+green: (128, 128+128*sin(a), 128+128*cos(a)) = (128, 219, 219)
-red: (128-128*sin(a), 128, 128+128*cos(a)) = (36, 128, 219)
-green: (128, 128-128*sin(a), 128+128*cos(a)) = (128, 36, 219)
Once you have these you can just make a gradient with them in that order, counterclockwise. For example, in the image above, I have +red pointing down, then +green pointing right, -red pointing up, -green pointing left.
If you switch them (clockwise) you end up with conflicting directions, and ingame the specular will rotate twice as fast as the wheel, instead of staying still. Easy to fix though, just mirror the texture (if your object is mapped mirrored, you'd need to do this in reverse to compensate, horizontal mirror works fine).
The direction of +red determines what angle to the surface the normals take (I think it's down - clockwise, right - inward, up - counterclockwise, left - outward but I'm not sure).
It's probably possible to combine the transparency of the various spoke parts with the "flat" bumpmap colour (128, 128, 255) to produce a composite bumpmap that handles more than one surface (and would give a single reflection at any point on the wheel instead of blending them ingame) but I don't know whether that's a good idea.
I also had a question. What are the blur models (and corresponding speed to switch) called in car.ini? I couldn't find any reference to it on racer.nl.
So I looked through how bumpmaps work, and made one that's physically impossible as a flat surface, to produce the effect I wanted.
This texture, used as a bumpmap, represents a 45 degree slope at every point on the plane.
Interestingly, the way this texture is rotated changes the direction of the slope. The way it is now, or a 180 degree rotation, are clockwise/counterclockwise slopes around the centre. Rotating it 90 degrees in either direction produces inward/outward slopes. Other angles end up somewhere in between.
This, for example, is the counterclockwise slope. Since it's angled toward the light at the top right, it's brighter, and it's dimmer on the bottom left since it's facing away from the light. The object it's mapped to is flat - the "point" at the centre is entirely a result of the texture.
This is useful, because on a blurred wheel, you effectively have the angled parts of the spokes spreading out into a flat surface, that reflects as if it were at an angle. (I note that brushed metal can also have reflections like this, so maybe this has other applications).
In order to use the effect ingame, I split the wheel into a few layers. The first is plain and simple - flat surfaces. The tire and outer rim of the wheel, as well as the face of the spokes, are flat.
A radial blur in the GIMP produces the texture.
Slightly behind that (at roughly the average depth of the sides of the spokes) is the interesting layer. It's mapped to another circular flat surface.
(this one might be hard to see on the forum, since it's light gray and mostly transparent)
This is a picture of the clockwise-facing polygons of the wheel, flattened out to face the viewer more directly (mostly a matter of making them wider), and blurred similarly to the previous image. This layer gets the bumpmapping from earlier applied - there are actually a pair of these, one clockwise and one counterclockwise, representing the corresponding sides of the spokes. When they catch the light, as in the earlier image of the composite wheel, they light up at an angle from the surface's normals, so you get the proper lighting on the spokes even though they're mapped to a flat object.
Behind these would be the brakes, axle, etc.. - which I didn't model.
The shaders are pretty easy - standard_f/v for the regular surfaces, bump_f/v for the angled ones. I haven't tried with reflections but I expect they would work.
I hope this makes sense, and is useful to someone.
(and then there was more)
To produce the radial gradient, there are 4 compass colours - +red, +green, -red, -green.
Since the bumpmap is expected to be normalized, step 1 is to decide the angle you want (eg. 45 degrees). Take sin/cosine of that angle -> .707/.707. Assuming 0 degrees to be normal (and 90 at a right angle to that), blue is cos and red/green are sin.
rgb triplets for the 4 points are:
+red: (128+128*sin(a), 128, 128+128*cos(a)) = (219, 128, 219)
+green: (128, 128+128*sin(a), 128+128*cos(a)) = (128, 219, 219)
-red: (128-128*sin(a), 128, 128+128*cos(a)) = (36, 128, 219)
-green: (128, 128-128*sin(a), 128+128*cos(a)) = (128, 36, 219)
Once you have these you can just make a gradient with them in that order, counterclockwise. For example, in the image above, I have +red pointing down, then +green pointing right, -red pointing up, -green pointing left.
If you switch them (clockwise) you end up with conflicting directions, and ingame the specular will rotate twice as fast as the wheel, instead of staying still. Easy to fix though, just mirror the texture (if your object is mapped mirrored, you'd need to do this in reverse to compensate, horizontal mirror works fine).
The direction of +red determines what angle to the surface the normals take (I think it's down - clockwise, right - inward, up - counterclockwise, left - outward but I'm not sure).
It's probably possible to combine the transparency of the various spoke parts with the "flat" bumpmap colour (128, 128, 255) to produce a composite bumpmap that handles more than one surface (and would give a single reflection at any point on the wheel instead of blending them ingame) but I don't know whether that's a good idea.
I also had a question. What are the blur models (and corresponding speed to switch) called in car.ini? I couldn't find any reference to it on racer.nl.