Simple software rasterizer in a single C++11 header file
11–20 of 23 posts
Re: Simple software rasterizer in a single C++11 header file
#12Earlier quoted context omitted.
Header libraries are easier to add to your project because there are no build scripts to figure out or cross-compiling to do or whatever. A lot of Boost is header-only, for example. GLM (OpenGL Mathematics), too, is header-only. OTOH if you end up modifying a header that's included in a whole bunch of places, woe unto you.
The reason Boost is headers only is you have to be a header to be generic. Implementations outside of headers have to friend / otherwise be not truly generic.
Re: Simple software rasterizer in a single C++11 header file
#13Earlier quoted context omitted.
Header libraries are easier to add to your project because there are no build scripts to figure out or cross-compiling to do or whatever. A lot of Boost is header-only, for example. GLM (OpenGL Mathematics), too, is header-only. OTOH if you end up modifying a header that's included in a whole bunch of places, woe unto you.
The reason Boost is headers only is you have to be a header to be generic. Implementations outside of headers have to friend / otherwise be not truly generic.
Re: Simple software rasterizer in a single C++11 header file
#14Earlier quoted context omitted.
This loops over the triangles and converts them to screen pixels. A ray tracer loops over screen pixels and checks if there are any triangles that overlap it.
More or less this. To expand a bit - rasterization converts lines or polygons to pixels via hidden line removal techniques ( http://en.wikipedia.org/wiki/Hidden_line_removal ) and/or hidden surface techniques ( http://en.wikipedia.org/wiki/Hidden_surface_determination ) while ray tracing can mean a lot of different things, where most common and basic form is Whitted's ray tracing where final image is a grid of pixels…
Re: Simple software rasterizer in a single C++11 header file
#15Earlier quoted context omitted.
More or less this. To expand a bit - rasterization converts lines or polygons to pixels via hidden line removal techniques ( http://en.wikipedia.org/wiki/Hidden_line_removal ) and/or hidden surface techniques ( http://en.wikipedia.org/wiki/Hidden_surface_determination ) while ray tracing can mean a lot of different things, where most common and basic form is Whitted's ray tracing where final image is a grid of pixels…
Thanks for the explanation. How are multiple hops in light path handled without having the computational complexity go insane?
Some popular shortcuts include:
- Cut at n hops (with n=4 or n=8 popular choices), defaulting to "ambient" light after that
- Give each material an "ambient" color, so that you don't actually need to trace every pixel back into every light source (just into e.g. spotlights)
- Solve a radiosity equation for the surface colors, and trace rays for textures/reflections.
Complete ray tracing is, indeed, insane - in fact, to get high quality pictures and avoid aliasing, most ray tracers send multiple rays through every picture and average the result.
Re: Simple software rasterizer in a single C++11 header file
#16Mine did Bresenham's algorithm for pixel fill rather than the winding approach used here.
Re: Simple software rasterizer in a single C++11 header file
#17I'm not a C++11 developer, I've done a little C++ in the past. What is the pride in putting all the code in the header file? Shouldn't the declarations be there, and the definitions be pulled out into a .cpp file? Is it somehow smaller, faster, more convenient to have it all in a header file?
Re: Simple software rasterizer in a single C++11 header file
#18I TA'd a rendering course once and wound up assigning a homework where the students implemented their own software rasterizers in CUDA. Before that homework, a lot of students didn't really understand what a rasterizer did. Afterwards, everyone got it.
Re: Simple software rasterizer in a single C++11 header file
#19I TA'd a rendering course once and wound up assigning a homework where the students implemented their own software rasterizers in CUDA. Before that homework, a lot of students didn't really understand what a rasterizer did. Afterwards, everyone got it.
Do you have links to any resources the students found handy? I'm not very familiar with anything to do with the graphics stack other than familiarity with some of the words.
Maybe start with chapter 38: http://downloads.gamedev.net/pdf/gpbb/gpbb38.pdf
Re: Simple software rasterizer in a single C++11 header file
#20Earlier quoted context omitted.
Header libraries are easier to add to your project because there are no build scripts to figure out or cross-compiling to do or whatever. A lot of Boost is header-only, for example. GLM (OpenGL Mathematics), too, is header-only. OTOH if you end up modifying a header that's included in a whole bunch of places, woe unto you.
The reason Boost is headers only is you have to be a header to be generic. Implementations outside of headers have to friend / otherwise be not truly generic.
http://stackoverflow.com/questions/495021/why-can-templates-...