pbrt-v3 icon indicating copy to clipboard operation
pbrt-v3 copied to clipboard

Ray intersection for a hyperboloid of one sheet

Open mishurov opened this issue 7 years ago • 2 comments

Your algorithm doesn't work correctly for hyperboloids. As I can understand, it's because you don't check the second solution for the quadric equation.

To reproduce the issue, you can render in RenderMan the whole teapot or just the hyperboloid for the spout from the following file. https://github.com/mishurov/rib_lexer_parser/blob/master/samples/teapot.rib

Hyperboloid 1.2 0 0 0.4 0 5.7 360

And then you can render it in PBRT with the same settings in PBRT's format for the quadric surfaces, excluding the tori, obviously. In PBRT the spout will be rendered as a cylinder, not as a truncated cone.

This code works correctly for intersections https://github.com/daliborgaric/pixie/blob/master/src/ri/quadrics.cpp

mishurov avatar Jan 04 '18 11:01 mishurov

Hm, we do check the second quadratic solution here: https://github.com/mmp/pbrt-v3/blob/master/src/shapes/hyperboloid.cpp#L100, in the case where the first one is at t < 0, and then here: https://github.com/mmp/pbrt-v3/blob/master/src/shapes/hyperboloid.cpp#L116 if the intersection point from the first one is outside of the z range, etc.

(I'm not saying there isn't a bug, just that I don't believe that's it. :-) )

mmp avatar Mar 29 '18 19:03 mmp

I've rendered images in pbrt and 3delight and attached example files with the same hyperboloid attributes.

3delight

3delight

##RenderMan RIB
version 3.03

Display "3delight.tiff" "file" "rgb"

Format 512 512  1
ShadingRate 1
PixelFilter "sinc" 3 3
PixelSamples 3 3
Exposure 1.0 2.2

Projection "perspective" "fov" [20]
Rotate -135 1 0 0
Translate 0 -20 -20

WorldBegin
    Attribute "visibility" "int transmission" [1]

    Attribute "visibility" "transmission" "opaque"

    LightSource "distantlight" 1 "intensity" [0.55] "from" [1 1 -1.5] "to" [0 0 0]
    LightSource "ambientlight" 2 "intensity" [0.7]

    Surface "plastic"
    AttributeBegin
        Color [0.7 0.7 0.7]
        Hyperboloid 1.2 0 0 0.4 0 5.7 360
    AttributeEnd

    Surface "plastic"
    AttributeBegin 
        Color [0.2 0.2 0.2]
        Polygon "P" [-10 -10 10 10 -10 10 10 -10 -20 -10 -10 -20]
    AttributeEnd 
WorldEnd

PBRT

pbrt

LookAt 10 10 10  # eye
       .5 .5 0  # look at point
       0 0 1    # up vector
Camera "perspective" "float fov" 45

Sampler "halton" "integer pixelsamples" 128
Integrator "path"
Film "image" "string filename" "pbrt.png"
     "integer xresolution" [400] "integer yresolution" [400]

WorldBegin

# uniform blue-ish illumination from all directions
LightSource "infinite" "rgb L" [.4 .45 .5]

# approximate the sun
LightSource "distant"  "point from" [ -30 40  100 ]
   "blackbody L" [3000 1.5]

AttributeBegin
  Material "matte"
  Shape "hyperboloid"
    "point p1" [1.2 0 0]
    "point p2" [0.4 0 5.7]
    "float phimax" [360]
AttributeEnd

AttributeBegin
  Texture "checks" "spectrum" "checkerboard"
          "float uscale" [8] "float vscale" [8]
          "rgb tex1" [.1 .1 .1] "rgb tex2" [.8 .8 .8]
  Material "matte" "texture Kd" "checks"
  Translate 0 0 -1
  Shape "trianglemesh"
      "integer indices" [0 1 2 0 2 3]
      "point P" [ -20 -20 0   20 -20 0   20 20 0   -20 20 0 ]
      "float st" [ 0 0   1 0    1 1   0 1 ]
AttributeEnd

WorldEnd

mishurov avatar Apr 02 '18 18:04 mishurov