diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-09-16 17:14:02 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-09-16 17:14:02 +0400 |
commit | 66b1dfae89cc44953bd51c5da962cab437e76972 (patch) | |
tree | e7679b3e554fb4f1bb6f68775c8619bcde0da822 /intern/cycles/kernel/osl/nodes | |
parent | 0a5fcf3da3e82fd114095c8c2903d927f15ffc31 (diff) |
Cycles: tweaks to properties and nodes
* Passes renamed to samples
* Camera lens radius renamed to aperature size/blades/rotation
* Glass and fresnel nodes input is now index of refraction
* Glossy and velvet fresnel socket removed
* Mix/add closure node renamed to mix/add shader node
* Blend weight node added for shader mixing weights
There is some version patching code for reading existing files, but it's not
perfect, so shaders may work a bit different.
Diffstat (limited to 'intern/cycles/kernel/osl/nodes')
8 files changed, 60 insertions, 30 deletions
diff --git a/intern/cycles/kernel/osl/nodes/CMakeLists.txt b/intern/cycles/kernel/osl/nodes/CMakeLists.txt index 365cc42ad6b..7d37bb09d71 100644 --- a/intern/cycles/kernel/osl/nodes/CMakeLists.txt +++ b/intern/cycles/kernel/osl/nodes/CMakeLists.txt @@ -30,6 +30,7 @@ set(osl_sources node_mix.osl node_mix_closure.osl node_musgrave_texture.osl + node_blend_weight_texture.osl node_noise_texture.osl node_output_displacement.osl node_output_surface.osl diff --git a/intern/cycles/kernel/osl/nodes/node_blend_weight.osl b/intern/cycles/kernel/osl/nodes/node_blend_weight.osl new file mode 100644 index 00000000000..d834819ef3a --- /dev/null +++ b/intern/cycles/kernel/osl/nodes/node_blend_weight.osl @@ -0,0 +1,42 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "stdosl.h" +#include "node_fresnel.h" + +shader node_blend_weight( + float Blend = 0.3, + normal Normal = N, + output float Fresnel = 0.0, + output float Facing = 0.0) +{ + float f = max(1.0 - Blend, 1e-5); + Fresnel = fresnel_dielectric(I, Normal, backfacing()? f: 1.0/f); + + Facing = abs(dot(I, Normal)); + + if(Blend != 0.5) { + Blend = clamp(Blend, 0.0, 1.0); + Blend = (Blend < 0.5)? 2.0*Blend: 0.5/(1.0 - Blend); + + Facing = powf(Facing, Blend); + } + + Facing = 1.0 - Facing; +} + diff --git a/intern/cycles/kernel/osl/nodes/node_environment_texture.osl b/intern/cycles/kernel/osl/nodes/node_environment_texture.osl index 267db7bad2d..3ad806781eb 100644 --- a/intern/cycles/kernel/osl/nodes/node_environment_texture.osl +++ b/intern/cycles/kernel/osl/nodes/node_environment_texture.osl @@ -23,9 +23,10 @@ shader node_environment_texture( vector Vector = P, string filename = "", string color_space = "sRGB", - output color Color = color(0.0, 0.0, 0.0)) + output color Color = color(0.0, 0.0, 0.0), + output float Alpha = 1.0) { - Color = (color)environment(filename, Vector); + Color = (color)environment(filename, Vector, "alpha", Alpha); if(color_space == "sRGB") Color = color_srgb_to_scene_linear(Color); diff --git a/intern/cycles/kernel/osl/nodes/node_fresnel.osl b/intern/cycles/kernel/osl/nodes/node_fresnel.osl index ddc86db130f..3af4448b43f 100644 --- a/intern/cycles/kernel/osl/nodes/node_fresnel.osl +++ b/intern/cycles/kernel/osl/nodes/node_fresnel.osl @@ -20,11 +20,12 @@ #include "node_fresnel.h" shader node_fresnel( - float Fresnel = 0.3, + float IOR = 1.45, normal Normal = N, output float Fac = 0.0) { - float f = max(1.0 - Fresnel, 0.00001); - Fac = fresnel_dielectric(I, Normal, backfacing()? f: 1.0/f); + float f = max(IOR, 1.0 + 1e-5); + float eta = backfacing()? 1.0/f: f; + Fac = fresnel_dielectric(I, Normal, eta); } diff --git a/intern/cycles/kernel/osl/nodes/node_glass_bsdf.osl b/intern/cycles/kernel/osl/nodes/node_glass_bsdf.osl index af946048011..cc2104af56f 100644 --- a/intern/cycles/kernel/osl/nodes/node_glass_bsdf.osl +++ b/intern/cycles/kernel/osl/nodes/node_glass_bsdf.osl @@ -23,12 +23,12 @@ shader node_glass_bsdf( color Color = color(0.8, 0.8, 0.8), string distribution = "Sharp", float Roughness = 0.2, - float Fresnel = 0.3, + float IOR = 1.45, normal Normal = N, output closure color BSDF = diffuse(Normal)) { - float f = clamp(1.0 - Fresnel, 1e-5, 1.0 - 1e-5); - float eta = backfacing()? f: 1.0/f; + float f = max(IOR, 1.0 + 1e-5); + float eta = backfacing()? 1.0/f: f; float Fr = fresnel_dielectric(I, Normal, eta); if(distribution == "Sharp") diff --git a/intern/cycles/kernel/osl/nodes/node_glossy_bsdf.osl b/intern/cycles/kernel/osl/nodes/node_glossy_bsdf.osl index ca6bee74b38..aa446b66cfb 100644 --- a/intern/cycles/kernel/osl/nodes/node_glossy_bsdf.osl +++ b/intern/cycles/kernel/osl/nodes/node_glossy_bsdf.osl @@ -23,23 +23,15 @@ shader node_glossy_bsdf( color Color = color(0.8, 0.8, 0.8), string distribution = "Beckmann", float Roughness = 0.2, - float Fresnel = 1.0, normal Normal = N, output closure color BSDF = diffuse(Normal)) { - float Fr = 1.0; - - if(Fresnel < 1.0) { - float eta = 1.0/clamp(1.0 - Fresnel, 1e-5, 1.0 - 1e-5); - Fr = fresnel_dielectric(I, Normal, eta); - } - if(distribution == "Sharp") - BSDF = (Fr*Color)*reflection(Normal); + BSDF = Color*reflection(Normal); else if(distribution == "Beckmann") - BSDF = (Fr*Color)*microfacet_beckmann(Normal, Roughness); + BSDF = Color*microfacet_beckmann(Normal, Roughness); else if(distribution == "GGX") - BSDF = (Fr*Color)*microfacet_ggx(Normal, Roughness); + BSDF = Color*microfacet_ggx(Normal, Roughness); } diff --git a/intern/cycles/kernel/osl/nodes/node_image_texture.osl b/intern/cycles/kernel/osl/nodes/node_image_texture.osl index 85025db7c74..38126401d76 100644 --- a/intern/cycles/kernel/osl/nodes/node_image_texture.osl +++ b/intern/cycles/kernel/osl/nodes/node_image_texture.osl @@ -23,9 +23,10 @@ shader node_image_texture( point Vector = P, string filename = "", string color_space = "sRGB", - output color Color = color(0.0, 0.0, 0.0)) + output color Color = color(0.0, 0.0, 0.0), + output float Alpha = 1.0) { - Color = (color)texture(filename, Vector[0], 1.0-Vector[1], "wrap", "periodic"); + Color = (color)texture(filename, Vector[0], 1.0-Vector[1], "wrap", "periodic", "alpha", Alpha); if(color_space == "sRGB") Color = color_srgb_to_scene_linear(Color); diff --git a/intern/cycles/kernel/osl/nodes/node_velvet_bsdf.osl b/intern/cycles/kernel/osl/nodes/node_velvet_bsdf.osl index 2b6219f6325..7a336c148db 100644 --- a/intern/cycles/kernel/osl/nodes/node_velvet_bsdf.osl +++ b/intern/cycles/kernel/osl/nodes/node_velvet_bsdf.osl @@ -22,19 +22,11 @@ shader node_velvet_bsdf( color Color = color(0.8, 0.8, 0.8), float Sigma = 0.0, - float Fresnel = 0.3, normal Normal = N, output closure color BSDF = diffuse(Normal)) { - float Fr = 1.0; - - if(Fresnel < 1.0) { - float eta = 1.0/clamp(1.0 - Fresnel, 1e-5, 1.0 - 1e-5); - Fr = fresnel_dielectric(I, Normal, eta); - } - float sigma = clamp(Sigma, 0.0, 1.0); - BSDF = (Fr*Color)*ashikhmin_velvet(Normal, sigma); + BSDF = Color*ashikhmin_velvet(Normal, sigma); } |