After doing the experiment with the fake materials and writting
the controversial post the ambition of getting real materials grown on me.
For the people that doesn't know what I'm talking about when saying fake/real. In the last examples, the reflection was just a plane on top of the other texture and I was scrolling the reflection map. That's faking the reflection, there are no real calculations of what that face of the mesh needs to reflect from the texture...
I'm a bit lost on this, but it's only a matter of keep trying, testing, and getting deductions from the errors and results.
This is what I've achieved by now...
I was doing this a little bit like blindfolded, the UVmapping just gets the position of the texture from 0 to 1 for each vertice and filling the poly is easy. For doing the spherical environment mapping it was about getting the texture from 0 to 1 in relation to the normal of each face (as seen
here). After messing around with the matrix, I ended up with this:

Well, it's a good start... after trying different values in the matrix I ended up getting this:

Better, and in fact, pretty nice rendering I think. And finally I reached something that looked like what I was after:

It's really messy, it's not environment mapping in flat mode, neither in smooth mode, it's what I have at the moment, here it's how it looks in another mesh:

So, for the people that were looking for the code... I'm not going to give it this time because that would mean having to zip papervision3d sources and in that way creating a working version that will last for a week or two only, so, instead I'm going to explain a bit what I've been doing...
To get to this point, basically I modified
Face3D.as so every time a new face is created it also calculates the normal for the face (which, I don't know why pv3d still doesn't have this, because the code is really simple and short).
normal = Number3D.cross( Number3D.sub( new Number3D(v1.x,v1.y,v1.z) , new Number3D(v0.x,v0.y,v0.z) ), Number3D.sub( new Number3D(v2.x,v2.y,v2.z), new Number3D(v0.x,v0.y,v0.z) ) );
normal.normalize(); Then, on the
MaterialObject3D.as I defined the property
mapping_type which, by default equals to
"normal", I can then change it to
"environment" or
"environmentFlat".
Having done all that, I only had to go back to the render loop inside
Face3D.as and adding a Switch for each kind of mapping type.
At the moment the environment is not facing the camera, is facing a light in the scene, which means that if all this works we could simulate a better light than the flat one we have seen on away3D examples. It would be kind of Phong illumination.
However, in order to do that I've to modify the code a bit more so I end up using the normals of each vertex. Again, I'm a bit blindfolded here, but I think I'm on the right path... in a couple of days, maybe I'll have a bit more :)
#permalink