Working old software is underappreciated A decision all programmers have faced is whether or not to replace old working software. There are usually good reasons to replace but especially extensibility. Old code is brittle and often contains parts nobody understands. Sometimes it contains inefficiencies for modern hardware and you wouldn’t design it that way now. My experience is that for most…
I got three Philips Hue bulbs and a Philips Hue Bridge (basically a hub you need to attach to your router) and tried various Python interfaces to control them. I found one I really like and here is a hello world: (Yes, you could in theory run that program and control my bridge, but part of the Philips security is you need to be on the same network as the bridge) Each bulb is set using HSB system…
Part 1 of 3 Part 2 of 3 In the previous two posts I discussed why one might want direct lighting as a separate computation. But what goes in that function? If we are just sampling a single light, then we need to bite the bullet and do a Monte Carlo integration with actual probability density functions. These functions can either be defined over the area of the light, or the angles the light is…
Part 1 of 3 Part 3 of 3 In my last post, I talked about using shadow rays to sample a light source directly. Here is our old lovely but noisy path tracer: vec3 ray_color(ray r) if (r hits an object) r = ray(hitpoint, generate a scattered direction from the surface) return emitted(hitpoint) + reflectance*ray_color(r) else return background_color(r) This works great provided the light emitting…
Part 2 of 3 Part 3 of 3 In Ray Tracing in One Weekend , we took a very brute force and we hope intuitive approach that didn't use "shadow rays", or as some on the whipper-snappers say "next event estimation". Instead we scattered rays and they got "direct light" (light that is emitted by a radiant object, hits one surface, and is scattered to the camera) implicitly by having a ray randomly scatter…
I am no expert on "uber shaders", but I am a fan. These did not make much sense to me until recently. First let's unpack the term a little bit. The term "shader" in graphics has become almost meaningless. To a first approximation it means "function". So a "geometry shader" is a function that modifies geometry. A "pixel shader" is a function that works on pixels. In context those terms might mean…
In the writing of the new edition of Marschner's and my graphics text , we tried to add more "basics" on light and material interaction (I don't mean BRDF stuff-- I mean more dielectrics) and more on brute force simulation of light transport. In the "how would you maximally brute force a ray tracer) we wrote this: Basically, it's just a path tracer run with *only* smooth dielectrics and Beer's…
I just spent this week learning to program with OpenGL in Python using the fabulous PyOpenGL . I was barely able to do it. I have written a whole textbook on computer graphics and it derives the OpenGL matrix stack and the viewing model conceptually. The OpenGL graphics pipeline model, if I recall accurately, I was also barely able to learn! I think there is a zero percent chance I could learn the…
Almost everybody has trouble with getting refraction right in a ray tracer. I have a previous blog post on debugging refraction direction if you support boxes . But usually your first ray tracers just supports spheres and when the picture just looks wrong and/or is black, what do you do? So if you are more disciplined than I usually am, write a visualization tool that shows you in 3D the rays…
Most papers are bad and almost unintelligible. Most of my papers are bad and almost unintelligible. The ubiquity of this is evidence that writing good papers must be hard. So what am I to do about this if I suck at writing? This is not false modesty; I do suck at writing. But I am an engineer, so there must be a way to apply KISS here. KISS works. This blog post describes my current methodology to…
I am tutoring an undergrad non-CS person on Python and we tried to graph some online data. This turned out to be pretty painful to get to work just because of versioning and encodings and my own lack of Python experience. But in the end it was super-smooth code because Python packages rule. Here it is. The loop over counter is super kludgy. If you use this, improve that ;) import csv import urllib…
Here is a paper at EGSR being presented tomorrow at the time of this writing. It deals with sampling lights. The paper is pretty daunting because it has some curve fitting which always looks complicated and it works on manifolds so there are Jacobians running around. But the basic ideas are less scary than the algebra implies and is clean in code. I will cover a key part of it in a simple case. If…
Here is a setup to help debugging refraction using a sphere and a particular ray. I have do track single rays like this every time I implement refraction. Here is the setup: So let's put a sphere of radius 1 the with center (0,0,0). Now all of the action is in XY so I will leave off the Zs. First, what is A ? If it is to hit where the surface of the sphere is at 45 degrees, it has to have y…
If you look at a renderer you will probably see some references to "Schlick" and "Fresnel" and see some 5th order polynomial equations. This is all about smooth metals and "dielectrics". You will notice that the reflectivity of smooth surfaces vary with angle. This is especially easy to see on water: Note how the reflectivity increases as the angle of the viewer increases as the incident angle of…
Hi Pete, I have some nits with your blog post, in particular two points: 1) ALAN: I found it ironic that you wrote this while you are currently learning something new (neural networks...) while I agree you want to balance learning new things with getting stuff done, I think it’s important to always learn new things. 2) good at one thing vs. multiple. This one struck a chord with me, I think I’m…
In a previous post I outlined why programmers should strive to be good at one thing rather than everything. In this post I discuss how to be an asset to an organization when you are not a good programmer. First, for the record: I am a poor programmer. Ask anyone who has worked on group projects with me. But the key compensation is I am aware I am a poor programmer. I do not try to do anything…
I have always wanted a "fishtank VR" fake window that is bright enough to light a room. Everytime a new brighter screen comes out I want to know whether it is bright enough. Apple just announced a boss 6K screen . But what caught my eye was this: "...and can maintain 1,000 nits of full-screen brightness indefinitely." That is very bright compared to most screens (though not all-- the SIM2 sells…
I am no expert in making BVHs fast so just use this blog post as a starting point. But there are some things you can try if you want to speed things up. All of them involve tradeoffs so test them rather than assume they are faster! 1. Store the inverse ray direction with the ray. The most popular ray-bounding box hit test assumes this (used in both the intel and nvidia ray tracers as far as I…
In a physically-based renderer, your RGB values are not confined to [0,1] and your need to deal with that somehow. The simplest thing is to clamp them to zero to one. In my own C++ code: inline vec3 vec3::clamp() { if (e[0] < real(0)) e[0] = 0; if (e[1] < real(0)) e[1] = 0; if (e[2] < real(0)) e[2] = 0; if (e[0] > real(1)) e[0] = 1; if (e[1] > real(1)) e[1] = 1; if (e[2] > real(1)) e[2] = 1;…
NOTE: this post has three basic problems. It assumes property 1 and 2 are true, and there is a missing piece at the end that keeps us from showing anything :) This post results from a bunch of conversations with Dave Hart and the twitter hive brain. There are several ways to generate a random Lambertian direction from a point with surface normal N . One way is inspired by a cool paper by Sbert and…
Suppose you have a physically based renderer with area lights. Along comes a model with point and directional lights. Perhaps the easiest way to deal with them is convert them to a very small spherical light source. But how do you do that in a way that gets the color right? IF you have things set up so they tend to be tone mapped (a potential big no in physically-based renderer), meaning that a…
Most "ray tracers" these days are what we used to call "path tracers" or "Monte Carlo ray tracers". Because they all have about the same core architecture, this short hand is taking over. These ray tracers have variants but a big one is whether the ray tracing is: Batch : run your ray tracer in the background until done (e.g., movie renderers) Realtime : run what you can in 30ms or some other…
I need to stick a " ideal thin lens " in my ray tracer. Rather than a real lens with some material, coating, and shape, it's an idealized version like we get in Physics1. The thin lens has some basic properties that have some redundancy but they are the ones I remember and deploy when needed: a ray through the lens center is not bent all rays through a point that then pass through the lens…
For some tests you want the set of "all" rays that hit a box. If you want to stratify this is somewhat involved (and I don't know that I have done it nor seen it). Chris Wyman and I did a jcgt paper on doing this stratified in a square in 2D . But often stratification isn't needed. When in doubt I never do it-- the software is always easier to deal with un-stratified, and as soon as dimension gets…
I saw a neat tweet on how the estimate the Egyptians used for PI. This is all my speculation, and maybe a math history buff can enlighten me, but the D^2 dependence they should discover pretty naturally. Including the constant before squaring is, I would argue, just as natural as having it outside the parentheses, so let's go with that for now. So was there a nearby better fraction? How well did…