Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Original Picture #13

Closed
rudiana587 opened this issue Jun 8, 2021 · 2 comments
Closed

Original Picture #13

rudiana587 opened this issue Jun 8, 2021 · 2 comments

Comments

@rudiana587
Copy link

Hello,
I'm very interesting with your project, so maybe you can help me how to see the picture before rendered, maybe you can explain it to add some code to see the image before rendered and then the image after rendered into ray tracing

@rafael-fuente
Copy link
Owner

Hello!
If you replace Sc.render() by Sc.get_distances() in any of the examples you'll avoid almost all rendering algorithm and you'll get a greymap where the darker pixels indicates that the object is nearer from the camera.

In example1.py this will be: (I just remplaced line 42)

from sightpy import *

# define materials to use

gold_metal = Glossy(diff_color = rgb(1., .572, .184), n = vec3(0.15+3.58j, 0.4+2.37j, 1.54+1.91j), roughness = 0.0, spec_coeff = 0.2, diff_coeff= 0.8) # n = index of refraction
bluish_metal = Glossy(diff_color = rgb(0.0, 0, 0.1), n = vec3(1.3+1.91j, 1.3+1.91j, 1.4+2.91j), roughness = 0.2,spec_coeff = 0.5, diff_coeff= 0.3)

floor =  Glossy(diff_color = image("checkered_floor.png", repeat = 80.),   
	            n = vec3(1.2+ 0.3j, 1.2+ 0.3j, 1.1+ 0.3j), roughness = 0.2, spec_coeff = 0.3, diff_coeff= 0.9 )





# Set Scene 
Sc = Scene(ambient_color = rgb(0.05, 0.05, 0.05))


angle = -np.pi/2 * 0.3
Sc.add_Camera(look_from = vec3(2.5*np.sin(angle), 0.25, 2.5*np.cos(angle)  -1.5 ), 
			  look_at = vec3(0., 0.25, -3.), 
	          screen_width = 400 ,
	          screen_height = 300)



Sc.add_DirectionalLight(Ldir = vec3(0.52,0.45, -0.5),  color = rgb(0.15, 0.15, 0.15))


Sc.add(Sphere(material = gold_metal, center = vec3(-.75, .1, -3.),radius =  .6, max_ray_depth = 3))
Sc.add(Sphere(material = bluish_metal, center = vec3(1.25, .1, -3.), radius = .6, max_ray_depth = 3))

Sc.add(Plane(material = floor,  center = vec3(0, -0.5, -3.0), width = 120.0,height = 120.0, u_axis = vec3(1.0, 0, 0), v_axis = vec3(0, 0, -1.0),  max_ray_depth = 3))

#see sightpy/backgrounds
Sc.add_Background("stormydays.png")




# Render 
img = Sc.get_distances()

img.save("EXAMPLE1.png")

img.show()

This is the graymap the script output:

EXAMPLE1

Obtaining the nearest object and the distance that the rays launched from each pixel intersect is the first step that the raytracer does. Then we proceed to obtain the information about the material of the intersecting object, and in what direction intersected to colour the pixel, using material.get_color()

@rudiana587
Copy link
Author

Thank you so much, that was helpful.
I wish you good health and success.

Repository owner locked and limited conversation to collaborators Jun 9, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants