POV-Ray : Newsgroups : povray.general : Bug or feature? Server Time
6 Aug 2024 12:28:20 EDT (-0400)
  Bug or feature? (Message 1 to 4 of 4)  
From: Timon Christl
Subject: Bug or feature?
Date: 7 Mar 2002 14:28:46
Message: <3c87bf6e$1@news.povray.org>
Many popular 3D games use skyboxes to simulate a sky. A skybox is simply
a very large box containing the entire world, textured with appropriate
bitmaps in such a way that the edges are (nearly) invisible.

When I tried this in POV-Ray I saw that the edges to not match seamlessly.
I investigated further and found that image_map interpolation behaves wrong.

Take the following scene:

camera {
  orthographic
  location <0.5,0.5,-1>
  right <1,0,0>
  up <0,1,0>
  look_at <0.5,0.5,0>
}

plane {
  -z,0
  texture {
    pigment {
      image_map {
        png "texture.png"
#if(clock>0)
        interpolate 2
#end
      }
    }
    finish {
      ambient 1
      diffuse 0
    }
  }
}

texture.png is a 8x8 pixel image with some colors in it, nothing special.
Use a simple black/white checker pattern and put a rectangle in red in
the middle to see it more clearly.

Render this with

+itest.pov +otest.png +fn +w256 +h256 +a0.1 +ki0 +kf1 +kfi0 +kff1

and see the difference between the two images. The interpolated version
shows a shifted texture image. I think it would be correct it the
interpolation would take the middle of each texel (texture bitmap pixel)
instead of a texel's corner.

Is this a bug or a feature?

-- 
Timon Christl <chr### [at] fmiuni-passaude>


Post a reply to this message

From: Warp
Subject: Re: Bug or feature?
Date: 7 Mar 2002 14:55:07
Message: <3c87c59a@news.povray.org>
Timon Christl <chr### [at] arielfmiuni-passaude> wrote:
> and see the difference between the two images. The interpolated version
> shows a shifted texture image. I think it would be correct it the
> interpolation would take the middle of each texel (texture bitmap pixel)
> instead of a texel's corner.

> Is this a bug or a feature?

  AFAIK, feature.
  3D-cards do the same. Probably also most other renderers.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Ron Parker
Subject: Re: Bug or feature?
Date: 8 Mar 2002 15:47:01
Message: <slrna8i8q8.178.ron.parker@fwi.com>
On 7 Mar 2002 14:55:07 -0500, Warp wrote:
> Timon Christl <chr### [at] arielfmiuni-passaude> wrote:
>> and see the difference between the two images. The interpolated version
>> shows a shifted texture image. I think it would be correct it the
>> interpolation would take the middle of each texel (texture bitmap pixel)
>> instead of a texel's corner.
> 
>> Is this a bug or a feature?
> 
>   AFAIK, feature.
>   3D-cards do the same. Probably also most other renderers.

There are (or were) some bugs in interpolation.  I don't remember whether
we've gotten around to fixing them or not.

-- 
#macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z a-z)R(a
-z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F T)merge{
P(z+a)P(z-a)R(-z-z-x a)pigment{rgbf 1}hollow interior{media{emission 3-T}}}#end 
Z(-x-x.2x)camera{location z*-10rotate x*90normal{bumps.02scale.05}}


Post a reply to this message

From: Timon Christl
Subject: Re: Bug or feature?
Date: 10 Mar 2002 18:13:00
Message: <3c8be87c$1@news.povray.org>
On 8 Mar 2002 15:47:01 -0500, Ron Parker wrote
>>> and see the difference between the two images. The interpolated version
>>> shows a shifted texture image. I think it would be correct it the
>>> interpolation would take the middle of each texel (texture bitmap pixel)
>>> instead of a texel's corner.
>> 
>>> Is this a bug or a feature?
>> 
>>   AFAIK, feature.
>>   3D-cards do the same. Probably also most other renderers.
> 
> There are (or were) some bugs in interpolation.  I don't remember whether
> we've gotten around to fixing them or not.

I checked with POV 3.5 Beta 12 (Win32), it's the same behaviour.


@Warp: I disagree. I thought about it and came to the conclusion that
it is a bug. Let me explain why.

I don't know if current hardware really does this the way it's
specified in the OpenGL specs (I did not check), but at least the
specs state very clearly how to interpolate texel colors, so I
assume 3D cards will do it as specified.

The OpenGL spec says (In Section 3.8.7 of the 1.3 spec):

----
When the interpolation mode is set to GL_LINEAR (linear interpolation),
the color to be used for some texture coordinates (u,v) is determined
by these equations:

Let T[i,j] be the color of a texel at coordinates i,j.
Let floor(x) be the largest integer not greater than x, in other words,
the normal C function floor().
Let frac(x) be x-floor(x). This means that frac(x) is never negative.

i=floor(u-1/2)
j=floor(v-1/2)

a=frac(u-1/2)
b=frac(v-1/2)

t=(1-a)*(1-b)*T[i  ,j  ]
 +   a *(1-b)*T[i+1,j  ]
 +(1-a)*   b *T[i  ,j+1]
 +   a *   b *T[i+1,j+1]

t is the final color resulting from the interpolation.
----

These equations have the following properties:

i) For the center of a texel (where frac(u)=frac(v)=0.5) the
final color is the texel's color, and nothing else.

ii) For the point where four texels meet (where frac(u)=frac(v)=0) the
final color is the sum of the four texel's colors, weighted with 0.25.

In POV-Ray this is not true. The mapping is shifted by half a texel in
u and v.

-- 
Timon Christl <chr### [at] fmiuni-passaude>


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.