# Raytracing

This topic is 2611 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, my name is Daniel and I'm a Java developer. I would like to learn about raytracing. I want to write a raytracing program just for fun, with no third libraries dependencies and in Java, it doesn't matter performance, I just want to know concepts and how they interact each other. I love drawing and I think it is a good idea to combine both programming and drawing in raytracing.

On the other hand I'm interested in photography, so I consider to play with lights, materials, surfaces and so on, is also important to learn photography, how lights interact with objects, etc.

But I have an important problem, I'm not good in mathematics and I know it is important to develope a raytracing program.

My knowledge about mathematics is some operations with vectors such as cross product, scalar products, multiply a vector by scalar, etc, but it is difficult to me understand some equations like torus, cylinders..., and I don't remember how to solve equations.

I have the following books, I know they are excellent books but when I read them I feel demotivated because it hard to me to understand them, and it is right, I don't know too much about mathematics.

Realistic Ray Tracing - Shirley, Morley
Real-Time Rendering - Akenine, Moller
Physically Based Rendering: From Theory to Implementation - Pharr, Humphreys

I would like if someone of us can help me or give some advice, I like learning by my own but I find this field difficult.

##### Share on other sites
I think, if you are not family with all the details, it might be best to take a working project and play with it (or in your case, to port it to java).

I suggest: http://www.flipcode.com/archives/Raytracing_Topics_Techniques-Part_1_Introduction.shtml

it's a good series of articles about raytracing, starting with very basic things, easy to understand.

if you have problems with some basic math, there will be no other way than to learn it. most of those informations can be found on wikipedia and those articles are quite short, so you can use it like a reference and incrementally learn your stuff.

##### Share on other sites
I suggest you start with Devmaster's Tutorial. He explains step by step Raycasting.

1. Sending a ray and Phong light shading.
3. Refraction and Supersampling

He also offers complete code examples using windows library (without DirectX, OpenGL etc.).

##### Share on other sites
Thank you for your advice! I've read the first page, it sounds simple. I would like to know if you can help me to compile and run the program into raytracer1.zip. I unzip its content and I run:

gcc raytracer raytracer.cpp

but I got the following error:

