Author Topic: Perspective correct texture mapping problems...  (Read 11195 times)

0 Members and 1 Guest are viewing this topic.

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: Perspective correct texture mapping problems...
« Reply #20 on: March 04, 2010 »
Are you sure that this
Code: [Select]
for y as integer = y1performs the same rounding as you imply here:
Code: [Select]
1 - (ceil(inval) - inval)?
"sub_pix" won't work for "ceil(i)=i", eg. i= 5.0.
Challenge Trophies Won:

Offline Dr_D

  • Atari ST
  • ***
  • Posts: 151
  • Karma: 29
    • View Profile
Re: Perspective correct texture mapping problems...
« Reply #21 on: March 04, 2010 »
Yeah, that rounding would be different since fb's integer rounding by default only scales up when it's >= .5. I've modified that bit to use the ceil function, making it consistent across all variables. I've also used ceil for converting the y loops to integer, but it's still acting weird. I have to find where that dn calculation is drifting to infinity... I'm sure that's it, it so close now. :crutches:
The Dr. is INsane!!!

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Perspective correct texture mapping problems...
« Reply #22 on: March 05, 2010 »
Quote
fb's integer rounding by default only scales up when it's >= .5
No,
5.5 will round up to 6
4.5 will round down to 4

Jim
Challenge Trophies Won:

Offline Dr_D

  • Atari ST
  • ***
  • Posts: 151
  • Karma: 29
    • View Profile
Re: Perspective correct texture mapping problems...
« Reply #23 on: March 05, 2010 »
Damn, I never noticed that.. I guess that's what Stonemonkey mentioned. It makes sense now. :p
The Dr. is INsane!!!

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Perspective correct texture mapping problems...
« Reply #24 on: March 20, 2010 »
Truncating all your x,y floats towards 0 when rendering is enough to ensure you never get cracking, though Stonemonkey is bang on to say that that's not perfect - it's very good though.  There's no need to perspective correct your r,g,b imho, there's enough error in the fact your using Gouraud and the RGB colour-space to make it irrelevant, just perspective correct the u,v, which is really important.

Jim

I'm of a slightly different opinion with regards to perspective correct rgb/shading, if it's on a textured surface then it's not really noticable but if the surface is a single colour then it can be. As you already have 1/(1/z) to get u and v then it's only an extra mul for each extra component in the inner loop.

For the first time in a while I've been looking at some code, as usual this is some cubes. With perspective correct shading and more accurate normal calculation than just averaging. Even though it's not textured I think the visible banding in the shading is due to the bi linear filtering and the shading calcs being combined. The bend in the shading is still a little noticable at some extreme angles but not noo bad.

L/R mouse buttons turn, both together move forward.