Texture conversion was done with texconv.(https://github.com/tvspelsfreak/texconv) Source code: (Bug fix) The features of Dreamcast bump mapping are as follows.
- Only flat shading is supported.
- Convert the light vector to tangent space and assign it to the offset color for use.
- Bump-mapped polygons change only in brightness, so overlay polygons to add color.
- Find the tangent and binormal of each vertex in local space. Please refer to the next page for details.
(http://www.opengl-tutorial.org/intermed ... l-mapping/)
- Convert the light vector to local space and find the elevation (T) and azimuth (Q) by the three inner products.
Code: Select all
T = clamp(dot(Normal, LightVector), 0, 1) * (π * 0.5)
Q = atan2(dot(Binormal, LightVector), dot(Tangent, LightVector)) + π
K1 = (1.0 - H) * 255
K2 = sin(T) * H * 255
K3 = cos(T) * H * 255
q= (Q / (2 * π)) * 255
OffsetColor = (K1 << 24) | (K2 << 16) | (K3 << 8) | q
Only flat shading is supported, so only one light vector can be received per face.
So, in this sample, the values of the three vertices are averaged and used.
In addition, cheating is required when used in Gouraud shading.
Notice that the hardware expresses the elevation angle (T) in two terms, K2 and K3. It seems that K2 determines the brightness of the plane perpendicular to the light vector, and K3 determines the brightness of the plane parallel to the light vector.
In other words, by setting K2 to a fixed value, it can be made to appear without shading. Since K3 is calculated properly, the shadow orientation of the bump map is drawn.
Use it for you!
Unfortunately, this sample sometimes inverts the bump mapping. I can't think of a good solution.
Edit:Bug fix. It was a mistake at vertex, sorry.
-Tashi