r/computergraphics • • Mar 03 '15

Some test images from a renderer I am developing...

http://imgur.com/a/FBoTS
135 Upvotes

44 comments sorted by

9

u/[deleted] Mar 03 '15

Couple questions:

How do you begin to "develop a renderer"? Like, if you handed me a billion dollars and said "go forth, and make me a renderer", I literally wouldn't know where to start.

Second, what did you find lacking in current rendering solutions that you decided to invest so much time making a new one? Why would I want to use yours when it's done?

14

u/betajippity Mar 03 '15 edited Mar 03 '15
  1. Read the PBRT book (http://www.pbrt.org/). It's basically the holy grail in the field at this point.

  2. This is being done partially for fun, partially for research. I don't know that anyone would want to use it, if it's ever really done. :)

8

u/oogaboogacaveman Mar 03 '15

I look forward to the day when I can call someone a "giant fucking nerd" and not have it be seen as an insult, because you are making a renderer for fun and it looks incredible and that makes you a giant fucking nerd and that is awesome

3

u/log_2 Mar 04 '15

It's already that day, it just depends on your tone.

1

u/oogaboogacaveman Mar 04 '15

my tone tends to be extremely sarcastic :(

-11

u/swefpelego2 Mar 03 '15 edited Mar 04 '15

You should make a game out of it. like where you have different random paths bouncing and you have to dodge them in real-time. YO DAWG!!!

-Wow bite my ass bandwagon bitches you'll see this shit at E3.

2

u/sharkweek247 Mar 04 '15

game rendering and computer rendering are two very different things.

2

u/SarahC Mar 08 '15

Give it 50 years!

-2

u/swefpelego2 Mar 04 '15

No shit shorlock.

0

u/sharkweek247 Mar 04 '15

damn you showed me.

-1

u/swefpelego2 Mar 04 '15

It was an off the cuff remark about a renderer that's going nowhere. Code is shared in concept despite working differently in games and offline renderers, I think it would be cool to play around with making a game that uses physics from path traced renderers. Sue me you wet blanket.

6

u/pfannkuchen_gesicht Mar 03 '15 edited Mar 03 '15

Not OP, but start with math and then learn a programming language you like.

Essentially all ray-tracers boil down to intersection tests. You'd want basic intersection tests for planes, triangles, quads, axis aligned bounding boxes and eventually oriented bounding boxes. These are your primitives.

You probably know from school how to find the intersection of a ray and a plane, from that you can also derive simple ways to find intersections with quads and triangles. There are better ways, but for a start and for understanding you can begin there.

The first three are for your world geometry, the last two, or rather the AABB for the most part is for accelerating the process of finding an intersection.

If you do a ray cast, you take an ordinary ray, as in math, and test for intersections with all primitives in your scenes. To speed things up and not test all the primitives, you use a spatial tree, like an Octree, Bounding Volume Hierachy(BVH) or even a Binary Space Partioning(BSP, also often used in Quake based games). In this tree you have your primitives stored in a hierachy, so that you can reduce the amount of tests you have to do. Basically each step in the hierachy has a AABB which is smaller from the previous step and which contains a certain subset of your scene primitives. First you test against the first steps AABB, so you can determine if the ray would even hit something, then you do the same down the hierachy and test the AABBs, until you find the final step where your primitives are. Then you test only these primitives.

If you hit a primitive you have now to decide what to do with that information. In a traditional ray-tracers you can now apply the shading and draw a pixel on your image plane. Usually you do another ray-casts to all light sources in the scene. If something is hit, you know there must be shadow, if not, you can now calculate the lights influence on the shading of that particular point. You can do this by using lambertian diffuse shading and phong specular shading equations, which are fairly simple and fast. Also you can do reflections by casting another ray and so on.

In path-tracing and variations of it, you do not immediately calculate the shading. What you do is you cast another ray that is reflected from the primitive you hit and then again and again, until you hit a light source. Note that for diffuse surfaces you randomize the rays direction in a hemisphere, for direct reflections you use the reflection without any random component. When you have hit a light source you can calculate the influence. Again, you'll most likely want to use lambertian shading and phong shading for that. Instead of applying it once you do it for all the intersections on the path to the light.

In the programming language you would want some library for vector maths, but there are plenty and if you want to you can also implement one yourself, but be aware that it might not be as fast as some library, because there are quite a lot of optimizations that you can do, starting with how you pack your vector components so you can read them in one cycle and use them with certain acceleration instruction sets, like SSE.

This post simplifies quite a bit, to make it a little more readable. I hope you understood what I wrote.

TL;DR: know your vector math.

Also as OP already mentioned, the PBRT Book is greatly recommended, give it a read, it's a little expensive but worth it.

EDIT: Source: I'm a computer science student and I also implement a ray-tracer as a hobby.

2

u/[deleted] Mar 04 '15

I understood most of it. Thanks for the detailed answer.

1

u/Harha Mar 04 '15

I can calculate line->primitive intersections, I understand the ideas behind path tracing and ray tracing, but when it comes to using a K-Dimensional tree or some other data structure to accelerate the finding of the intersectable primitives, my understanding ends...

Fuck. I've tried and tried but for some reason my brain can't comprehend or come up with a good way to use a data structure like that. I guess I should just read a lot of theory behind it but I'm just more of a guy who learns by experimenting himself instead of reading thousands of lines of text.

/rant

2

u/pfannkuchen_gesicht Mar 04 '15

Well, the hardest part there really is to partition your primitives. An octree is really the easiest of them all imo, but not quite memory efficient.

An octree, as you might know, is a tree that always has either no child leafs or 8(hence the name). The child leaves always have 1/8 of the volume of the father leaf.

So to build an octree, you first compute the AABB for your whole scene, so that it encapsulates all of it, without any primitive sticking out or anything. That's your octrees root. Then you look if there is a primitive that is bigger than a child leaf, if so, put it in the primitive list of that leaf. Otherwise you create your child leaves and now look which primitives are in a certain leaf, now also test as above, then either add it to the leafs primitive list or create more children leafs and repeat.

That's how it basically works for that, also based on an octree you can generate a BVH.

Now retrieving is quite easy, you just test down the tree. First the root. If you hit it, you can now get the leafs and test them. Hit one? test it's leafs. repeat until you get to your primitives and test them.

I hope it helps a little. Either, way, there are a lot of FOSS ray-tracers, you can look how they did it to understand it better. Look for example into the repository of LuxRender, they have quite a few such structures.

0

u/[deleted] Mar 03 '15

[deleted]

2

u/jrkirby Mar 03 '15

Well, you really only need to know one. But you'd have to be a skilled programmer, and most skilled programmers would already know several languages.

2

u/pfannkuchen_gesicht Mar 03 '15

well not completely true. One language is generally enough, what you really need to have some knowledge of is mathematics. Really just comes down to that. Of course you also need to know how to structure and design such software and if you want to optimize it you would want to know how your platform you build it for works, so you can e.g. store the data in such a way that the retrieval takes the shortest time possible and so on.

I for example write a traditional ray-tracer and a more modern path tracer in C++. They both build on the same principle, which is finding intersections in your scene geometry. If you get that code working well, you have a pretty good start for both types.

-4

u/[deleted] Mar 03 '15

I'd think you'd have to be pretty proficient with a modeling/lighting package ie: Maya, as well, which is no short order, either.

3

u/radarsat1 Mar 03 '15

Awesome. I guess this is some more information about it?

Edit: ps i'm getting a lot of "[Math Processing Error]" on your blog instead of equations.

2

u/betajippity Mar 03 '15

Weird, that means the LaTeX plugin I use is breaking for you. What browser/platform are you reading with?

2

u/radarsat1 Mar 03 '15

Well, I just tried Firefox and Chromium because I couldn't remember which one I was using, and it worked fine in both so... false alarm I guess ;) Sorry about that. Really nice-looking renders man.

1

u/betajippity Mar 03 '15

No worries, and thanks!

2

u/berkut Mar 03 '15

Very nice!

Was peak memory usage for ~250M tris really only 1.5GB? Was it a fully baked-down scene, or was subdivision done on-the-fly?

Assuming the former with a completely closed (so one point per triangle, which the petals couldn't be as they're edges) fully-triangulated mesh with 235M tris at 3 x float per point, I work that out to be ~2.8GB just for the points...

3

u/betajippity Mar 03 '15 edited Mar 03 '15

Oops, good catch! I accidentally a whole 0... it should say 10.5 GB. My renderer is not nearly that memory efficient. Post updated!

Well, so, I haven't posted about this yet since I'm not sure whether or not I'm even going to keep this "feature", but the memory usage for the flowers should be even higher than 10.5 GB (closer to 30 GB), but in order to fit in memory on my machine, I implemented a crazy hack for getting geometry memory usage down. I have a half-float mode for storing geometry, which loses a lot of precision but works okay for scenes like the flower vase where there's so much going on that you can't really tell if things are slightly detached or floating if you don't look closely.

2

u/berkut Mar 03 '15

cool - I was going to say... :)

