Jump to content

  • Log In with Google      Sign In   
  • Create Account


RobinsonUK

Member Since 12 Feb 2012
Offline Last Active Apr 30 2012 02:36 AM

Topics I've Started

Phong lighting and normal mapping working.

04 April 2012 - 12:58 PM

It's taken me weeks to get simple Phong lighting model up and running. Bugs tend to be well hidden if you're looking at an object placed at the origin, or the camera never moves, or the light source is pointed along a certain axis, or you're always using sampler 0, or etc. As soon as you start them all moving/changing, well, it doesn't look so hot Posted Image.

Anyway I think I finally cracked it. Compared to how long it took me to do Phong, adding normal mapping was a breeze. The only trouble was that ASSIMP doesn't bother checking for a map on the bump channel in a .3DS export, so I had to mod it to get it to add a normal map to the material description. It does magically calculate tangent and bi-normals for vertices though, so that's something going for it.

This is a major achievement for a dumbass like me, so I thought I'd share :-)... Obviously I don't have a knowledgable expert sitting next to me, so I'm assuming it's correct just by looking at it myself. I'm wondering if it looks correct to everyone else?

Phong:

http://www.youtube.com/watch?v=kfoLksz_mlE&feature=relmfu

Phong + Normal Mapping:

http://www.youtube.com/watch?v=o7Fk9RyfRxQ

SLMATH library and SSE optimisation problem.

02 March 2012 - 07:31 AM

I have a problem with the SLMATH library. Not sure if anyone uses it or has used it before? Anyway, the issue is that when I compile with SSE optimisation enabled (in VS 2010), I obviously have to provide a container that has the correct byte alignment for SSE type objects. This is OK because there's a little class in SLMATH that's an aligned vector; it aligns the vector allocation on an 8 byte boundary (i.e. I do not use std::vector<>).

Now the problem is that it appears any structure or class that contains something like slm::mat4 must also be aligned on such a boundary too, before it's put into a collection. So, for example, I used an aligned vector to create an array of slm::mat4, but if I create a class called Mesh, and Mesh contains an slm::mat4 and I want to put Mesh into a std::vector, well, I get strange memory errors whilst debugging.

So given the documentation is very sparse indeed, can anyone who's used this library tell me what, precisely, I have to do to use it with SSE optimisation? I mean I don't like the idea of having to use aligned vectors absolutely everywhere in place of std::vector just in case an slm:: component ends up being encapsulated into a class or structure somehow.

Alternatively, a fast vector/matrix/graphics math library as good as SLMATH would be great if there's on around.

Thanks for any advice you can offer.



Robin

PARTNERS