Here is my blog website.
wermos / rendera Goto Github PK
View Code? Open in Web Editor NEWA C++20 ray-tracing engine.
License: MIT License
A C++20 ray-tracing engine.
License: MIT License
Here is my blog website.
Herb Sutter, one of the C++ gods, mentions in [GoTW 20] (http://www.gotw.ca/gotw/020.htm) that hidden execution paths can pollute an otherwise sane program/executable, because the compiler has to assume that anything that can throw
, will throw
.
However, our ray tracer does not throw any exceptions, and as of now, there is no plan to incorporate them into Rendera. Hence, we can promise the compiler that all of our functions do not throw exceptions using the noexcept
keyword. This would allow us to ensure that we are keeping our promise to not throw exceptions (as the compiler will error out if we accidentally write code which can throw), and also allow the compiler to perform optimizations that it could not otherwise perform.
The task for this issue is quite simple: Go through the entire repository and mark all the functions with noexcept
. (The ones where it makes sense to do so, at least, which should be most of them.)
The material of a particular object determines the following:
We already have a generic material class. Define a virtual function scatter
in the material class.
Also, derive a class Metal from Material and implement the scatter
function.
The scatter function can take in the following:
HitInfo
object. This is implemented in this PR. This should provide all the necessary information needed.In the case of metals, the scatter
function is quite straightforward. Just obtain the reflected ray according to the laws of reflections. That will be the scattered ray.
Thus, update the scattered ray. The attenuation color in the case of metal can be any color.
Currently, we have the Phong Reflection Model implemented in our codebase.
The Lambertian model for reflection/shading is an alternative model which has a distribution of
This can be achieved by:
In all modern software projects which are worked on by a team, a unified coding style is used. The benefits of this are numerous:
a) Take a look at Clang Format. It's a tool which takes a specific code style (specified in a .clang-format
file), and applies that to the file you pass in as the argument.
b) Choose a specific style to enforce: I think the Google Code Style is really good, with some minor modifications, such as having the indent width be 4 spaces instead of 2. You can specify what our specific style looks like using these options. In particular, we want BasedOnStyle: google
, and IndentWidth
to be 4.
Any other modifications that you think are reasonable, should probably be discussed on the group with the others.
d) Run clang-format
on every file in the repository so far (excluding files in the submodules).
e) Implement a GitHub Action which will prevent PRs with incorrect formatting from being merged into the main line of work. You can use this existing Action as inspiration ;)
Currently, the RayTracer only supports sphere objects. Implement cubes into the project.
This will involve the following:
1.) Implementing a Cube class that stores the dimensions and other necessary features.
2.) Implement ray-box intersections which are necessary to render the cube onto the image.
References:
1.) Scratchapixel
2.)The RayTracer Challenge
Assignee: @KartikDhawaniya
Write some basic classes for ray tracing: camera.hpp
, material.hpp
, sphere.hpp
, etc. And get a simple image up.
Assignee: @Inferno2401
Most image viewers, especially those on Windows, don't have support for viewing .ppm
files. To view such files on Windows, usually one needs to install a massive application such as GIMP or Photoshop. To make viewing these images easier, we should switch to creating .png
and .jpg
images.
CMakeLists.txt
files as appropriate.stbi_write_png
and stbi_write_jpg
functions from stb_image_write.h
to generate PNG and JPG images.Optional:
We can look into either determining at runtime (by asking the user), or make a macro, to decide to generate PNG images, JPG images, or both.
Assignee: @Stealth2002
The task is to create a vec4
class, which will be a vector with 4 elements, with the relevant functionality (like adding, subtracting, multiplication and division by a scalar).
Use the xsimd
submodule for SIMD intrinsics to speed up the math operations, and provide reasonable constructors.
Make the vec3
class by inherting from vec4
, and supply a cross product function for the 3 dimensional vectors.
You might find this link on how you can use SIMD intrinsics for computing the cross product of two 3D vectors interesting.
Assignee: @prateekgargX
As it stands, we have some complex vector classes in the utilities/
directory. To ensure correctness, we want to write some tests and make sure that they work as expected. However, to do so, we need a testing framework, which is why we need Google Test.
vec4
and vec3
classes. The tests should go inside a tests
directory inside utilities
.CMakeLists.txt
inside utilities
should also be updated to properly build Google Test, and expose the headers to Rendera source files.Implement a little randomness in the get_ray
function in the Camera
class (basically, it should return the ray, except that the ray should be off by a little).
Modify the rendering algorithm to do multiple samples per pixel (say 50), and then combine all the samples to make the final image.
Assignee: @Inferno2401
In #14, our main goal was to get a basic render up and running. Now that we have achieved that goal, our next step is to clean up that code and give it a glow up. As such, here are some of the improvements we should make:
Material
class should probably be a struct.Rendera/Rendera/include/material.hpp
Lines 22 to 39 in 47f65c2
std::size_t
and not int
.Rendera/Rendera/include/camera.hpp
Lines 13 to 14 in 47f65c2
std::size_t
is one such well-defined unsigned type.get_int()
function.Rendera/utilities/include/color.hpp
Lines 28 to 33 in 47f65c2
color
consisting of 8-bit ints, but the int
type is 32 bits. We need to amend this by using the std::uint8_t
type. (Unsigned because the value will be in the range 0-255, inclusive).std::max
function is needed. Perhaps discussing this @Inferno2401 will help here.hit
function, we see the following:Rendera/utilities/include/intersection.hpp
Lines 26 to 33 in 47f65c2
t2
is non-negative, and outside the if clause, we should return false
. The reason a "return fast" policy is better than the existing implementation is because it minimizes the number of possible comparisons and branches in the code.Intersection
class should not have getter functions for both t1
and t2
, because if the ray doesn't hit the object at all, they will return garbage to the user. However, amending this problem is less of a priority because we are planning to remove this class entirely as a part of the refactoring being done in #24.Assignee: @KartikDhawaniya
Currently, we have all the basic tools needed to render an image. However, we want a separate scene class that will handle all of the elements involved in a particular scene. As such, implementation of the following is required:
Make a unified design for hittable objects:
a) Implement a base class for the hittable objects with a pure virtual function called hit
.
b) Make the existing Sphere
class inherit from this class, and move the ray-sphere intersection code from intersection.hpp
into the sphere
class.
Scene class:
a) Make a class with an array of hittable objects. Also implement an add_object()
function to add objects into the scene.
b) Make a struct called HitInfo
to store information relating to an intersection (a boolean is_hitting
, a pointer to the material, the point of intersection, the normal at that point, the ray itself, and the recursion depth).
c) Implement a hit_object
function which will traverse the entire hittable object array and return a HitInfo
object for a given ray, for the closest intersection from the camera.
Refactor the main
function to make it more modular:
a) The main function will be handling a lot of tasks. We can make it more modular by refactoring all of the scene creation into one function and all the rendering in another. Call these two functions from the main function.
b) Make a function called create_scene()
which will create the scene which will be ray-traced.
c) Make a function called render()
which will contain the actual rendering algorithm, and generate the image.
Assignee: @mahesh0537
Currently, we have a lot of people doing lots of different work on the ray tracer. As a result, the project is currently failing to build, and we cannot use the executable at all. There are two parts to this task:
This subtask is pretty self explanatory. Do whatever is necessary (short of removing features) to make the project build.
Obviously, one of the pre-requisites of making the project submission-ready is having it build. Apart from that, to create a nice-looking picture as our final submission, we need to generate the scene first.
The scene used as the cover image of the SoC had 487 spheres. Since we also have a Cube
class, we can have a scene filled with spheres and cubes. Here is what you should do:
Scene
object with this scene, and then pass it into the render
function (which you can assume to be written by @KartikDhawaniya).It would be good to have one PR for each sub-task.
Assignee: @mahesh0537
As it stands, our program just runs for however long it requires, and then just outputs "PNG image generated" and "JPG image generated" at the very end. This is highly undesirable because anyone who runs our program will not know if the program is even working or not, once they start the program.
stbi_write_png
and stbi_write_jpg
functions. Note that a non-zero return value indicates a success, and a zero return value indicates a failure to generate the relevant image file.Note
This is a very tricky issue to get right, because we have to make sure that the BVH Nodes are as lightweight as possible, and also make sure that the BVH construction is as fast and accurate as possible. Otherwise, for smaller scenes, the BVH construction time contributes more to the program runtime than the actual rendering algorithm runtime.
Currently, the rendering algorithm in Rendera checks if a given ray intersects with any object sequentially. This is fundamentally an
Can we do better? The answer is yes! If we partition the space inside the scene and organize it into a bounding volume hierarchy, then we can make the algorithm run in
However, like I mentioned in the note, there are many competing factors here, so the actual implementation is quite tricky: one false step and we will introduce an unnecessary slowdown.
Assignee: @prateekgargX and @mahesh0537
Currently, we don't have any explicit support for different types of lights. Our first render implicitly uses a point light, but there are some drawbacks to only supporting point lights, as discussed in The Ray Tracer Challenge (chapter 17). For some motivation for implementing these different types of lights, as well a short explanation of how they work, read that chapter.
Light
, with pure virtual functions called get_direction
, which returns the direction of the incoming light at a hit point and L
, which returns the incident radiance at a hit point.This is a slightly bigger task than the previous issues. To complete this task, you should break it up over multiple PRs. Do not send one massive PR because that makes it very difficult to review effectively. As such, a reasonable break down would be:
Light
.Assignee: @Inferno2401
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.