Bumpmapping problems
Posted: Sat Sep 20, 2008 1:16 pm
I'm still trying to get some bump mapping code working on the GameCube, but unfortunately my work and other things leave me no free time at the moment.
Here is what I've got so far: http://bin.mypage.sk/FILES/bumpmap_demo.zip
The menu is operated from the digital pad:
mode 0: emboss bump mapping. That was easiest to get to work, and should work fine
mode 1+2: ST environment mapped bump mapping, normals are in tangent space. This is causing most problems.
mode 3: XYZ environment mapped bump mapping, normals are in object space. Should work, though I have to set up the indirect tex matrix to rotate normals into light space.
mode 1-3 should use a light probe calculated in a previous pass. For the moment I'm cheating and use a fixed light probe.
If you hold the left shoulder button you can move the camera with the analog sticks, if you hold the right shoulder button you can move the light. (Though the light only makes a difference for the emboss bump mapping at the moment.)
My problems:
- Some state doesn't seem to be correctly updated: After displaying mode 0 you have to go into mode 3 first to get the tangent space correctly set up. Is that something I'm doing wrong? From the documentation I have to disable textures on the tevs that I'm only using to transfer texcoords into the indirect tev unit, but I'm not sure if gx.c updates the registers in that case.
- For the ST bumpmapping to work you need to rotate the tangent space into light space. But the texture matrix doesn't seem to have any effect. Any ideas what I could be doing wrong?
- From the patent I assumed the inputs for the indirect tex unit should be colours R,G and B, though I find red is not available and you get values from "A" instead. Is that what others find as well? That means you're forced to store object-space bumpmap as RGBA, doesn't it?
P.S.: When the patents speak of a "light map", I'd use suggest to use "light probe": Under a light map I understand a map that stores incoming light over a surface, while a light probe would store incoming light at a point.
Here is what I've got so far: http://bin.mypage.sk/FILES/bumpmap_demo.zip
The menu is operated from the digital pad:
mode 0: emboss bump mapping. That was easiest to get to work, and should work fine
mode 1+2: ST environment mapped bump mapping, normals are in tangent space. This is causing most problems.
mode 3: XYZ environment mapped bump mapping, normals are in object space. Should work, though I have to set up the indirect tex matrix to rotate normals into light space.
mode 1-3 should use a light probe calculated in a previous pass. For the moment I'm cheating and use a fixed light probe.
If you hold the left shoulder button you can move the camera with the analog sticks, if you hold the right shoulder button you can move the light. (Though the light only makes a difference for the emboss bump mapping at the moment.)
My problems:
- Some state doesn't seem to be correctly updated: After displaying mode 0 you have to go into mode 3 first to get the tangent space correctly set up. Is that something I'm doing wrong? From the documentation I have to disable textures on the tevs that I'm only using to transfer texcoords into the indirect tev unit, but I'm not sure if gx.c updates the registers in that case.
- For the ST bumpmapping to work you need to rotate the tangent space into light space. But the texture matrix doesn't seem to have any effect. Any ideas what I could be doing wrong?
- From the patent I assumed the inputs for the indirect tex unit should be colours R,G and B, though I find red is not available and you get values from "A" instead. Is that what others find as well? That means you're forced to store object-space bumpmap as RGBA, doesn't it?
P.S.: When the patents speak of a "light map", I'd use suggest to use "light probe": Under a light map I understand a map that stores incoming light over a surface, while a light probe would store incoming light at a point.