$gcc raytracer raytracer.cpp gcc: raytracer: No such file or directory In file included from raytracer.h:9, from raytracer.cpp:6: common.h:72: error: member Raytracer::vector3 Raytracer::plane::<anonymous union>::<anonymous struct>::N' with constructor not allowed in anonymous aggregate common.h:72: error: member Raytracer::vector3 Raytracer::plane::<anonymous union>::<anonymous struct>::N' with constructor not allowed in union In file included from raytracer.h:9, from raytracer.cpp:6: common.h:83:7: warning: no newline at end of file In file included from raytracer.cpp:6: raytracer.h:57:7: warning: no newline at end of file In file included from raytracer.cpp:7: scene.h:124:7: warning: no newline at end of file raytracer.cpp: In member function Raytracer::Primitive* Raytracer::Engine::Raytrace(Raytracer::Ray&, Raytracer::Color&, int, float, float&)': raytracer.cpp:96: error: no match for 'operator*' in 'Raytracer::operator*(diff, ((const Raytracer::vector3&)((const Raytracer::vector3*)(&prim->Raytracer::Primitive::GetMaterial() ->Raytracer::Material::GetColor())))) * light->Raytracer::Primitive::GetMaterial()->Raytracer::Material::GetColor()' common.h:52: note: candidates are: Raytracer::vector3 Raytracer::operator*(const Raytracer::vector3&, float) common.h:53: note: Raytracer::vector3 Raytracer::operator*(const Raytracer::vector3&, Raytracer::vector3&) common.h:54: note: Raytracer::vector3 Raytracer::operator*(float, const Raytracer::vector3&) raytracer.cpp:177:26: warning: no newline at end of file I think, if you are not family with all the details, it might be best to take a working project and play with it (or in your case, to port it to java). I suggest: http://www.flipcode....roduction.shtml it's a good series of articles about raytracing, starting with very basic things, easy to understand. if you have problems with some basic math, there will be no other way than to learn it. most of those informations can be found on wikipedia and those articles are quite short, so you can use it like a reference and incrementally learn your stuff. #### Share this post ##### Link to post ##### Share on other sites Thank you for your advice too! It is the same tutorial that Krypt0n recommended me, as I said before, it seems simple and easy to follow. I have posted a question about how to compile and run raytracer1.zip because it show me a compile error and I guess I have to use some command options I unknow to compile .cpp with their header files. Thank you again for your time to write me. I suggest you start with Devmaster's Tutorial. He explains step by step Raycasting. 1. Sending a ray and Phong light shading. 2. Reflection and shadows 3. Refraction and Supersampling He also offers complete code examples using windows library (without DirectX, OpenGL etc.). #### Share this post ##### Link to post ##### Share on other sites  gcc raytracer.cpp -o raytracer.exe  shall create the file for you. or .elf if you're on linux #### Share this post ##### Link to post ##### Share on other sites Thank you for your advice too! It is the same tutorial that Krypt0n recommended me, as I said before, it seems simple and easy to follow. I have posted a question about how to compile and run raytracer1.zip because it show me a compile error and I guess I have to use some command options I unknow to compile .cpp with their header files. Thank you again for your time to write me. [quote name='rumpfi88' timestamp='1318946303' post='4873910'] I suggest you start with Devmaster's Tutorial. He explains step by step Raycasting. 1. Sending a ray and Phong light shading. 2. Reflection and shadows 3. Refraction and Supersampling He also offers complete code examples using windows library (without DirectX, OpenGL etc.). [/quote] Use Visual C++ (Express Edition is fine). Create an empty project and add existing files (it should be 4 headers and 4 cpp files). Then Debug or Build everything, a new window will open and you see 2 gray spheres without shadows, a small white sphere at the top and a plane below. #### Share this post ##### Link to post ##### Share on other sites Sorry, I tried it but it give me the same error: raytracer.cpp:96: error: no match for 'operator*' in 'Raytracer::operator*(diff, ((const Raytracer::vector3&)((const Raytracer::vector3*)(&prim->Raytracer::Primitive::GetMaterial() This is the complete error:$ gcc raytracer.cpp -o raytracer.exe
In file included from raytracer.h:9,
from raytracer.cpp:6:
common.h:72: error: member Raytracer::vector3 Raytracer::plane::<anonymous union>::<anonymous struct>::N' with constructor not allowed in anonymous aggregate
common.h:72: error: member Raytracer::vector3 Raytracer::plane::<anonymous union>::<anonymous struct>::N' with constructor not allowed in union
In file included from raytracer.h:9,
from raytracer.cpp:6:
common.h:83:7: warning: no newline at end of file
In file included from raytracer.cpp:6:
raytracer.h:57:7: warning: no newline at end of file
In file included from raytracer.cpp:7:
scene.h:124:7: warning: no newline at end of file
raytracer.cpp: In member function Raytracer::Primitive* Raytracer::Engine::Raytrace(Raytracer::Ray&, Raytracer::Color&, int, float, float&)':
raytracer.cpp:96: error: no match for 'operator*' in 'Raytracer::operator*(diff, ((const Raytracer::vector3&)((const Raytracer::vector3*)(&prim->Raytracer::Primitive::GetMaterial()
->Raytracer::Material::GetColor())))) * light->Raytracer::Primitive::GetMaterial()->Raytracer::Material::GetColor()'
common.h:52: note: candidates are: Raytracer::vector3 Raytracer::operator*(const Raytracer::vector3&, float)
common.h:53: note: Raytracer::vector3 Raytracer::operator*(const Raytracer::vector3&, Raytracer::vector3&)
common.h:54: note: Raytracer::vector3 Raytracer::operator*(float, const Raytracer::vector3&)
raytracer.cpp:177:26: warning: no newline at end of file

 gcc raytracer.cpp -o raytracer.exe 

shall create the file for you. or .elf if you're on linux

##### Share on other sites

[quote name='EDBarrera' timestamp='1318946562' post='4873912']
Thank you for your advice too! It is the same tutorial that Krypt0n recommended me, as I said before, it seems simple and easy to follow. I have posted a question about how to compile and run raytracer1.zip because it show me a compile error and I guess I have to use some command options I unknow to compile .cpp with their header files.

Thank you again for your time to write me.

[quote name='rumpfi88' timestamp='1318946303' post='4873910']
I suggest you start with Devmaster's Tutorial. He explains step by step Raycasting.

1. Sending a ray and Phong light shading.
3. Refraction and Supersampling

He also offers complete code examples using windows library (without DirectX, OpenGL etc.).

[/quote]

Use Visual C++ (Express Edition is fine). Create an empty project and add existing files (it should be 4 headers and 4 cpp files). Then Debug or Build everything, a new window will open and you see 2 gray spheres without shadows, a small white sphere at the top and a plane below.
[/quote]

##### Share on other sites
I tried with Visual C++ but it give the same error as compiling it via line command. Using Eclipse is more familiar for me but I got the same error too. I considered to ask this topic in General Programming forum. There I have explain a bit more.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 10
• 9
• 9
• 11
• 11
• ### Forum Statistics

• Total Topics
633687
• Total Posts
3013327
×