Raytracer | CPU Raytracer algorithm with shadows reflections | Graphics library

 by   mtrebi C++ Version: Current License: MIT

kandi X-RAY | Raytracer Summary

kandi X-RAY | Raytracer Summary

Raytracer is a C++ library typically used in User Interface, Graphics, WebGL applications. Raytracer has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

The goal of this project was to become familiar with C++ and graphics stuff while having fun. It was a really amazing project and I encourage everyone to do it if you like graphics. My raytracer is a backwards raytracer. Is quite basic and simple and includes the following features:.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              Raytracer has a low active ecosystem.
              It has 48 star(s) with 6 fork(s). There are 4 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              Raytracer has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of Raytracer is current.

            kandi-Quality Quality

              Raytracer has no bugs reported.

            kandi-Security Security

              Raytracer has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              Raytracer is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              Raytracer releases are not available. You will need to build from source code and install.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Raytracer
            Get all kandi verified functions for this library.

            Raytracer Key Features

            No Key Features are available at this moment for Raytracer.

            Raytracer Examples and Code Snippets

            No Code Snippets are available at this moment for Raytracer.

            Community Discussions

            QUESTION

            Copy a VkImage after TraceRaysKHR to CPU
            Asked 2021-Jun-06 at 09:08

            Copying a VkImage that is being used to render to an offscreen framebuffer gives a black image.

            When using a rasterizer the rendered image is non-empty but as soon as I switch to ray tracing the output image is empty:

            ...

            ANSWER

            Answered 2021-Jun-06 at 09:08

            Resolved by now: When submitting the command buffer to the queue it would require an additional vkQueueWaitIdle(m_queue) since ray tracing finishes with a certain latency

            Source https://stackoverflow.com/questions/67765292

            QUESTION

            fasm x64 windows gdi programming struggles - call to stretchdibits not painting screen as expected
            Asked 2021-Jun-02 at 00:38

            I have a simple fasm program, in this program I get some zeroed memory from windows through VirtualAlloc. I then have a procedure where I simply set up the parameters and make a call to StretchDIBits passing a pointer to the empty memory buffer. I therefore expect the screen should be drawn black. This however is not the case, and I can't for the life of me figure out why.

            Below is the code.

            ...

            ANSWER

            Answered 2021-May-31 at 06:32

            I'm sorry I don't know much about fasm, I tried to reproduce the problem through C++:

            Source https://stackoverflow.com/questions/67766028

            QUESTION

            What is the difference between ray tracing, ray casting, ray marching and path tracing?
            Asked 2021-May-02 at 08:31

            As far as I know, all the techniques mentioned in the title are rendering algorithms that seem quite similar. All ray based techniques seem to revolve about casting rays through each pixel of an image which are supposed to represent rays of real light. This allows to render very realistic images.

            As a matter of fact I am making a simple program that renders such images myself based on Raytracing in one Weekend.

            Now the thing is that I wanted to somehow name this program. I used the term “ray tracer” as this is the one used in the book.

            I have heard a lot of different terms however and I would be interested to know what exactly is the difference between ray tracing, ray matching, ray casting, path tracing and potentially any other common ray-related algorithms. I was able to find some comparisons of these techniques online, but they all compared only two of these and some definitions overlapped, so I wanted to ask this question about all four techniques.

            ...

            ANSWER

            Answered 2021-May-02 at 08:31

            My understanding of this is:

            1. ray cast

              is using raster image to hold the scene and usually stop on first hit (no reflections and ray splitting) and does not necessarily cast ray on per pixel basis (usually per row or column of screen). The 3D version of this is called Voxel space ray cast however the map is not voxel space instead 2 raster images RGB,Height are used.

              For more info see:

            2. (back) ray trace

              This usually follows physical properties of light so ray split in reflected and refracted and we stop usually after some number of hits. The scene is represented either with BR meshes or with Analytical equations or both.

              for more info see:

              the back means we cast the rays from camera to scene (on per pixel basis) instead of from light source to everywhere ... to speed up the process a lot at the cost of wrong lighting (but that can be remedied with additional methods on top of this)...

            The other therms I am not so sure as I do not use those techniques (at least knowingly):

            1. path tracing

              is optimization technique to avoid recursive ray split in ray trace using Monte Carlo (stochastic) approach. So it really does not split the ray but chose randomly between the 2 options (similarly how photons behave in real world) and more rendered frames are then blended together.

            2. ray marching

              is optimization technique to speed up ray trace by using SDF (signed distance function) to determine safe advance along the ray so it does not hit anything. But it is confined only to analytical scene.

            Source https://stackoverflow.com/questions/67347177

            QUESTION

            Transparent/noisy spheres when using simple diffuse calculations
            Asked 2021-Feb-13 at 07:35

            I've been trying to write a raytracer but I came across a problem when trying to implement simple diffuse calculations (trying to replicate the first ones from Ray Tracing in One Weekend but without a guide)

            Here's the relevant code:

            Intersection/diffuse calculations:

            ...

            ANSWER

            Answered 2021-Feb-10 at 19:19

            Too lazy to debug your code however the screenshot and just a quick look at source hints accuracy problems. So try to use 64bit doubles instead of 32 bit floats...

            Intersection between ray and ellipsoid/sphere tend to be noisy on just floats... once refraction and reflection is added on top of that the noise multiplies ...

            Also sometimes helps using relative coordinates instead of absolute ones (that can make a huge impact even on floats). For more info see:

            Source https://stackoverflow.com/questions/66136360

            QUESTION

            Multi threading Raytracer
            Asked 2021-Jan-27 at 02:18

            I am making a raytracer, im trying to use pthread to divide the rendering. i noticed that isnt helping with the speed because the function pthread_join is to slow, if i use a loop to make the 'await' is way faster and works almost every time fine. But i cant use that because the time of rendering changes with the scene. Is there a way to check if a thread is finished, on a more efficient way. This is the code. `

            ...

            ANSWER

            Answered 2021-Jan-26 at 22:32

            You have a concurrency problem here in your thread function:

            Source https://stackoverflow.com/questions/65909659

            QUESTION

            GLFW (opengl) window closes when hovering mouse over the white window top handle
            Asked 2021-Jan-16 at 10:06

            Whenever I am rendering a window for a test raytracer in opengl with the GLFW library for C++ , the window works fine up to a point where if I just hover , not outside of the window , but over its white top handle , whether it is to move the window or minimize it , the window and the whole program just crashes with no error output , even tho I am not using any try-catch block or any noexcept keyword inside the whole program , and I'm using std::shared_ptr for pointer management.

            Here's the main function (variables written in caps that aren't from glfw or opengl are defined in another file , but not initialized):

            ...

            ANSWER

            Answered 2021-Jan-16 at 10:01

            I think I sort of tracked down what the problem was, thanks to Retired Ninja in the comment section. I reduced the code to just a few lines, forgetting about the mesh system and all that stuff. Apparently, when I grab the window, the main thread seems to sleep until I am done moving it, and in the ray-trace algorithm I am instantiating new threads, so when the main one sleeps, most of the times it doesn't await (aka "join()") for them, and because I am passing pointers to those threads, those seem to fill up the memory and crash. I have added a system to also sleep the working threads while the main one is doing so and it works like a charm!. Now I gotta see how to do it in cuda XD. Nevertheless , thank you all!

            Source https://stackoverflow.com/questions/65706704

            QUESTION

            Intesection problem with Möller-Trumbore algorithm on 1 dimension of the triangle
            Asked 2020-Dec-30 at 18:44

            I am currently working on a raytracer project and I just found out a issue with the triangle intersections.

            Sometimes, and I don't understand when and why, some of the pixels of the triangle don't appear on the screen. Instead I can see the object right behind it. It only occurs on one dimension of the triangle and it depends on the camera and the triangle postions (e.g. picture below).

            Triangle with pixels missing

            I am using Möller-Trumbore algorithm to compute every intersection. Here's my implementation :

            ...

            ANSWER

            Answered 2020-Dec-30 at 18:44

            Take a look at Watertight Ray/Triangle Intersection. I would much appropriate if you could provide a minimal example where a ray should hit the triangle, but misses it. I had this a long time ago with the Cornel Box - inside the box there were some "black" pixels because on edges none of the triangles has been hit. It's a common problem stemming from floating-point imprecision.

            Source https://stackoverflow.com/questions/65506477

            QUESTION

            Problem generating raytracing world due to lifetime errors
            Asked 2020-Dec-24 at 17:47

            I'm stuck with how I should best make a world in Rust (it's for a raytracer). I've tried to make a small example here.

            See playground here. I get lots of different lifetimes errors so maybe it's easier for you to just look at the code.

            ...

            ANSWER

            Answered 2020-Dec-24 at 17:46

            Rc is slightly less efficient than bare references, but they are a lot easier to work with.

            Source https://stackoverflow.com/questions/64760544

            QUESTION

            Trouble with linking in Makefile
            Asked 2020-Dec-17 at 23:28

            If I try and compile the makefile in this plea for help, the terminal gives me the following for all my object files:

            ...

            ANSWER

            Answered 2020-Dec-17 at 22:43

            QUESTION

            WebGL Reading pixels properly from offscreen canvas
            Asked 2020-Oct-27 at 12:37

            I know there are a lot of resources on this, but none of them have worked for me.
            Some are: webgl readpixels is always returning 0,0,0,0,
            and this one: https://stackoverflow.com/questions/44869599/readpixels-from-webgl-canvas\ as well as this one: Read pixels from a WebGL texture
            but none of them have been either helpful or successful.

            The goal: Render an offscreen canvas with a WebGL shader, then use that as a texture in a separate WebGL shader.

            Notes:

            • For these WebGL shaders, I'm using a generic vertex shader used for pixel shaders, specifically, a raytracer/raymarcher. This is: attribute vec2 a_position; void main() { gl_Position = vec4(a_position.xy, 0.0, 1.0); }. This vertex shader is inputted two triangles that cover the screen, so basically the fragment shader is doing all the work.

            Problem: In order to get the image data off of the offscreen canvas, I've tried these methods:

            1. The WebGL gl.readPixels function
            ...

            ANSWER

            Answered 2020-Oct-26 at 20:32

            For some reason gl.readPixels works better with a Uint8Array.

            Source https://stackoverflow.com/questions/64543523

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install Raytracer

            This project has been developed using Netbeans and Linux but it should work on Windows, MAC OS and Linux. It can be easily build using CMake and different generators. The following code can be used to generate the VS 2017 project files:. Then, from VS you can edit and execute the project. Make sure that main project is set up as the startup project.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/mtrebi/Raytracer.git

          • CLI

            gh repo clone mtrebi/Raytracer

          • sshUrl

            git@github.com:mtrebi/Raytracer.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link