Skip to content
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

Coloring the Spheres #59

Open
radhikamattoo opened this issue Oct 4, 2017 · 2 comments
Open

Coloring the Spheres #59

radhikamattoo opened this issue Oct 4, 2017 · 2 comments

Comments

@radhikamattoo
Copy link

I'm confused about how to apply different colors to different spheres. I tried modifying the values passed into the given code here: write_matrix_to_png(C,C,C,A,filename); by doing something like: write_matrix_to_png((C/2),C,(C/3),A,filename);, etc. to give different RGB values, but it changes all sphere colors and the background as well.

I can't find anything in the slides about how to modify the color of individual spheres, so any help would be appreciated!

@jiangzhongshi
Copy link
Collaborator

Hi,

write_matrix_to_png(R, G, B, A, filename) is indeed where you need to modify to get the different color. However, this function only simply writing R, G, B and Alpha matrices to a png file.

When it comes to different colors for each sphere. You need to specify it when constructing matrices R, G, B. Different colors come from different materials i.e. those coefficients in the shading model, which would be different for each color channel (reflecting more red light gives you a red object). The easiest way to get it done is to let different objects' shading contributes to a different color channel.

Best,
Zhongshi

@radhikamattoo
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants