diff --git a/sandbox/tests/test scenes/environment/27 - osl environment reflection direct lighting.appleseed b/sandbox/tests/test scenes/environment/27 - osl environment reflection direct lighting.appleseed new file mode 100644 index 0000000000..7ac2481bef --- /dev/null +++ b/sandbox/tests/test scenes/environment/27 - osl environment reflection direct lighting.appleseed @@ -0,0 +1,195 @@ + + + + + + + + + + + -0.999269725598125 0.001642966393130 0.038174810601749 1.715050303872409 + 0.000000000000000 0.999075151126506 -0.042998167420825 -0.019262019900611 + -0.038210149215207 -0.042966766959830 -0.998345552118089 -5.486060105139496 + 0.000000000000000 0.000000000000000 0.000000000000000 1.000000000000000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.200000 0.200000 0.200000 + + + 1.000000 + + + + + + 0.750000 0.750000 0.750000 + + + 1.000000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.000000000000000 0.000000000000000 0.000000000000000 1.000000000000000 + 0.000000000000000 1.000000000000000 0.000000000000000 0.000000000000000 + 0.000000000000000 0.000000000000000 1.000000000000000 0.000000000000000 + 0.000000000000000 0.000000000000000 0.000000000000000 1.000000000000000 + + + + + + + + + 1.000000000000000 0.000000000000000 0.000000000000000 2.000000000000000 + 0.000000000000000 1.000000000000000 0.000000000000000 0.000000000000000 + 0.000000000000000 0.000000000000000 1.000000000000000 0.000000000000000 + 0.000000000000000 0.000000000000000 0.000000000000000 1.000000000000000 + + + + + + + + + 1.000000000000000 0.000000000000000 0.000000000000000 3.000000000000000 + 0.000000000000000 1.000000000000000 0.000000000000000 0.000000000000000 + 0.000000000000000 0.000000000000000 1.000000000000000 0.000000000000000 + 0.000000000000000 0.000000000000000 0.000000000000000 1.000000000000000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/tests/test scenes/environment/envmap.osl b/sandbox/tests/test scenes/environment/envmap.osl new file mode 100644 index 0000000000..04daa3f764 --- /dev/null +++ b/sandbox/tests/test scenes/environment/envmap.osl @@ -0,0 +1,13 @@ + +surface envmap(string filename = "") +{ + vector dir = normalize(I); + + float theta = acos(dir[1]); + float phi = atan2(dir[2], dir[0]); + + float tu = (phi + M_PI) / M_2PI; + float tv = 1.0 - (theta / M_PI); + color c = texture(filename, tu, tv); + Ci = c * background(); +} diff --git a/sandbox/tests/test scenes/environment/envmap.oso b/sandbox/tests/test scenes/environment/envmap.oso new file mode 100644 index 0000000000..73ac004fc8 --- /dev/null +++ b/sandbox/tests/test scenes/environment/envmap.oso @@ -0,0 +1,55 @@ +OpenShadingLanguage 1.00 +# Compiled by oslc 1.7.4 +# options: +surface envmap +param string filename "" %read{10,10} %write{2147483647,-1} +global vector I %read{0,0} %write{2147483647,-1} %derivs +global closure color Ci %read{2147483647,-1} %write{12,12} +local vector dir %read{1,4} %write{0,0} %derivs +local float theta %read{8,8} %write{2,2} %derivs +local float phi %read{6,6} %write{5,5} %derivs +local float tu %read{10,10} %write{7,7} %derivs +local float tv %read{10,10} %write{9,9} %derivs +local color c %read{12,12} %write{10,10} +const int $const1 1 %read{1,1} %write{2147483647,-1} +temp float $tmp1 %read{2,2} %write{1,1} %derivs +const int $const2 2 %read{3,3} %write{2147483647,-1} +temp float $tmp2 %read{5,5} %write{3,3} %derivs +const int $const3 0 %read{4,4} %write{2147483647,-1} +temp float $tmp3 %read{5,5} %write{4,4} %derivs +const float $const4 3.1415927 %read{6,8} %write{2147483647,-1} +temp float $tmp4 %read{7,7} %write{6,6} %derivs +const float $const5 6.2831855 %read{7,7} %write{2147483647,-1} +const float $const6 1 %read{9,9} %write{2147483647,-1} +temp float $tmp5 %read{9,9} %write{8,8} %derivs +temp closure color $tmp6 %read{12,12} %write{11,11} +const string $const7 "background" %read{11,11} %write{2147483647,-1} +code ___main___ +# envmap.osl:4 +# vector dir = normalize(I); + normalize dir I %filename{"envmap.osl"} %line{4} %argrw{"wr"} +# envmap.osl:6 +# float theta = acos(dir[1]); + compref $tmp1 dir $const1 %line{6} %argrw{"wrr"} + acos theta $tmp1 %argrw{"wr"} +# envmap.osl:7 +# float phi = atan2(dir[2], dir[0]); + compref $tmp2 dir $const2 %line{7} %argrw{"wrr"} + compref $tmp3 dir $const3 %argrw{"wrr"} + atan2 phi $tmp2 $tmp3 %argrw{"wrr"} +# envmap.osl:9 +# float tu = (phi + M_PI) / M_2PI; + add $tmp4 phi $const4 %line{9} %argrw{"wrr"} + div tu $tmp4 $const5 %argrw{"wrr"} +# envmap.osl:10 +# float tv = 1.0 - (theta / M_PI); + div $tmp5 theta $const4 %line{10} %argrw{"wrr"} + sub tv $const6 $tmp5 %argrw{"wrr"} +# envmap.osl:11 +# color c = texture(filename, tu, tv); + texture c filename tu tv %line{11} %argrw{"wrrr"} %argderivs{2,3} +# envmap.osl:12 +# Ci = c * background(); + closure $tmp6 $const7 %line{12} %argrw{"wr"} + mul Ci $tmp6 c %argrw{"wrr"} + end diff --git a/sandbox/tests/test scenes/environment/ref/27 - osl environment reflection direct lighting.png b/sandbox/tests/test scenes/environment/ref/27 - osl environment reflection direct lighting.png new file mode 100644 index 0000000000..4d45a35bb9 Binary files /dev/null and b/sandbox/tests/test scenes/environment/ref/27 - osl environment reflection direct lighting.png differ diff --git a/sandbox/tests/test scenes/osl/11 - background osl - ptne.appleseed b/sandbox/tests/test scenes/osl/11 - background osl - ptne.appleseed deleted file mode 100644 index ee0339eb2c..0000000000 --- a/sandbox/tests/test scenes/osl/11 - background osl - ptne.appleseed +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - _geometry - - - _shaders - - - - - - - - - - -0.184255811687806 -0.160188164351797 0.969736844644396 1.500292409049696 - 0.000000000000000 0.986629598941879 0.162978632009806 0.542118269962757 - -0.982878322000881 0.030029760128735 -0.181792237588250 -0.348568473946572 - 0.000000000000000 0.000000000000000 0.000000000000000 1.000000000000000 - - - - - - - - - - - 1.000000 1.000000 1.000000 - - - 1.000000 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sandbox/tests/test scenes/osl/_shaders/background.osl b/sandbox/tests/test scenes/osl/_shaders/background.osl deleted file mode 100644 index ac66f7477a..0000000000 --- a/sandbox/tests/test scenes/osl/_shaders/background.osl +++ /dev/null @@ -1,6 +0,0 @@ - -surface background() -{ - vector dir = normalize(I); - Ci = color(fabs(dir[0]), fabs(dir[1]), fabs(dir[2])) * background(); -} diff --git a/sandbox/tests/test scenes/osl/_shaders/background.oso b/sandbox/tests/test scenes/osl/_shaders/background.oso deleted file mode 100644 index d509db8f0e..0000000000 --- a/sandbox/tests/test scenes/osl/_shaders/background.oso +++ /dev/null @@ -1,35 +0,0 @@ -OpenShadingLanguage 1.00 -# Compiled by oslc 1.7.4 -# options: -surface background -global vector I %read{0,0} %write{2147483647,-1} -global closure color Ci %read{2147483647,-1} %write{9,9} -local vector dir %read{2,6} %write{0,0} -temp closure color $tmp1 %read{9,9} %write{1,1} -const string $const1 "background" %read{1,1} %write{2147483647,-1} -temp color $tmp2 %read{9,9} %write{8,8} -temp float $tmp3 %read{8,8} %write{3,3} -const int $const2 0 %read{2,2} %write{2147483647,-1} -temp float $tmp4 %read{3,3} %write{2,2} -temp float $tmp5 %read{8,8} %write{5,5} -const int $const3 1 %read{4,4} %write{2147483647,-1} -temp float $tmp6 %read{5,5} %write{4,4} -temp float $tmp7 %read{8,8} %write{7,7} -const int $const4 2 %read{6,6} %write{2147483647,-1} -temp float $tmp8 %read{7,7} %write{6,6} -code ___main___ -# background.osl:4 -# vector dir = normalize(I); - normalize dir I %filename{"background.osl"} %line{4} %argrw{"wr"} -# background.osl:5 -# Ci = color(fabs(dir[0]), fabs(dir[1]), fabs(dir[2])) * background(); - closure $tmp1 $const1 %line{5} %argrw{"wr"} - compref $tmp4 dir $const2 %argrw{"wrr"} - fabs $tmp3 $tmp4 %argrw{"wr"} - compref $tmp6 dir $const3 %argrw{"wrr"} - fabs $tmp5 $tmp6 %argrw{"wr"} - compref $tmp8 dir $const4 %argrw{"wrr"} - fabs $tmp7 $tmp8 %argrw{"wr"} - color $tmp2 $tmp3 $tmp5 $tmp7 %argrw{"wrrr"} - mul Ci $tmp1 $tmp2 %argrw{"wrr"} - end diff --git a/sandbox/tests/test scenes/osl/ref/11 - background osl - ptne.png b/sandbox/tests/test scenes/osl/ref/11 - background osl - ptne.png deleted file mode 100644 index ed7089e011..0000000000 Binary files a/sandbox/tests/test scenes/osl/ref/11 - background osl - ptne.png and /dev/null differ diff --git a/src/appleseed/renderer/modeling/environmentedf/oslenvironmentedf.cpp b/src/appleseed/renderer/modeling/environmentedf/oslenvironmentedf.cpp index 34d3cff365..f392720825 100644 --- a/src/appleseed/renderer/modeling/environmentedf/oslenvironmentedf.cpp +++ b/src/appleseed/renderer/modeling/environmentedf/oslenvironmentedf.cpp @@ -134,7 +134,7 @@ namespace const Transformd& transform = m_transform_sequence.evaluate(0.0f, scratch); outgoing = transform.vector_to_parent(local_outgoing); - evaluate(shading_context, input_evaluator, local_outgoing, value); + evaluate_osl_background(shading_context, local_outgoing, value); } virtual void evaluate( @@ -149,9 +149,7 @@ namespace const Transformd& transform = m_transform_sequence.evaluate(0.0f, scratch); const Vector3f local_outgoing = transform.vector_to_local(outgoing); - if (m_shader_group) - shading_context.execute_osl_background(*m_shader_group, local_outgoing, value); - else value.set(0.0f); + evaluate_osl_background(shading_context, local_outgoing, value); } virtual void evaluate( @@ -167,7 +165,7 @@ namespace const Transformd& transform = m_transform_sequence.evaluate(0.0f, scratch); const Vector3f local_outgoing = transform.vector_to_local(outgoing); - evaluate(shading_context, input_evaluator, local_outgoing, value); + evaluate_osl_background(shading_context, local_outgoing, value); probability = evaluate_pdf(input_evaluator, outgoing); } @@ -180,6 +178,16 @@ namespace } private: + void evaluate_osl_background( + const ShadingContext& shading_context, + const Vector3f& local_outgoing, + Spectrum& value) const + { + if (m_shader_group) + shading_context.execute_osl_background(*m_shader_group, local_outgoing, value); + else value.set(0.0f); + } + ShaderGroup* m_shader_group; }; }