Normals and UVs can both be quantised fairly easily (with very little loss in precision - as long as you don't want stupid numbers of UDIMS) to 4 bytes from 12 and 8 respectively.

I've found that quantising points just isn't worth it, at least with production-scale scenes. When everything's really close to origin (like < fabsf(16.0) ) you can get away with it, but other than that it gets messy with highly detailed models and subd/displacement.

2

u/3dmesh Mar 03 '15

I love the renderer. You should look at Blender's Cycles renderer for some additional ideas. Good luck with finishing it.

2

u/betajippity Mar 03 '15

I've been looking at Mitsuba, Cycles, PBRT, etc. for general ideas and such. I'm also lucky enough to know a few folks working on Hyperion and Renderman and whatnot, and they've all been a great help. :)

2

u/agenthex Mar 03 '15

What methods are you using for rendering? Is there anything special or unique about your algorithm?

2

u/betajippity Mar 03 '15

The renderer supports unidirectional pathtracing, Veach-style bidirectional pathtracing, progressive photon mapping, and vertex connection and merging (which is an algorithm that combines BDPT and PPM). The internal architecture of the renderer is pretty unusual, and I'm also working on a neat little extension to VCM, but both of those things I can't talk about too much yet since they are related to my thesis work.

2

u/Jedimastert Mar 03 '15

I think you won. Seriously, those are gorgeous. The only thing I found off was that the depth of field on the 1st and 3rd images look off. Like you rendered out difference depths and glued them together instead of a smooth transition, if that makes sense.

What was the render time? And what methods are you using?

3

u/betajippity Mar 03 '15

The DOF is entirely in-camera/in-renderer, so it's probably just the falloff that is making it look weird.

Render time/methods/info/etc. can all be found here: http://blog.yiningkarlli.com/

2

u/Tangled-Universe Mar 04 '15 edited Mar 04 '15

Hi Karl, I was just wondering the following...

Understandably - as it is the current 'fashion stream' in rendering research - you are further developing/improving on existing state of the art rendering solutions as (partly) provided by your colleagues.

The whole industry seems to have jumped on the raytracing bandwagon for hyper-realistic visualization of non-natural surfaces. What I really miss from a personal interest is the lack of research in rendering solutions for massively displaced surfaces, like for canyons, cliffs, rocks and all on a large scene scale. For example, Renderman has a bit of hybrid renderer which combines REYES methods with modern tracing tech, but it seems they are mostly focussing on tracing solutions lately(?).

How do you see your renderer or some of the tech used in your renderer (MIS, VCM) being applicable to REYES-style generated procedurally displaced surfaces?? To me it seems the industry abandoned research on this niche of type of surface rendering.

I'd love to see the performance and visual fidelity of this render-tech being applied to digital landscape environments!

2

u/betajippity Mar 04 '15 edited Mar 04 '15

There are a couple of reasons why research and industry have jumped to raytracing based solutions in favor of REYES (even the Renderman guys... Renderman 19's RIS mode is a 100% raytraced system). Two of the most important reasons are:

  1. Physically based shading and lighting

  2. Asymptotic efficiency

So the first point, physically based shading and lighting. Doing GI in a physically accurate and correct manner requires the ability to evaluate surface BSDFs, for which a rasterization-based approach to evaluation simply does not exist. Calculating complex area lighting and shadowing is also difficult with rasterization, since most approaches to shadow mapping area lights are really hacky and break in weird ways, while raytraced area lights and area shadows is really easy and accurate. Overall rasterization is a bit of a hack; it's a very effective hack especially for primary visibility to the camera, but once you want to start simulating the behavior or light in the real world, it makes more sense to adopt a model of rendering that maps well to how light exists in the world (well... sort of. Raytracing maps very well to the particle model of light, but doesn't take into account wave optics. But that's a whole other story).

Second point, asymptotic efficiency. The base principles behind physically based rendering have been well know and mathematically defined for basically two decades now, but were never really put into practice until the past 5 years or so because of how computationally expensive raytracing has been historically compared with REYES and other rasterization solutions. However, raytracing for direct visibility is actually asymptotically more efficient than rasterization; that is, the more complex your geometry becomes, the closer raytracing will catch up with REYES in efficiency until some point, where raytracing surpasses REYES. In industry, we are basically either at or beyond this point now. Also we just have absolute gobs of computational power these days, so suddenly raytracing is no longer implausibly or infeasible from a computational point of view. Additionally, there are entire classes of effects where rasterization simply doesn't provide any possible avenue towards a solution, such as volume rendering.

So does this mean rasterization is dead? Well, no. At the end of the day, REYES/rasterization and etc. are just approaches for finding direct visibility to the camera of whatever is in the scene, and there's no reason why these approaches can't be used to find the first bounce in a physically based rendering system, and then have raytracing take over beyond that point. Beyond primary visibility, rasterization is completely infeasible for obvious reasons.

So what about raytraced algorithms and displacement or natural scenes/geometry? Fully raytraced renderers like Vray, Arnold, Renderman 19 RIS have been able to handle displacement and landscapes and trees and stuff perfectly fine for a long time now. Raytracing absolutely massive amounts of geometry efficiently was a problem that was basically beaten to death and solved in the late 2000s by the likes of Ingo Wald and others. Just take a look at the outdoor landscapes in projects such as The Third and the Seventh (100% Vray), or the Whiskeytree Athens demo (100% Arnold). Another great example for procedurally generated displacement can be found in some of Inigo Quilez's demos, which are 100% raymarched, 100% procedural, and yet run in realtime in a web browser (mountains demo, canyon demo, volcanic demo). Another great example of heavily procedural based, heavily displaced raytraced natural environments can be found in any film made by Blue Sky Studios (Rio and Epic are especially good examples); Blue Sky's in-house renderer has been a pathtracer since day 1, all the way back in the 1990s, and Blue Sky as a studio basically models and shades using procedurals instead of polygons anywhere they possibly can up to and including primary characters.

Hope that helps!

1

u/autowikibot Mar 04 '15

Bidirectional scattering distribution function:


The definition of the BSDF (bidirectional scattering distribution function) is not well standardized. The term was probably introduced in 1980 by Bartell, Dereniak, and Wolfe. Most often it is used to name the general mathematical function which describes the way in which the light is scattered by a surface. However in practice this phenomenon is usually split into the reflected and transmitted components, which are then treated separately as BRDF (bidirectional reflectance distribution function) and BTDF (bidirectional transmittance distribution function).

====

Image i - BSDF: BRDF + BTDF


Interesting: 3D ^rendering | Computer-generated ^imagery | Computer graphics (computer ^science) | Subsurface ^scattering

Parent commenter can toggle ^NSFW or ^delete. Will also delete on comment score of -1 or less. | FAQs | ^Mods | Magic ^Words

4

u/ikonane Mar 03 '15

Looks really good!

3

u/aclave1 Mar 03 '15

Looks incredible. I think if you showed these renders to someone as if they were real, they wouldn't question it one bit.

2

u/Harha Mar 03 '15

Amazing work! I can only wish I could achieve something as big as this in the future.

2

u/[deleted] Mar 03 '15 edited Sep 27 '16

[deleted]

1

u/JimmyJamesincorp Mar 03 '15

You must be really fucking smart man. Kudos.

0

u/physixer Mar 06 '15 edited Mar 06 '15

Great work!

Could you say something about the state of OpenCL (or CUDA) vs OpenGL/GLSL, as well as GPGPU vs special hardware like TMU and ROP?

After exploring OpenGL and failing to find a straightforward way to implement path tracing in it, I've come to realize that OpenGL is pretty much a bloated and technically irrelevant (in principle) standard in the sense that it makes it way harder to do graphics programming and still doesn't let you replace the crappy fixed renderer, although I haven't looked at the latest thing, compute shaders, but even then by making itself more and more general purpose it only ends up making itself obsolete because the same thing could be done, in principle, in OpenCL or CUDA.

Do you think ROP and TMU units in a GPU are part of "fixed" aspects of OpenGL, and going forward, a better approach is that GPU vendors should provide the whole GPU as GPGPU? (TMU might still have utility in a path tracing code since texture mapping is still useful, but TMU should be exposed to OpenCL/CUDA then OpenGL would be irrelvant. So do you think ROP is "fixed" for rasterization and useless for path tracing? I actually don't know how TMU/ROPs operate)

(WebGL is yet another thing that I haven't thought of in context of all this, so my question is mainly for full blown desktop OpenGL, but feel free to comment on the situation in regards to WebGL as well.)

Thanks in advance.

0

u/[deleted] Mar 03 '15

[deleted]

3

u/betajippity Mar 03 '15

My own little hobby/research renderer. It's not one of the big-boy commercial renderers.