Can you explain Multisampling?

Discussion in 'General 3D Technology' started by king_iron_fist, Dec 2, 2002.

  1. KimB

    Legend

    Joined:
    May 28, 2002
    Messages:
    12,902
    Likes Received:
    218
    Location:
    Seattle, WA
    Speaking of which, it still seems to me that normal maps should be able to be filtered and MIP mapped. It will likely require a little bit more processing power than just plain linear filtering, but it should be possible. Situations like you described above should almost never occur. If it did, the hardware should just choose one or the other ((1,0,0) or (-1,0,0)). It seems to me that you'd need to just filter the textures linearly, then normalize the result (given that bump mapping techniques assume normalized normals). MIP maps would be best pre-generated.

    Another way might be to do a linear interpolation in angle space (aka spherical coords) instead of cartesian. This would require quite a bit more processing, but should still be possible.
     
  2. Hyp-X

    Hyp-X Irregular
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    1,170
    Likes Received:
    5
    Slerp does that.
    Unfortunately it's quite expensive. :(
    (Altough there could be a sufficiently precise aproximation.)
     
  3. Basic

    Regular

    Joined:
    Feb 8, 2002
    Messages:
    846
    Likes Received:
    13
    Location:
    Linköping, Sweden
    Filtering and PS does not commute in the general case. They only commute with very simple shaders. So it doesn't matter if you do a renormalization of filtered normals, you'll still get wrong result.

    Classical example is an environment mapped rough bumpmapped surface, that get filtered to a perfect mirror instead of "smearing" the reflection.

    Supersampling solves it, although in a brute force way. Better texture filtering does not. (Advanced pixel shaders can also do it, but not without some effort.)
     
  4. Dio

    Dio
    Veteran

    Joined:
    Jul 1, 2002
    Messages:
    1,758
    Likes Received:
    8
    Location:
    UK
    ... but don't expect to understand much of Foley and Van Dam. I've been working in this industry the better part of ten years now and I still don't :)

    Before andypski says anything, it is probably me, not the book :D

    The Watt & Watt book is much more readable, although it's not well targetted at the PC space. Of course, Foley & Van Dam is still the computer graphics bible, and looks very good on the shelf.
     
  5. Dio

    Dio
    Veteran

    Joined:
    Jul 1, 2002
    Messages:
    1,758
    Likes Received:
    8
    Location:
    UK
    Mipmapping is an extremely non-trivial issue - probably more so than filtering.

    For certain lighting algorithms the mipmap is a valid approximation, but other than that you have to accept that the mipmapping process will smooth out your bumps (through information loss).

    For example, if you are using the conventional Phong lighting model with a high specular power, you will only get a bright specular reflection if H (the halfangle vector, the vector evenly dividing the light incident vector and the vector to the eye) is nearly exactly the same direction as N (the normal vector from the bump map). (Simple math, H.N must be very nearly 1).

    So, if a single 'mip' pixel was composed of two source angles at 90 degrees to each other, the correct result is to see two half-brightness flashes of light as the H.N crosses each of the two source angles. Unfortunately, what you get with a mipped vector is a single full-brightness flash at the halfangle of the two normals. In effect, you have flattened out your bump map.

    There's no easy solution to this problem.
     
  6. jb

    jb
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    1,636
    Likes Received:
    7
    sa,

    thanks for the info!
     
  7. Bambers

    Regular

    Joined:
    Mar 25, 2002
    Messages:
    781
    Likes Received:
    0
    Location:
    Bristol, UK
    With sufficient AF wouldn't the mipmaps only be used when the bumps were so small that they were sub pixel sized?
     
  8. Basic

    Regular

    Joined:
    Feb 8, 2002
    Messages:
    846
    Likes Received:
    13
    Location:
    Linköping, Sweden
    Mipmaping is one way to low pass filter the texture. Bilinear and trilinear is mostly reconstruction filters (going from a texture of discrete samples to a continuous image that can be sampled again at exact pixel positions). Anisotropic is a bit of both, doing low pass filtering primarily in the direction of the anisotropy.

    All of it can be called "filtering". (That's what I meant by filtering above.)

    So even if AF in some cases can reduce the use of anything but the most detailed mipmap, it will itself incorrectly smooth out bumps.
     
  9. moichi

    Newcomer

    Joined:
    Jul 22, 2002
    Messages:
    36
    Likes Received:
    0
    Location:
    Japan

    Thanks, Hype-X.


    Speaking about Multisampling,
    recently "Render to Texture" become basic more and more.
    Especially for HDRI
    But we can't render to texture with Multisampling AA.
    So I think multisampling AA will be not important in the near future.
     
  10. Ailuros

    Ailuros Epsilon plus three
    Legend Subscriber

    Joined:
    Feb 7, 2002
    Messages:
    9,420
    Likes Received:
    179
    Location:
    Chania
    Is MSAA really impossible with render to texture (via upsampling f.e.), or would it just cost too much in performance?
     
  11. Simon F

    Simon F Tea maker
    Moderator Veteran

    Joined:
    Feb 8, 2002
    Messages:
    4,560
    Likes Received:
    157
    Location:
    In the Island of Sodor, where the steam trains lie
    "better part of ten year"
    Oh I wish it were only ten years :)

    The "Aliasing and Antialiasing" chapter is quite good because, even though it contains plenty of theory (for sad gits like me), it also has lots of diagrams, pictures, and graphs to make it easy to understand what the maths is doing (also great for sad gits like me when it's early in the morning). The corresponding chapter in Watt & Watt is also quite good.

    Then get it off the shelf and on to your desk! :)
     
  12. Dio

    Dio
    Veteran

    Joined:
    Jul 1, 2002
    Messages:
    1,758
    Likes Received:
    8
    Location:
    UK
    My desk won't support the weight :)
     
  13. KimB

    Legend

    Joined:
    May 28, 2002
    Messages:
    12,902
    Likes Received:
    218
    Location:
    Seattle, WA
    Only thing is I'm not talking about API-defined filtering. I'm talking about PS-defined filtering. That means it's customized by the programmer for the specific application it's intended for. I don't see how this can go wrong.

    Yes, a properly-rendered rough surface would require supersampling, but it could all be done in the PS, which should improve performance a fair bit.

    I still see definite advantages to filtering of bump maps in specific scenarios, though. A good example would be ATI's own car demo. With sufficient internal accuracy, the rendering that used the 8-bit normal map should look just as good as the higher-precision map with just a bit of filtering.
     
  14. Basic

    Regular

    Joined:
    Feb 8, 2002
    Messages:
    846
    Likes Received:
    13
    Location:
    Linköping, Sweden
    User defined filtering in PS aren't as trivial as it might seem. Even a bilinear filter is difficult. The problem is to know how much to shift coordinates to get the texture samples. You'd need to replicate the GPUs built in mip lod selection algorithm in the PS.

    Doing supersampling in PS i possible. But with Nx supersampling, at least the whole lightning part of the shader need to be duplicated N times, one for each sample. I agree that there are other operations that work fine when relying to texture filtering. The supersampled part will be slightly slower than with usual supersampling, since you'd need to explicitly shift tex-coords, and then blend the results. The part that don't need supersampling will of course be faster. And then you get the benefit of better frame buffer compression with MSAA than SSAA. With this long shaders, the frame buffer bandwidth might not be a big limiting factor though.

    Overall, yes a fair performance improvement, although it might not be huge. (Far from the usual difference between MSAA and SSAA.)

    The real deal would of course be to implement something like what we talked about here. :) And yes, that's pure PS, no supersampling, and would work well all the way through the mipmap pyramid. What I said should be possible on R300, and what MfA linked to should be possible on NV30.


    I'm not so sure that it's easy to make ATI's car demo look just as good with a 4x8bit normal map, just by adding better filtering. What kind of filter do you have in mind?
     
  15. arjan de lumens

    Veteran

    Joined:
    Feb 10, 2002
    Messages:
    1,274
    Likes Received:
    50
    Location:
    gjethus, Norway
    Hmm .. supersampling in the pixel shader sounds a bit cumbersome, but not impossible. You could, for each datum (gouraud color, texture coordinate set) that you wish to supersample, use the derivative instructions (DDX, DDY) to compute the offsets you need to add to the datum to sample it at a given sample grid point, and repeat this procedure (and all subsequent calculations) for each sample grid point. This should be moderately slower (about 3 to 10 instructions per sample point) than hardwired supersampling, and has a small problem with what happens at polygon edges - since the pixel shader has no way of knowing which sample points are inside and outside the polygon, you don't get any edge AA with this method (can be partially fixed with multisampling), and you risk sampling outside the polygon (giving artifacts with polygons viewed from sharp angles).

    Manual texture filtering in a pixel shader program sounds *very* slow - I seem to remember a figure of about 10-12 instructions for just bilinear interpolation. For trilinear, you can multiply this figure by 2 and add instructions for mipmap level computation, which will get you something like 30-40 instructions.
     
  16. psurge

    Regular

    Joined:
    Feb 6, 2002
    Messages:
    939
    Likes Received:
    35
    Location:
    LA, California
    Hyp-X :

    what if the values stored in the normal map were quaternions?

    OTOH I can't remember what is required to convert back to a Euclidian vector, but I thought it was just a matrix multiply...

    Serge
     
  17. KimB

    Legend

    Joined:
    May 28, 2002
    Messages:
    12,902
    Likes Received:
    218
    Location:
    Seattle, WA
    Which is where two things come in:

    1. This could show quite well how modern Pixel Shaders need to be improved. User-defined filtering is only natural for complex shaders.

    2. Higher-level languages should be able to help out significantly if the hardware is general enough for this sort of thing.

    This is just an optimization issue. We're really not to where this sort of thing is viable anyway, but hopefully next-gen hardware will improve added routines for optimizing PS filtering.

    I was thinking of just using an angle-based filtering method, essentially duplicating bilinear filtering in every form, except for computing the final weighted average in angle space. Obviously this won't provide the exact same results, but the results should be very similar. This should work almost perfectly here since we're not talking about a rough surface, just a smoothly-curved and very shiny surface, though I could imagine a couple of spots where it would look a bit different than what the higher-res bump map displays.

    And obviously you would absolutely need higher internal precision than is available in the 8-bit per value normal map to get the proper result.
     
  18. KimB

    Legend

    Joined:
    May 28, 2002
    Messages:
    12,902
    Likes Received:
    218
    Location:
    Seattle, WA
    Oh, thanks, that would be cool. Finally took a look.

    While I didn't do much more than a very quick glance, I got the impression that the idea was to encode "blurriness" data into the bump map's MIP maps, as well as doing texture filtering that takes the amount of "blurriness" that should be there into account? If I'm reading it right, it sounds like an excellent idea, particularly since you only need two values to fully-define a normal map, there's lots of space left to use for other things.
     
  19. OpenGL guy

    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    2,357
    Likes Received:
    28
    You've lost me here: What does internal precision have to do with the input precision?
     
  20. KimB

    Legend

    Joined:
    May 28, 2002
    Messages:
    12,902
    Likes Received:
    218
    Location:
    Seattle, WA
    My basic idea was that the "bands" in the ATI car demo were due to lack of normal map precision. If internal precision is higher, and the pixel shaders do some sort of filtering on the normal map, then those bands should be gone.
     
Loading...

Share This Page

  • About Us

    Beyond3D has been around for over a decade and prides itself on being the best place on the web for in-depth, technically-driven discussion and analysis of 3D graphics hardware. If you love pixels and transistors, you've come to the right place!

    Beyond3D is proudly published by GPU Tools Ltd.
Loading...