|
Post by sbphillips on Aug 16, 2020 22:49:11 GMT
Anyone up for a challenge. I'm terrible at creating new images. I found one online that I was trying to recreate. the original appears brighter and the spheres seems more "metallic" i'd like to understand the changes required to create something more like the original. I've cobbled together a yml file. original image my image _
#
# camera
#
- add: camera
width: 600
height: 400
field-of-view: pi / 2.2)
from: [0, 0, -1]
to: [0, 0, 0]
up: [0, 1, 0]
#
# light
#
- add: light
at: [5, 5, -5]
intensity: [1, 1, 1]
#
# floor
#
- add: plane
transform:
- [ translate, 0, -0.7, 0 ]
material:
color: [0.25, 0.25, 0.25]
ambient: 0.1
diffuse: 0.6
specular: 1.0
shininess: 25.0
reflective: 0
#
# red sphere
#
- add: sphere
transform:
- [ translate, 0.2, 0, 1 ]
- [ scale, 0.7, 0.7, 0.7 ]
material:
color: [0.35, 0, 0]
ambient: 0.1
diffuse: 0.7
specular: 1.0
shininess: 25.0
reflective: 0.5
#
# magenta sphere
#
- add: sphere
transform:
- [ translate, 0.1, -0.3, 0 ]
- [ scale, 0.1, 0.1, 0.1 ]
material:
color: [0.35, 0, 0.35]
ambient: 0.1
diffuse: 0.7
specular: 1.0
shininess: 25.0
reflective: 0.5
#
# green sphere
#
- add: sphere
transform:
- [ translate, -0.3, 0, 0 ]
- [ scale, 0.15, 0.15, 0.15 ]
material:
color: [0, 0.35, 0]
ambient: 0.1
diffuse: 0.6
specular: 1.0
shininess: 25.0
reflective: 0.5
|
|
|
Post by sbphillips on Aug 18, 2020 0:36:18 GMT
Looks a bit better but more like a shiny pool ball not metallic
|
|
|
Post by Jamis on Aug 20, 2020 15:24:44 GMT
Yes, a metallic texture is hard to do with the Phong lighting model that my book describes, but with some fiddling you can usually come up with something passable. I wrote about one recipe in this post: /post/77/thread. Let me know if that helps at all!
|
|
|
Post by sbphillips on Aug 21, 2020 13:52:45 GMT
|
|
|
Post by Jamis on Aug 21, 2020 19:05:04 GMT
Blinn-Phong is very nearly the same thing as Phong, it just makes some assumptions and is therefore faster. I wouldn't expect the difference (in the scene you mentioned) to be significant. The difference is really just in the specular highlight (which, to my eye, looks pretty oversaturated in the reference image).
Do you have code somewhere describing your recreation of the scene?
|
|
|
Post by chrisd on Aug 26, 2020 3:19:50 GMT
With your YML file, I was not getting the same results. I found you had scale and translates reversed. The scale should come first, then the translate, otherwise the results are not what you expect.
I modified the field of view, as yours seems to be a formula and my parser does not support that.
I also changed some values for the floor.
Given that the article's reference scene was generated with separate RGB multipliers for ambient and diffuse instead of a single multiplier (which all our Ray Tracer Challenge supports), I don't think you can get the exact same color effects as the article without modifying the ray tracer. Also the article uses additional ambient/diffuse/specular values on the light, which we don't have. I modified the light intensity to try to get a little closer to the light levels of the example.
I hope this helps.
Here is my modified YML file:
# From https://forum.raytracerchallenge.com/thread/194/recreate-image
# # camera #
- add: camera width: 600 height: 400 field-of-view: 1.4279966607226332902102924469452 from: [0, 0, -1] to: [0, 0, 0] up: [0, 1, 0]
# # light #
- add: light at: [5, 5, -5] intensity: [2, 2, 2]
# # floor #
- add: plane transform: - [ translate, 0, -0.7, 0 ] material: color: [0.25, 0.25, 0.25] ambient: 0.1 diffuse: 0.6 specular: 1.0 shininess: 100.0 reflective: 0.5
# # red sphere #
- add: sphere transform: - [ scale, 0.7, 0.7, 0.7 ] - [ translate, -0.2, 0, 1 ] material: color: [0.35, 0, 0] ambient: 0.1 diffuse: 0.7 specular: 1.0 shininess: 25.0 reflective: 0.5
# # magenta sphere #
- add: sphere transform: - [ scale, 0.1, 0.1, 0.1 ] - [ translate, 0.1, -0.3, 0 ] material: color: [0.35, 0, 0.35] ambient: 0.1 diffuse: 0.7 specular: 1.0 shininess: 25.0 reflective: 0.5
# # green sphere #
- add: sphere transform: - [ scale, 0.15, 0.15, 0.15 ] - [ translate, -0.3, 0, 0 ] material: color: [0, 0.35, 0] ambient: 0.1 diffuse: 0.6 specular: 1.0 shininess: 25.0 reflective: 0.5
|
|
|
Post by sbphillips on Aug 27, 2020 18:02:49 GMT
Thanks for the help. Sorry about the yml file, I built it by hand and didn't know any better. Any insight on how to build the file to read/process the yml file? Seems like a large task.
|
|
|
Post by chrisd on Aug 28, 2020 23:40:23 GMT
I am not sure what language you did your tracer in ... I did mine in Java. I found the yamlbeans library and used that. The code that translates the parser output into Shapes and Camera and Lights is the ugliest code in my system. Yamlbeans builds a tree of objects. You don't know in advance whether something is going to be a list or a map or a string. Also, because the tree is pre-built, when you detect an error in the data, you don't know what line number the error was on. I almost wish I had written my own parser, or tried one of the other parsers available. I will come back to it some day to clean it up, but it is good enough for now. However, it is extremely convenient being able to read in files from Jamis and the others. I highly recommend doing it!
In case you are using Java, here is the yamlbeans lines for the pom.xml:
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <cucumber.version>6.1.1</cucumber.version> <junit.version>4.12</junit.version> <yamlbeans.version>1.13</yamlbeans.version> </properties>
<dependencies> <dependency> <groupId>com.esotericsoftware.yamlbeans</groupId> <artifactId>yamlbeans</artifactId> <version>${yamlbeans.version}</version> </dependency> [... etc ...] </dependencies>
|
|