forked from AcademySoftwareFoundation/OpenShadingLanguage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up ray types for testrender (AcademySoftwareFoundation#1648)
Try to set ray types correctly for rays -- a little naive now, only using "camera", "shadow", and "diffuse" for all rays (leave distinguishing between reflection, refraction, diffuse, glossy for another day, and currently testrender doesn't support subsurface or displacement, but maybe someday). Also, for testshade, improve efficency -- don't decode raytype on every point. For each individual shade, testshade was converting the name of the raytype from a string to a ustring, then decoding to a bitfield. Pull it all out of the loops by computing the bitfield once. Adjust glass shaders to not change behavior based on raytype: The code path that was supposed to suppress noisy caustic rays never worked properly before because we never set the ray type in testrender. Now that testrender sets it -- but does not distinguish between the different types of secondary rays -- the code path is active, but incorrect, and causes tests to fail. Just remove the offending clause for now and return to the old behavior of the shader (no attempt to eliminate caustic rays). Later, we should revamp the glass shader entirely by switching to the newer MaterialX-inspired closures. Note: when you specify a resolution in the Background command in our scene xml, it will run the shader out of any ray context at all (therefore having no raytype) in order to populate an environment map that will be used as needed. If you omit the resolution, no importance sampling is used at all, so it's much noisier. I think the right approach is to do both -- populate the map for importance sampling, but run the shader on the rays themselves to get higher quality visible results. Signed-off-by: Larry Gritz <lg@larrygritz.com>
- Loading branch information
Showing
15 changed files
with
212 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Render too expensive without optimization |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright Contributors to the Open Shading Language project. | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage | ||
|
||
|
||
surface | ||
glossy | ||
[[ string description = "Glossy material" ]] | ||
( | ||
color Cs = 0.5 | ||
[[ string description = "Base color", | ||
float UImin = 0, float UImax = 1 ]], | ||
color Ce = 1.0 | ||
[[ string description = "Edge color", | ||
float UImin = 0, float UImax = 1 ]], | ||
float roughness = 0.5 | ||
[[ string description = "Roughness of the surface", | ||
float UImin = 0, float UImax = 1 ]], | ||
float anisotropy = 0.0 | ||
[[ string description = "Anisotropy of the surface", | ||
float UImin = 0, float UImax = 1 ]] | ||
) | ||
{ | ||
float alpha = roughness * roughness; | ||
float alpha_x = alpha * (1.0 - anisotropy); | ||
float alpha_y = alpha; | ||
vector U = normalize(cross(N, dPdv)); | ||
color ior, extinction; | ||
artistic_ior(Cs, Ce, ior, extinction); | ||
Ci = conductor_bsdf(N, U, alpha_x, alpha_y, ior, extinction, "ggx"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright Contributors to the Open Shading Language project. | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage | ||
|
||
|
||
surface | ||
magic | ||
[[ string help = "Magic shader that varies by ray type" ]] | ||
( | ||
float scale_s = 4 | ||
[[ string description = "scale factor for s coordinate" ]], | ||
float scale_t = 4 | ||
[[ string description = "scale factor for t coordinate" ]], | ||
) | ||
{ | ||
float cs = fmod(u * scale_s, 2); | ||
float ct = fmod(v * scale_t, 2); | ||
int check = ((int(cs) ^ int(ct)) == 0); | ||
color Cs = 0; | ||
if (raytype("camera")) { | ||
// Looks like a grey and white checkerboard to camera rays | ||
Cs = check ? 1 : 0.125; | ||
} else { | ||
// Looks like a red and green checkerboard to secondary rays | ||
Cs = check ? color(1,0,0) : color(0,0.25,0); | ||
} | ||
Ci = Cs * diffuse(N); | ||
} |
Oops, something went wrong.