-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testrender: Implement basic displacement shader support
Associate an (optional) displacement shader with each material. On startup, we execute the displacement for each face-vertex that has a valid displacement shader assigned. Signed-off-by: Chris Kulla <[email protected]>
- Loading branch information
1 parent
bcb5adb
commit 663e1fb
Showing
9 changed files
with
256 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright Contributors to the Open Shading Language project. | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage | ||
|
||
|
||
displacement | ||
disp | ||
( | ||
float scale = 1, | ||
float amplitude = 1, | ||
int octaves = 4, | ||
color Cs = 1 | ||
) | ||
{ | ||
float amount = 0; | ||
point b = P * scale; | ||
float a = amplitude; | ||
for (int i = 0; i < octaves; i++) { | ||
amount += a * noise(b); | ||
b *= 2.0; | ||
a *= 0.5; | ||
} | ||
P += amount * N; | ||
} |
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,23 @@ | ||
// Copyright Contributors to the Open Shading Language project. | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage | ||
|
||
|
||
surface | ||
emitter | ||
[[ string description = "Lambertian emitter material" ]] | ||
( | ||
float power = 1 | ||
[[ string description = "Total power of the light", | ||
float UImin = 0 ]], | ||
color Cs = 1 | ||
[[ string description = "Base color", | ||
float UImin = 0, float UImax = 1 ]] | ||
) | ||
{ | ||
// Because emission() expects a weight in radiance, we must convert by dividing | ||
// the power (in Watts) by the surface area and the factor of PI implied by | ||
// uniform emission over the hemisphere. N.B.: The total power is BEFORE Cs | ||
// filters the color! | ||
Ci = (power / (M_PI * surfacearea())) * Cs * emission(); | ||
} |
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,19 @@ | ||
// Copyright Contributors to the Open Shading Language project. | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage | ||
|
||
|
||
surface | ||
matte | ||
[[ string description = "Lambertian diffuse material" ]] | ||
( | ||
float Kd = 1 | ||
[[ string description = "Diffuse scaling", | ||
float UImin = 0, float UIsoftmax = 1 ]], | ||
color Cs = 1 | ||
[[ string description = "Base color", | ||
float UImin = 0, float UImax = 1 ]] | ||
) | ||
{ | ||
Ci = Kd * Cs * diffuse (N); | ||
} |
Binary file not shown.
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,10 @@ | ||
#!/usr/bin/env python | ||
|
||
# Copyright Contributors to the Open Shading Language project. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# https://github.com/AcademySoftwareFoundation/OpenShadingLanguage | ||
|
||
failthresh = 0.01 | ||
failpercent = 1 | ||
outputs = [ "out.exr" ] | ||
command = testrender("-r 256 256 -aa 8 scene.xml out.exr") |
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 @@ | ||
<World> | ||
<Camera eye="0, 1.5, 25" dir="0,0,-1" fov="14.5" /> | ||
|
||
<ShaderGroup name="main">color Cs 0.35 0.35 0.35; shader matte layer1;</ShaderGroup> | ||
<ShaderGroup name="main" type="displacement"> | ||
float scale 4; | ||
float amplitude 0.3; | ||
int octaves 8; | ||
shader disp layer1; | ||
</ShaderGroup> | ||
|
||
<Sphere center="0,1.25,-0.25" radius="0.6" resolution="256" /> | ||
|
||
<ShaderGroup>color Cs 0.75 0.25 0.25; shader matte layer1;</ShaderGroup> | ||
<Quad corner="-1.5, 0, -1.5" edge_x="0,3,0" edge_y="0,0,3" /> <!-- Left --> | ||
|
||
<ShaderGroup>color Cs 0.25 0.25 0.75; shader matte layer1;</ShaderGroup> | ||
<Quad corner="1.5, 0, -1.5" edge_x="0,0,3" edge_y="0,3,0" /> <!-- Right --> | ||
|
||
<ShaderGroup>color Cs 0.25 0.25 0.25; shader matte layer1;</ShaderGroup> | ||
<Quad corner="-1.5, 0,-1.5" edge_x="3,0,0" edge_y="0,3,0" /> <!-- Back --> | ||
<Quad corner="-1.5, 0,-1.5" edge_x="0,0,3" edge_y="3,0,0" /> <!-- Botm --> | ||
|
||
<Quad corner="-1.5,3,-1.5" edge_x="3,0,0" edge_y="0,0,3" /> <!-- Top --> | ||
|
||
<ShaderGroup is_light="yes">float power 100; shader emitter layer1</ShaderGroup> | ||
<Quad corner="-0.5,2.98,-0.5" edge_x="1, 0, 0" edge_y="0, 0, 1"/> <!--Lite --> | ||
</World> |