Assignment 3 Discussion
Misc Notes
Several people have posted some great comments on the refraction slide about alternative ways to compute Snell's Law in practice. It may help you to implement the refraction in this assignment. (Meng)
If you're using the Photoshop EXR plugin with CS2 (don't know about the other versions), don't trust what the preview shows you for very small images! It might either show a strangely blurred version with low contrast (which can totally fool you when working with the autofocus preview images) or just random noise (which cost me an evening). (MattiasBergbom)
I've placed a version of realistic.so that DOES NOT AUTOFOCUS, but does work with the modifications to scene.cpp here (KayvonFatahalian).
You have to change 2 things in the Makefile. Here is one where you only change one thing:
PBRT_DIR = ../src-1.02 PBRT_BIN_DIR = $(PBRT_DIR)/bin ARCH = $(shell uname) ifneq ($(ARCH),Darwin) DLLLIB = -ldl endif EXRINCLUDE=../OpenEXR/include EXRLIBS=-lIlmImf -lImath -lIex -lHalf -lz CXX=g++ OPT=-O2 INCLUDE=-I. -I$(PBRT_DIR)/core -I$(EXRINCLUDE) WARN=-Wall CWD=$(shell pwd) CXXFLAGS=$(OPT) $(INCLUDE) $(WARN) LIBS=$(LEXLIB) $(DLLLIB) -L$(EXRLIBDIR) $(EXRLIBS) -lm ifeq ($(ARCH), Darwin) SHARED_LDFLAGS = -flat_namespace -undefined suppress -bundle -noprebind LRT_LDFLAGS=$(OPT) -L/sw/lib #PBRTPRELINK=-Wl,-all_load INCLUDE += -I/sw/include CXX=ccache g++ EXRLIBDIR=../OpenEXR/lib-osx WARN += -Wno-long-double else SHARED_LDFLAGS = -shared LRT_LDFLAGS=-rdynamic $(OPT) EXRLIBDIR=../cs348b_extras/lib PBRTPRELINK=-Wl,--export-dynamic -Wl,-whole-archive PBRTPOSTLINK=-Wl,-no-whole-archive endif LD=$(CXX) $(OPT) CAMERAS = realistic CAMERAS_DSOS := $(CAMERAS:=.so) CORE_HEADERFILES = api.h camera.h color.h dynload.h film.h geometry.h \ kdtree.h light.h pbrt.h material.h mc.h mipmap.h octree.h \ paramset.h primitive.h reflection.h sampling.h scene.h \ shape.h texture.h timer.h tonemap.h transform.h transport.h \ volume.h CORE_HEADERS := $(addprefix ../core/, $(CORE_HEADERFILES) ) .SECONDARY: $(CAMERAS_OBJS) default: $(CAMERAS_DSOS) cp $< $(PBRT_BIN_DIR) $(CORE_LIB): $(CORE_OBJS) ar rcs $(CORE_LIB) $(CORE_OBJS) %.so: %.o @$(LD) $(SHARED_LDFLAGS) $^ -o $@ %.o: cameras/%.cpp $(CORE_HEADERS) @echo "Building Realistic Camera Plugin \"$*\"" @$(CXX) $(CXXFLAGS) -o $@ -c $< clean: rm -f *.o *.so
Q.1
Are the hw3_scene.pbrt and hw3_scene2.pbrt supposed to work without changes?
hw3_scene.pbrt pbrt version 1.020 of Apr 9 2006 at 16:12:53 Copyright (c)1998-2005 Matt Pharr and Greg Humphreys. For educational use only; commercial use expressly forbidden. Error: Scene description must be inside world block; "Texture" not allowed. Ignoring. Line 8, file hw3_scene.pbrt Error: Scene description must be inside world block; "Texture" not allowed. Ignoring. Line 9, file hw3_scene.pbrt Error: Scene description must be inside world block; "Material" not allowed. Ignoring. Line 10, file hw3_scene.pbrt Error: Scene description must be inside world block; "Shape" not allowed. Ignoring. Line 15, file hw3_scene.pbrt Error: Scene description must be inside world block; "Material" not allowed. Ignoring. Line 16, file hw3_scene.pbrt Error: Scene description must be inside world block; "Shape" not allowed. Ignoring. Line 21, file hw3_scene.pbrt Error: Scene description must be inside world block; "Texture" not allowed. Ignoring. Line 22, file hw3_scene.pbrt Error: Scene description must be inside world block; "Material" not allowed. Ignoring. Line 23, file hw3_scene.pbrt Error: Scene description must be inside world block; "Shape" not allowed. Ignoring. Line 28, file hw3_scene.pbrt Error: Scene description must be inside world block; "Texture" not allowed. Ignoring. Line 29, file hw3_scene.pbrt Error: Scene description must be inside world block; "Material" not allowed. Ignoring. Line 30, file hw3_scene.pbrt Error: Scene description must be inside world block; "Shape" not allowed. Ignoring. Line 34, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectBegin" not allowed. Ignoring. Line 34, file hw3_scene.pbrt Error: Scene description must be inside world block; "Material" not allowed. Ignoring. Line 36, file hw3_scene.pbrt Error: Scene description must be inside world block; "Shape" not allowed. Ignoring. Line 41, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectEnd" not allowed. Ignoring. Line 41, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectBegin" not allowed. Ignoring. Line 43, file hw3_scene.pbrt Error: Scene description must be inside world block; "Material" not allowed. Ignoring. Line 45, file hw3_scene.pbrt Error: Scene description must be inside world block; "Shape" not allowed. Ignoring. Line 50, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectEnd" not allowed. Ignoring. Line 50, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectBegin" not allowed. Ignoring. Line 53, file hw3_scene.pbrt Error: Scene description must be inside world block; "Material" not allowed. Ignoring. Line 55, file hw3_scene.pbrt Error: Scene description must be inside world block; "Shape" not allowed. Ignoring. Line 61, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectEnd" not allowed. Ignoring. Line 61, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectBegin" not allowed. Ignoring. Line 63, file hw3_scene.pbrt Error: Scene description must be inside world block; "Material" not allowed. Ignoring. Line 65, file hw3_scene.pbrt Error: Scene description must be inside world block; "Shape" not allowed. Ignoring. Line 71, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectEnd" not allowed. Ignoring. Line 71, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectBegin" not allowed. Ignoring. Line 73, file hw3_scene.pbrt Error: Scene description must be inside world block; "Texture" not allowed. Ignoring. Line 75, file hw3_scene.pbrt Error: Scene description must be inside world block; "Material" not allowed. Ignoring. Line 76, file hw3_scene.pbrt Error: Scene description must be inside world block; "Shape" not allowed. Ignoring. Line 81, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectEnd" not allowed. Ignoring. Line 81, file hw3_scene.pbrt Error: Scene description must be inside world block; "AttributeBegin" not allowed. Ignoring. Line 83, file hw3_scene.pbrt Error: Scene description must be inside world block; "Material" not allowed. Ignoring. Line 85, file hw3_scene.pbrt Error: Scene description must be inside world block; "Shape" not allowed. Ignoring. Line 87, file hw3_scene.pbrt Error: Scene description must be inside world block; "AttributeEnd" not allowed. Ignoring. Line 87, file hw3_scene.pbrt Error: Scene description must be inside world block; "AttributeBegin" not allowed. Ignoring. Line 89, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectInstance" not allowed. Ignoring. Line 92, file hw3_scene.pbrt Error: Scene description must be inside world block; "AttributeEnd" not allowed. Ignoring. Line 93, file hw3_scene.pbrt Error: Scene description must be inside world block; "AttributeBegin" not allowed. Ignoring. Line 95, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectInstance" not allowed. Ignoring. Line 99, file hw3_scene.pbrt Error: Scene description must be inside world block; "AttributeEnd" not allowed. Ignoring. Line 100, file hw3_scene.pbrt Error: Scene description must be inside world block; "AttributeBegin" not allowed. Ignoring. Line 102, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectInstance" not allowed. Ignoring. Line 106, file hw3_scene.pbrt Error: Scene description must be inside world block; "AttributeEnd" not allowed. Ignoring. Line 107, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectInstance" not allowed. Ignoring. Line 110, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectInstance" not allowed. Ignoring. Line 113, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectInstance" not allowed. Ignoring. Line 116, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectInstance" not allowed. Ignoring. Line 119, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectInstance" not allowed. Ignoring. Line 122, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectInstance" not allowed. Ignoring. Line 125, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectInstance" not allowed. Ignoring. Line 128, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectInstance" not allowed. Ignoring. Line 131, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectInstance" not allowed. Ignoring. Line 134, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectInstance" not allowed. Ignoring. Line 137, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectInstance" not allowed. Ignoring. Line 140, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectInstance" not allowed. Ignoring. Line 143, file hw3_scene.pbrt Error: Scene description must be inside world block; "ObjectInstance" not allowed. Ignoring. Line 146, file hw3_scene.pbrt
Q.2
Is the small angle (curvature) approximation sufficient when doing the weight computation? From what I can tell the paper just goes with a planar disc from the start, and only mentions the assumption that the disc is parallel to the film plane.
A.2
I'm not sure which angle you refer to, but for a particular ray that strikes on the film plane, the angle of the ray from the center axis is already given. (Meng)
Q.2.2
What I'm saying is that the rearmost lens element is usually quite curved, and thus the angle of incidence on it doesn't necessarily equal the angle between the ray and the film plane normal. Is the assumption that the rearmost element is a disc valid in this case, and if so why? Kolb uses the disc approximation without further explanation, which makes me fear I've missed something crucial. (MattiasBergbom)
A.2.2
The integral is computed over a disk, because the exposure is integrated over the shape of the shutter, but not the lens surface. (Meng)
Q.3
What does the axpos = 0 for the last lens in dgauss.50mm.dat signify? How can the thickness of the lens be zero?
A.3
The axpos is the distance from the current surface to the next surface. For the last one, there's no more lens elements, so the value is 0. (Meng)
Q.4
Do we calculate the focal length from the parameters in the file or can we assume it to be the values mentioned in the comments in the dat file. For eg 50mm in dgauss lens?
A.4
The data are physical lens model profiles, and all lenses have certain amount of defects. The given values are good estimate of the focal lengths, but you can't use it to directly compute ray directions without refracting through all lens elements. (Meng)
Q.5
Also, what does filmdistance mean? Is it the distance between the film and the focal point or the distance from the film to the first lens?
A.5
The distance between the film and the back lens. To be clear, the back lens I refer to is the one that is closest to the film plane.
Q.6
Do rays generated by GenerateRay have to be normalized? Also, what does lensU and lensV actually mean, given a camera with a certian set of lenses?
A.6
lensU and lensV are the sampling values in the uv coords generated by the sampler. For a set of lenses, you may sample on the back lens surface, and trace ray through the rest. (Meng)
To answer your first question, I found this on p. 256 of the text: "It is important that the camera normalize the direction of the returned ray -- many other parts of the system will depend on this behavior." (Tom)
Q.7
What ratio between generated rays and rays that pass through the system should we expect? Total internal reflection seems like a major issue in my implementation.
A.7
I'm gonna answer this one myself: the wide angle lens really drops a LOT of rays both to reflection and off-shooting due to the way it's designed. Using the thick lens approximation to extract the exit pupil would probably increase the image quality tons. (MattiasBergbom)
Q.8
When I try to run pbrt on any scene file, I get the following:
Error: Can't open plug-in "/home/myilang/workspace/pbrt/bin/realistic.so" (/home/myilang/workspace/pbrt/bin/realistic.so: undefined symbol: _ZN23SimpleStratifiedSampler5resetEv) Line 38, file hw3.telephoto.pbrt Fatal Error: Couldn't get symbol "CreateCamera" in Plugin /home/myilang/workspace/pbrt/bin/realistic.so. Line 38, file hw3.telephoto.pbrt
What can I do to get past this problem?
A.8
The mangled _ZN23SimpleStratifiedSampler5resetEv c++ symbol is just SimpleStratifiedSampler::reset(). (see man pages for c++filt in case you want to try demangling symbols in the future). I'm guessing you might have inadvertently failed to build simplesampler.cpp or you might not have the new sampling.h that designates the Sample struct CODRELL. This is required to resolve link issues between the core library and our plugin. Kayvon sent an email about this yesterday (Murad Akhter).
Check bin/ and objs/} directories, make sure simplesampler and camerasensor .so & .objs files are there. (Meng)
Q.9
There seems to be some inconsistency on the assignment page in how the AF zones are to be specified. Specifically, the sentences "These coordinates are relative to the center of the film (the numbers will fall between -1.0 and 1.0). For example, a zone spanning the entire film plane would be given by 0.0 1.0 0.0 1.0." are contradictory. Looking over the actual text files provide, it appears as though the values follow the latter convention, but could this be confirmed?
A.9
You are correct. It's 0 to 1. The assignment page has been updated. [Kayvon]
Q.10
When we check for a range of focal depths for autofocussing, is there any parameter that determines the min or max of this range or do we just make a guess and try a random range, and then keep narrowing it down?
A.10
We leave this up to you, depending on how sophisticated you want to be. How to limit the max film depth is a little unclear, since a regular camera has a physical limit on how far awar the film can be placed. You could do a number of things: (1) make min and max parameters defined in a pbrt file (2) you could compute min using the thick lens approximation (3) you could look to see if focus decreses for a certain number of steps, and then conclude you are moving away from the point of optimal focus. [Kayvon]