Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/kernel/shaders')
-rw-r--r--intern/cycles/kernel/shaders/CMakeLists.txt212
-rw-r--r--intern/cycles/kernel/shaders/node_absorption_volume.osl10
-rw-r--r--intern/cycles/kernel/shaders/node_add_closure.osl10
-rw-r--r--intern/cycles/kernel/shaders/node_ambient_occlusion.osl36
-rw-r--r--intern/cycles/kernel/shaders/node_anisotropic_bsdf.osl70
-rw-r--r--intern/cycles/kernel/shaders/node_attribute.osl38
-rw-r--r--intern/cycles/kernel/shaders/node_background.osl10
-rw-r--r--intern/cycles/kernel/shaders/node_bevel.osl18
-rw-r--r--intern/cycles/kernel/shaders/node_blackbody.osl19
-rw-r--r--intern/cycles/kernel/shaders/node_brick_texture.osl165
-rw-r--r--intern/cycles/kernel/shaders/node_brightness.osl20
-rw-r--r--intern/cycles/kernel/shaders/node_bump.osl74
-rw-r--r--intern/cycles/kernel/shaders/node_camera.osl16
-rw-r--r--intern/cycles/kernel/shaders/node_checker_texture.osl71
-rw-r--r--intern/cycles/kernel/shaders/node_color.h197
-rw-r--r--intern/cycles/kernel/shaders/node_combine_hsv.osl9
-rw-r--r--intern/cycles/kernel/shaders/node_combine_rgb.osl9
-rw-r--r--intern/cycles/kernel/shaders/node_combine_xyz.osl9
-rw-r--r--intern/cycles/kernel/shaders/node_convert_from_color.osl26
-rw-r--r--intern/cycles/kernel/shaders/node_convert_from_float.osl26
-rw-r--r--intern/cycles/kernel/shaders/node_convert_from_int.osl28
-rw-r--r--intern/cycles/kernel/shaders/node_convert_from_normal.osl26
-rw-r--r--intern/cycles/kernel/shaders/node_convert_from_point.osl26
-rw-r--r--intern/cycles/kernel/shaders/node_convert_from_string.osl16
-rw-r--r--intern/cycles/kernel/shaders/node_convert_from_vector.osl26
-rw-r--r--intern/cycles/kernel/shaders/node_diffuse_bsdf.osl18
-rw-r--r--intern/cycles/kernel/shaders/node_displacement.osl30
-rw-r--r--intern/cycles/kernel/shaders/node_emission.osl8
-rw-r--r--intern/cycles/kernel/shaders/node_environment_texture.osl82
-rw-r--r--intern/cycles/kernel/shaders/node_fresnel.h44
-rw-r--r--intern/cycles/kernel/shaders/node_fresnel.osl14
-rw-r--r--intern/cycles/kernel/shaders/node_gamma.osl7
-rw-r--r--intern/cycles/kernel/shaders/node_geometry.osl88
-rw-r--r--intern/cycles/kernel/shaders/node_glass_bsdf.osl44
-rw-r--r--intern/cycles/kernel/shaders/node_glossy_bsdf.osl35
-rw-r--r--intern/cycles/kernel/shaders/node_gradient_texture.osl89
-rw-r--r--intern/cycles/kernel/shaders/node_hair_bsdf.osl65
-rw-r--r--intern/cycles/kernel/shaders/node_hair_info.osl22
-rw-r--r--intern/cycles/kernel/shaders/node_holdout.osl5
-rw-r--r--intern/cycles/kernel/shaders/node_hsv.osl36
-rw-r--r--intern/cycles/kernel/shaders/node_ies_light.osl29
-rw-r--r--intern/cycles/kernel/shaders/node_image_texture.osl378
-rw-r--r--intern/cycles/kernel/shaders/node_invert.osl10
-rw-r--r--intern/cycles/kernel/shaders/node_layer_weight.osl37
-rw-r--r--intern/cycles/kernel/shaders/node_light_falloff.osl40
-rw-r--r--intern/cycles/kernel/shaders/node_light_path.osl78
-rw-r--r--intern/cycles/kernel/shaders/node_magic_texture.osl162
-rw-r--r--intern/cycles/kernel/shaders/node_mapping.osl23
-rw-r--r--intern/cycles/kernel/shaders/node_math.osl162
-rw-r--r--intern/cycles/kernel/shaders/node_mix.osl421
-rw-r--r--intern/cycles/kernel/shaders/node_mix_closure.osl14
-rw-r--r--intern/cycles/kernel/shaders/node_musgrave_texture.osl302
-rw-r--r--intern/cycles/kernel/shaders/node_noise_texture.osl63
-rw-r--r--intern/cycles/kernel/shaders/node_normal.osl14
-rw-r--r--intern/cycles/kernel/shaders/node_normal_map.osl128
-rw-r--r--intern/cycles/kernel/shaders/node_object_info.osl18
-rw-r--r--intern/cycles/kernel/shaders/node_output_displacement.osl3
-rw-r--r--intern/cycles/kernel/shaders/node_output_surface.osl3
-rw-r--r--intern/cycles/kernel/shaders/node_output_volume.osl3
-rw-r--r--intern/cycles/kernel/shaders/node_particle_info.osl34
-rw-r--r--intern/cycles/kernel/shaders/node_principled_bsdf.osl245
-rw-r--r--intern/cycles/kernel/shaders/node_principled_hair_bsdf.osl128
-rw-r--r--intern/cycles/kernel/shaders/node_principled_volume.osl126
-rw-r--r--intern/cycles/kernel/shaders/node_ramp_util.h108
-rw-r--r--intern/cycles/kernel/shaders/node_refraction_bsdf.osl32
-rw-r--r--intern/cycles/kernel/shaders/node_rgb_curves.osl30
-rw-r--r--intern/cycles/kernel/shaders/node_rgb_ramp.osl18
-rw-r--r--intern/cycles/kernel/shaders/node_rgb_to_bw.osl7
-rw-r--r--intern/cycles/kernel/shaders/node_scatter_volume.osl12
-rw-r--r--intern/cycles/kernel/shaders/node_separate_hsv.osl19
-rw-r--r--intern/cycles/kernel/shaders/node_separate_rgb.osl15
-rw-r--r--intern/cycles/kernel/shaders/node_separate_xyz.osl15
-rw-r--r--intern/cycles/kernel/shaders/node_set_normal.osl9
-rw-r--r--intern/cycles/kernel/shaders/node_sky_texture.osl157
-rw-r--r--intern/cycles/kernel/shaders/node_subsurface_scattering.osl43
-rw-r--r--intern/cycles/kernel/shaders/node_tangent.osl46
-rw-r--r--intern/cycles/kernel/shaders/node_texture.h210
-rw-r--r--intern/cycles/kernel/shaders/node_texture_coordinate.osl141
-rw-r--r--intern/cycles/kernel/shaders/node_toon_bsdf.osl22
-rw-r--r--intern/cycles/kernel/shaders/node_translucent_bsdf.osl8
-rw-r--r--intern/cycles/kernel/shaders/node_transparent_bsdf.osl8
-rw-r--r--intern/cycles/kernel/shaders/node_uv_map.osl47
-rw-r--r--intern/cycles/kernel/shaders/node_value.osl20
-rw-r--r--intern/cycles/kernel/shaders/node_vector_curves.osl30
-rw-r--r--intern/cycles/kernel/shaders/node_vector_displacement.osl78
-rw-r--r--intern/cycles/kernel/shaders/node_vector_math.osl60
-rw-r--r--intern/cycles/kernel/shaders/node_vector_transform.osl30
-rw-r--r--intern/cycles/kernel/shaders/node_velvet_bsdf.osl14
-rw-r--r--intern/cycles/kernel/shaders/node_voronoi_texture.osl273
-rw-r--r--intern/cycles/kernel/shaders/node_voxel_texture.osl52
-rw-r--r--intern/cycles/kernel/shaders/node_wave_texture.osl72
-rw-r--r--intern/cycles/kernel/shaders/node_wavelength.osl7
-rw-r--r--intern/cycles/kernel/shaders/node_wireframe.osl39
-rw-r--r--intern/cycles/kernel/shaders/oslutil.h100
-rw-r--r--intern/cycles/kernel/shaders/stdosl.h1160
95 files changed, 3573 insertions, 3484 deletions
diff --git a/intern/cycles/kernel/shaders/CMakeLists.txt b/intern/cycles/kernel/shaders/CMakeLists.txt
index 4740db27d4e..b42b9b2fe64 100644
--- a/intern/cycles/kernel/shaders/CMakeLists.txt
+++ b/intern/cycles/kernel/shaders/CMakeLists.txt
@@ -2,102 +2,102 @@
# OSL node shaders
set(SRC_OSL
- node_add_closure.osl
- node_ambient_occlusion.osl
- node_anisotropic_bsdf.osl
- node_attribute.osl
- node_background.osl
- node_bevel.osl
- node_brick_texture.osl
- node_brightness.osl
- node_bump.osl
- node_camera.osl
- node_checker_texture.osl
- node_combine_rgb.osl
- node_combine_hsv.osl
- node_combine_xyz.osl
- node_convert_from_color.osl
- node_convert_from_float.osl
- node_convert_from_int.osl
- node_convert_from_normal.osl
- node_convert_from_point.osl
- node_convert_from_vector.osl
- node_diffuse_bsdf.osl
- node_displacement.osl
- node_vector_displacement.osl
- node_emission.osl
- node_environment_texture.osl
- node_fresnel.osl
- node_gamma.osl
- node_geometry.osl
- node_glass_bsdf.osl
- node_glossy_bsdf.osl
- node_gradient_texture.osl
- node_hair_info.osl
- node_scatter_volume.osl
- node_absorption_volume.osl
- node_principled_volume.osl
- node_holdout.osl
- node_hsv.osl
- node_ies_light.osl
- node_image_texture.osl
- node_invert.osl
- node_layer_weight.osl
- node_light_falloff.osl
- node_light_path.osl
- node_magic_texture.osl
- node_mapping.osl
- node_math.osl
- node_mix.osl
- node_mix_closure.osl
- node_musgrave_texture.osl
- node_noise_texture.osl
- node_normal.osl
- node_normal_map.osl
- node_object_info.osl
- node_output_displacement.osl
- node_output_surface.osl
- node_output_volume.osl
- node_particle_info.osl
- node_refraction_bsdf.osl
- node_rgb_curves.osl
- node_rgb_ramp.osl
- node_separate_rgb.osl
- node_separate_hsv.osl
- node_separate_xyz.osl
- node_set_normal.osl
- node_sky_texture.osl
- node_subsurface_scattering.osl
- node_tangent.osl
- node_texture_coordinate.osl
- node_toon_bsdf.osl
- node_translucent_bsdf.osl
- node_transparent_bsdf.osl
- node_value.osl
- node_vector_curves.osl
- node_vector_math.osl
- node_vector_transform.osl
- node_velvet_bsdf.osl
- node_voronoi_texture.osl
- node_voxel_texture.osl
- node_wavelength.osl
- node_blackbody.osl
- node_wave_texture.osl
- node_wireframe.osl
- node_hair_bsdf.osl
- node_principled_hair_bsdf.osl
- node_uv_map.osl
- node_principled_bsdf.osl
- node_rgb_to_bw.osl
+ node_add_closure.osl
+ node_ambient_occlusion.osl
+ node_anisotropic_bsdf.osl
+ node_attribute.osl
+ node_background.osl
+ node_bevel.osl
+ node_brick_texture.osl
+ node_brightness.osl
+ node_bump.osl
+ node_camera.osl
+ node_checker_texture.osl
+ node_combine_rgb.osl
+ node_combine_hsv.osl
+ node_combine_xyz.osl
+ node_convert_from_color.osl
+ node_convert_from_float.osl
+ node_convert_from_int.osl
+ node_convert_from_normal.osl
+ node_convert_from_point.osl
+ node_convert_from_vector.osl
+ node_diffuse_bsdf.osl
+ node_displacement.osl
+ node_vector_displacement.osl
+ node_emission.osl
+ node_environment_texture.osl
+ node_fresnel.osl
+ node_gamma.osl
+ node_geometry.osl
+ node_glass_bsdf.osl
+ node_glossy_bsdf.osl
+ node_gradient_texture.osl
+ node_hair_info.osl
+ node_scatter_volume.osl
+ node_absorption_volume.osl
+ node_principled_volume.osl
+ node_holdout.osl
+ node_hsv.osl
+ node_ies_light.osl
+ node_image_texture.osl
+ node_invert.osl
+ node_layer_weight.osl
+ node_light_falloff.osl
+ node_light_path.osl
+ node_magic_texture.osl
+ node_mapping.osl
+ node_math.osl
+ node_mix.osl
+ node_mix_closure.osl
+ node_musgrave_texture.osl
+ node_noise_texture.osl
+ node_normal.osl
+ node_normal_map.osl
+ node_object_info.osl
+ node_output_displacement.osl
+ node_output_surface.osl
+ node_output_volume.osl
+ node_particle_info.osl
+ node_refraction_bsdf.osl
+ node_rgb_curves.osl
+ node_rgb_ramp.osl
+ node_separate_rgb.osl
+ node_separate_hsv.osl
+ node_separate_xyz.osl
+ node_set_normal.osl
+ node_sky_texture.osl
+ node_subsurface_scattering.osl
+ node_tangent.osl
+ node_texture_coordinate.osl
+ node_toon_bsdf.osl
+ node_translucent_bsdf.osl
+ node_transparent_bsdf.osl
+ node_value.osl
+ node_vector_curves.osl
+ node_vector_math.osl
+ node_vector_transform.osl
+ node_velvet_bsdf.osl
+ node_voronoi_texture.osl
+ node_voxel_texture.osl
+ node_wavelength.osl
+ node_blackbody.osl
+ node_wave_texture.osl
+ node_wireframe.osl
+ node_hair_bsdf.osl
+ node_principled_hair_bsdf.osl
+ node_uv_map.osl
+ node_principled_bsdf.osl
+ node_rgb_to_bw.osl
)
set(SRC_OSL_HEADERS
- node_color.h
- node_fresnel.h
- node_ramp_util.h
- node_texture.h
- stdosl.h
- oslutil.h
+ node_color.h
+ node_fresnel.h
+ node_ramp_util.h
+ node_texture.h
+ stdosl.h
+ oslutil.h
)
set(SRC_OSO
@@ -106,20 +106,20 @@ set(SRC_OSO
# TODO, add a module to compile OSL
foreach(_file ${SRC_OSL})
- set(_OSL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${_file})
- set_source_files_properties(${_file} PROPERTIES HEADER_FILE_ONLY TRUE)
- string(REPLACE ".osl" ".oso" _OSO_FILE ${_OSL_FILE})
- string(REPLACE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} _OSO_FILE ${_OSO_FILE})
- add_custom_command(
- OUTPUT ${_OSO_FILE}
- COMMAND ${OSL_COMPILER} -q -O2 -I"${CMAKE_CURRENT_SOURCE_DIR}" -o ${_OSO_FILE} ${_OSL_FILE}
- DEPENDS ${_OSL_FILE} ${SRC_OSL_HEADERS} ${OSL_COMPILER})
- list(APPEND SRC_OSO
- ${_OSO_FILE}
- )
+ set(_OSL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${_file})
+ set_source_files_properties(${_file} PROPERTIES HEADER_FILE_ONLY TRUE)
+ string(REPLACE ".osl" ".oso" _OSO_FILE ${_OSL_FILE})
+ string(REPLACE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} _OSO_FILE ${_OSO_FILE})
+ add_custom_command(
+ OUTPUT ${_OSO_FILE}
+ COMMAND ${OSL_COMPILER} -q -O2 -I"${CMAKE_CURRENT_SOURCE_DIR}" -o ${_OSO_FILE} ${_OSL_FILE}
+ DEPENDS ${_OSL_FILE} ${SRC_OSL_HEADERS} ${OSL_COMPILER})
+ list(APPEND SRC_OSO
+ ${_OSO_FILE}
+ )
- unset(_OSL_FILE)
- unset(_OSO_FILE)
+ unset(_OSL_FILE)
+ unset(_OSO_FILE)
endforeach()
add_custom_target(cycles_osl_shaders ALL DEPENDS ${SRC_OSO} ${SRC_OSL_HEADERS} ${OSL_COMPILER} SOURCES ${SRC_OSL})
diff --git a/intern/cycles/kernel/shaders/node_absorption_volume.osl b/intern/cycles/kernel/shaders/node_absorption_volume.osl
index 18f662ebbbd..e99bd254666 100644
--- a/intern/cycles/kernel/shaders/node_absorption_volume.osl
+++ b/intern/cycles/kernel/shaders/node_absorption_volume.osl
@@ -16,11 +16,9 @@
#include "stdosl.h"
-shader node_absorption_volume(
- color Color = color(0.8, 0.8, 0.8),
- float Density = 1.0,
- output closure color Volume = 0)
+shader node_absorption_volume(color Color = color(0.8, 0.8, 0.8),
+ float Density = 1.0,
+ output closure color Volume = 0)
{
- Volume = ((color(1.0, 1.0, 1.0) - Color) * max(Density, 0.0)) * absorption();
+ Volume = ((color(1.0, 1.0, 1.0) - Color) * max(Density, 0.0)) * absorption();
}
-
diff --git a/intern/cycles/kernel/shaders/node_add_closure.osl b/intern/cycles/kernel/shaders/node_add_closure.osl
index b6596e0b6bd..077e2735e61 100644
--- a/intern/cycles/kernel/shaders/node_add_closure.osl
+++ b/intern/cycles/kernel/shaders/node_add_closure.osl
@@ -16,11 +16,9 @@
#include "stdosl.h"
-shader node_add_closure(
- closure color Closure1 = 0,
- closure color Closure2 = 0,
- output closure color Closure = 0)
+shader node_add_closure(closure color Closure1 = 0,
+ closure color Closure2 = 0,
+ output closure color Closure = 0)
{
- Closure = Closure1 + Closure2;
+ Closure = Closure1 + Closure2;
}
-
diff --git a/intern/cycles/kernel/shaders/node_ambient_occlusion.osl b/intern/cycles/kernel/shaders/node_ambient_occlusion.osl
index 825cccd59ce..7bf28719e78 100644
--- a/intern/cycles/kernel/shaders/node_ambient_occlusion.osl
+++ b/intern/cycles/kernel/shaders/node_ambient_occlusion.osl
@@ -16,20 +16,28 @@
#include "stdosl.h"
-shader node_ambient_occlusion(
- color ColorIn = color(1.0, 1.0, 1.0),
- int samples = 16,
- float Distance = 1.0,
- normal Normal = N,
- int inside = 0,
- int only_local = 0,
- output color ColorOut = color(1.0, 1.0, 1.0),
- output float AO = 1.0)
+shader node_ambient_occlusion(color ColorIn = color(1.0, 1.0, 1.0),
+ int samples = 16,
+ float Distance = 1.0,
+ normal Normal = N,
+ int inside = 0,
+ int only_local = 0,
+ output color ColorOut = color(1.0, 1.0, 1.0),
+ output float AO = 1.0)
{
- int global_radius = (Distance == 0.0 && !isconnected(Distance));
+ int global_radius = (Distance == 0.0 && !isconnected(Distance));
- /* Abuse texture call with special @ao token. */
- AO = texture("@ao", samples, Distance, Normal[0], Normal[1], Normal[2], inside, "sblur", only_local, "tblur", global_radius);
- ColorOut = ColorIn * AO;
+ /* Abuse texture call with special @ao token. */
+ AO = texture("@ao",
+ samples,
+ Distance,
+ Normal[0],
+ Normal[1],
+ Normal[2],
+ inside,
+ "sblur",
+ only_local,
+ "tblur",
+ global_radius);
+ ColorOut = ColorIn * AO;
}
-
diff --git a/intern/cycles/kernel/shaders/node_anisotropic_bsdf.osl b/intern/cycles/kernel/shaders/node_anisotropic_bsdf.osl
index 21e28ece65d..165c09eb8e0 100644
--- a/intern/cycles/kernel/shaders/node_anisotropic_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_anisotropic_bsdf.osl
@@ -16,45 +16,43 @@
#include "stdosl.h"
-shader node_anisotropic_bsdf(
- color Color = 0.0,
- string distribution = "GGX",
- float Roughness = 0.0,
- float Anisotropy = 0.0,
- float Rotation = 0.0,
- normal Normal = N,
- normal Tangent = normalize(dPdu),
- output closure color BSDF = 0)
+shader node_anisotropic_bsdf(color Color = 0.0,
+ string distribution = "GGX",
+ float Roughness = 0.0,
+ float Anisotropy = 0.0,
+ float Rotation = 0.0,
+ normal Normal = N,
+ normal Tangent = normalize(dPdu),
+ output closure color BSDF = 0)
{
- /* rotate tangent around normal */
- vector T = Tangent;
+ /* rotate tangent around normal */
+ vector T = Tangent;
- if (Rotation != 0.0)
- T = rotate(T, Rotation * M_2PI, point(0.0, 0.0, 0.0), Normal);
+ if (Rotation != 0.0)
+ T = rotate(T, Rotation * M_2PI, point(0.0, 0.0, 0.0), Normal);
- /* compute roughness */
- float roughness = Roughness * Roughness;
- float roughness_u, roughness_v;
- float aniso = clamp(Anisotropy, -0.99, 0.99);
+ /* compute roughness */
+ float roughness = Roughness * Roughness;
+ float roughness_u, roughness_v;
+ float aniso = clamp(Anisotropy, -0.99, 0.99);
- if (aniso < 0.0) {
- roughness_u = roughness / (1.0 + aniso);
- roughness_v = roughness * (1.0 + aniso);
- }
- else {
- roughness_u = roughness * (1.0 - aniso);
- roughness_v = roughness / (1.0 - aniso);
- }
+ if (aniso < 0.0) {
+ roughness_u = roughness / (1.0 + aniso);
+ roughness_v = roughness * (1.0 + aniso);
+ }
+ else {
+ roughness_u = roughness * (1.0 - aniso);
+ roughness_v = roughness / (1.0 - aniso);
+ }
- if (distribution == "sharp")
- BSDF = Color * reflection(Normal);
- else if (distribution == "beckmann")
- BSDF = Color * microfacet_beckmann_aniso(Normal, T, roughness_u, roughness_v);
- else if (distribution == "GGX")
- BSDF = Color * microfacet_ggx_aniso(Normal, T, roughness_u, roughness_v);
- else if (distribution == "Multiscatter GGX")
- BSDF = Color * microfacet_multi_ggx_aniso(Normal, T, roughness_u, roughness_v, Color);
- else
- BSDF = Color * ashikhmin_shirley(Normal, T, roughness_u, roughness_v);
+ if (distribution == "sharp")
+ BSDF = Color * reflection(Normal);
+ else if (distribution == "beckmann")
+ BSDF = Color * microfacet_beckmann_aniso(Normal, T, roughness_u, roughness_v);
+ else if (distribution == "GGX")
+ BSDF = Color * microfacet_ggx_aniso(Normal, T, roughness_u, roughness_v);
+ else if (distribution == "Multiscatter GGX")
+ BSDF = Color * microfacet_multi_ggx_aniso(Normal, T, roughness_u, roughness_v, Color);
+ else
+ BSDF = Color * ashikhmin_shirley(Normal, T, roughness_u, roughness_v);
}
-
diff --git a/intern/cycles/kernel/shaders/node_attribute.osl b/intern/cycles/kernel/shaders/node_attribute.osl
index 67183e9ffe0..336543cc130 100644
--- a/intern/cycles/kernel/shaders/node_attribute.osl
+++ b/intern/cycles/kernel/shaders/node_attribute.osl
@@ -16,26 +16,24 @@
#include "stdosl.h"
-shader node_attribute(
- string bump_offset = "center",
- string name = "",
- output point Vector = point(0.0, 0.0, 0.0),
- output color Color = 0.0,
- output float Fac = 0.0)
+shader node_attribute(string bump_offset = "center",
+ string name = "",
+ output point Vector = point(0.0, 0.0, 0.0),
+ output color Color = 0.0,
+ output float Fac = 0.0)
{
- getattribute(name, Color);
- Vector = point(Color);
- getattribute(name, Fac);
+ getattribute(name, Color);
+ Vector = point(Color);
+ getattribute(name, Fac);
- if (bump_offset == "dx") {
- Color += Dx(Color);
- Vector += Dx(Vector);
- Fac += Dx(Fac);
- }
- else if (bump_offset == "dy") {
- Color += Dy(Color);
- Vector += Dy(Vector);
- Fac += Dy(Fac);
- }
+ if (bump_offset == "dx") {
+ Color += Dx(Color);
+ Vector += Dx(Vector);
+ Fac += Dx(Fac);
+ }
+ else if (bump_offset == "dy") {
+ Color += Dy(Color);
+ Vector += Dy(Vector);
+ Fac += Dy(Fac);
+ }
}
-
diff --git a/intern/cycles/kernel/shaders/node_background.osl b/intern/cycles/kernel/shaders/node_background.osl
index 613d4e360fa..6ded0d2c65c 100644
--- a/intern/cycles/kernel/shaders/node_background.osl
+++ b/intern/cycles/kernel/shaders/node_background.osl
@@ -16,11 +16,9 @@
#include "stdosl.h"
-shader node_background(
- color Color = 0.8,
- float Strength = 1.0,
- output closure color Background = 0)
+shader node_background(color Color = 0.8,
+ float Strength = 1.0,
+ output closure color Background = 0)
{
- Background = Color * Strength * background();
+ Background = Color * Strength * background();
}
-
diff --git a/intern/cycles/kernel/shaders/node_bevel.osl b/intern/cycles/kernel/shaders/node_bevel.osl
index 9c4ca15be17..189c20c52e7 100644
--- a/intern/cycles/kernel/shaders/node_bevel.osl
+++ b/intern/cycles/kernel/shaders/node_bevel.osl
@@ -16,16 +16,14 @@
#include "stdosl.h"
-shader node_bevel(
- int samples = 4,
- float Radius = 0.05,
- normal NormalIn = N,
- output normal NormalOut = N)
+shader node_bevel(int samples = 4,
+ float Radius = 0.05,
+ normal NormalIn = N,
+ output normal NormalOut = N)
{
- /* Abuse texture call with special @bevel token. */
- vector bevel_N = (normal)(color)texture("@bevel", samples, Radius);
+ /* Abuse texture call with special @bevel token. */
+ vector bevel_N = (normal)(color)texture("@bevel", samples, Radius);
- /* Preserve input normal. */
- NormalOut = normalize(NormalIn + (bevel_N - N));
+ /* Preserve input normal. */
+ NormalOut = normalize(NormalIn + (bevel_N - N));
}
-
diff --git a/intern/cycles/kernel/shaders/node_blackbody.osl b/intern/cycles/kernel/shaders/node_blackbody.osl
index 1da6894d0f0..8a24bf1e28b 100644
--- a/intern/cycles/kernel/shaders/node_blackbody.osl
+++ b/intern/cycles/kernel/shaders/node_blackbody.osl
@@ -16,16 +16,13 @@
#include "stdosl.h"
-shader node_blackbody(
- float Temperature = 1200.0,
- output color Color = 0.0)
+shader node_blackbody(float Temperature = 1200.0, output color Color = 0.0)
{
- color rgb = blackbody(Temperature);
-
- /* Scale by luminance */
- float l = luminance(rgb);
- if (l != 0.0)
- rgb /= l;
- Color = rgb;
-}
+ color rgb = blackbody(Temperature);
+ /* Scale by luminance */
+ float l = luminance(rgb);
+ if (l != 0.0)
+ rgb /= l;
+ Color = rgb;
+}
diff --git a/intern/cycles/kernel/shaders/node_brick_texture.osl b/intern/cycles/kernel/shaders/node_brick_texture.osl
index 9d2e5b74ce6..0abc3574c48 100644
--- a/intern/cycles/kernel/shaders/node_brick_texture.osl
+++ b/intern/cycles/kernel/shaders/node_brick_texture.osl
@@ -21,85 +21,100 @@
float brick_noise(int ns) /* fast integer noise */
{
- int nn;
- int n = (ns + 1013) & 2147483647;
- n = (n >> 13) ^ n;
- nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 2147483647;
- return 0.5 * ((float)nn / 1073741824.0);
+ int nn;
+ int n = (ns + 1013) & 2147483647;
+ n = (n >> 13) ^ n;
+ nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 2147483647;
+ return 0.5 * ((float)nn / 1073741824.0);
}
-float brick(point p, float mortar_size, float mortar_smooth, float bias,
- float BrickWidth, float row_height, float offset_amount, int offset_frequency,
- float squash_amount, int squash_frequency, output float tint)
+float brick(point p,
+ float mortar_size,
+ float mortar_smooth,
+ float bias,
+ float BrickWidth,
+ float row_height,
+ float offset_amount,
+ int offset_frequency,
+ float squash_amount,
+ int squash_frequency,
+ output float tint)
{
- int bricknum, rownum;
- float offset = 0.0;
- float brick_width = BrickWidth;
- float x, y;
-
- rownum = (int)floor(p[1] / row_height);
-
- if (offset_frequency && squash_frequency) {
- brick_width *= (rownum % squash_frequency) ? 1.0 : squash_amount; /* squash */
- offset = (rownum % offset_frequency) ? 0.0 : (brick_width * offset_amount); /* offset */
- }
-
- bricknum = (int)floor((p[0] + offset) / brick_width);
-
- x = (p[0] + offset) - brick_width * bricknum;
- y = p[1] - row_height * rownum;
-
- tint = clamp((brick_noise((rownum << 16) + (bricknum & 65535)) + bias), 0.0, 1.0);
-
- float min_dist = min(min(x, y), min(brick_width - x, row_height - y));
- if(min_dist >= mortar_size) {
- return 0.0;
- }
- else if(mortar_smooth == 0.0) {
- return 1.0;
- }
- else {
- min_dist = 1.0 - min_dist/mortar_size;
- return smoothstep(0.0, mortar_smooth, min_dist);
- }
+ int bricknum, rownum;
+ float offset = 0.0;
+ float brick_width = BrickWidth;
+ float x, y;
+
+ rownum = (int)floor(p[1] / row_height);
+
+ if (offset_frequency && squash_frequency) {
+ brick_width *= (rownum % squash_frequency) ? 1.0 : squash_amount; /* squash */
+ offset = (rownum % offset_frequency) ? 0.0 : (brick_width * offset_amount); /* offset */
+ }
+
+ bricknum = (int)floor((p[0] + offset) / brick_width);
+
+ x = (p[0] + offset) - brick_width * bricknum;
+ y = p[1] - row_height * rownum;
+
+ tint = clamp((brick_noise((rownum << 16) + (bricknum & 65535)) + bias), 0.0, 1.0);
+
+ float min_dist = min(min(x, y), min(brick_width - x, row_height - y));
+ if (min_dist >= mortar_size) {
+ return 0.0;
+ }
+ else if (mortar_smooth == 0.0) {
+ return 1.0;
+ }
+ else {
+ min_dist = 1.0 - min_dist / mortar_size;
+ return smoothstep(0.0, mortar_smooth, min_dist);
+ }
}
-shader node_brick_texture(
- int use_mapping = 0,
- matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- float offset = 0.5,
- int offset_frequency = 2,
- float squash = 1.0,
- int squash_frequency = 1,
- point Vector = P,
- color Color1 = 0.2,
- color Color2 = 0.8,
- color Mortar = 0.0,
- float Scale = 5.0,
- float MortarSize = 0.02,
- float MortarSmooth = 0.0,
- float Bias = 0.0,
- float BrickWidth = 0.5,
- float RowHeight = 0.25,
- output float Fac = 0.0,
- output color Color = 0.2)
+shader node_brick_texture(int use_mapping = 0,
+ matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+ float offset = 0.5,
+ int offset_frequency = 2,
+ float squash = 1.0,
+ int squash_frequency = 1,
+ point Vector = P,
+ color Color1 = 0.2,
+ color Color2 = 0.8,
+ color Mortar = 0.0,
+ float Scale = 5.0,
+ float MortarSize = 0.02,
+ float MortarSmooth = 0.0,
+ float Bias = 0.0,
+ float BrickWidth = 0.5,
+ float RowHeight = 0.25,
+ output float Fac = 0.0,
+ output color Color = 0.2)
{
- point p = Vector;
-
- if (use_mapping)
- p = transform(mapping, p);
-
- float tint = 0.0;
- color Col = Color1;
-
- Fac = brick(p * Scale, MortarSize, MortarSmooth, Bias, BrickWidth, RowHeight,
- offset, offset_frequency, squash, squash_frequency, tint);
-
- if (Fac != 1.0) {
- float facm = 1.0 - tint;
- Col = facm * Color1 + tint * Color2;
- }
-
- Color = mix(Col, Mortar, Fac);
-}
+ point p = Vector;
+
+ if (use_mapping)
+ p = transform(mapping, p);
+
+ float tint = 0.0;
+ color Col = Color1;
+ Fac = brick(p * Scale,
+ MortarSize,
+ MortarSmooth,
+ Bias,
+ BrickWidth,
+ RowHeight,
+ offset,
+ offset_frequency,
+ squash,
+ squash_frequency,
+ tint);
+
+ if (Fac != 1.0) {
+ float facm = 1.0 - tint;
+ Col = facm * Color1 + tint * Color2;
+ }
+
+ Color = mix(Col, Mortar, Fac);
+}
diff --git a/intern/cycles/kernel/shaders/node_brightness.osl b/intern/cycles/kernel/shaders/node_brightness.osl
index 00cfb167885..2defbc4b1db 100644
--- a/intern/cycles/kernel/shaders/node_brightness.osl
+++ b/intern/cycles/kernel/shaders/node_brightness.osl
@@ -16,17 +16,15 @@
#include "stdosl.h"
-shader node_brightness(
- color ColorIn = 0.8,
- float Bright = 0.0,
- float Contrast = 0.0,
- output color ColorOut = 0.8)
+shader node_brightness(color ColorIn = 0.8,
+ float Bright = 0.0,
+ float Contrast = 0.0,
+ output color ColorOut = 0.8)
{
- float a = 1.0 + Contrast;
- float b = Bright - Contrast * 0.5;
+ float a = 1.0 + Contrast;
+ float b = Bright - Contrast * 0.5;
- ColorOut[0] = max(a * ColorIn[0] + b, 0.0);
- ColorOut[1] = max(a * ColorIn[1] + b, 0.0);
- ColorOut[2] = max(a * ColorIn[2] + b, 0.0);
+ ColorOut[0] = max(a * ColorIn[0] + b, 0.0);
+ ColorOut[1] = max(a * ColorIn[1] + b, 0.0);
+ ColorOut[2] = max(a * ColorIn[2] + b, 0.0);
}
-
diff --git a/intern/cycles/kernel/shaders/node_bump.osl b/intern/cycles/kernel/shaders/node_bump.osl
index a2a4468d5f3..3697bb37fd9 100644
--- a/intern/cycles/kernel/shaders/node_bump.osl
+++ b/intern/cycles/kernel/shaders/node_bump.osl
@@ -19,52 +19,50 @@
/* "Bump Mapping Unparameterized Surfaces on the GPU"
* Morten S. Mikkelsen, 2010 */
-surface node_bump(
- int invert = 0,
- int use_object_space = 0,
- normal NormalIn = N,
- float Strength = 0.1,
- float Distance = 1.0,
- float SampleCenter = 0.0,
- float SampleX = 0.0,
- float SampleY = 0.0,
- output normal NormalOut = N)
+surface node_bump(int invert = 0,
+ int use_object_space = 0,
+ normal NormalIn = N,
+ float Strength = 0.1,
+ float Distance = 1.0,
+ float SampleCenter = 0.0,
+ float SampleX = 0.0,
+ float SampleY = 0.0,
+ output normal NormalOut = N)
{
- point Ptmp = P;
- normal Normal = NormalIn;
+ point Ptmp = P;
+ normal Normal = NormalIn;
- if (use_object_space) {
- Ptmp = transform("object", Ptmp);
- Normal = normalize(transform("object", Normal));
- }
+ if (use_object_space) {
+ Ptmp = transform("object", Ptmp);
+ Normal = normalize(transform("object", Normal));
+ }
- /* get surface tangents from normal */
- vector dPdx = Dx(Ptmp);
- vector dPdy = Dy(Ptmp);
+ /* get surface tangents from normal */
+ vector dPdx = Dx(Ptmp);
+ vector dPdy = Dy(Ptmp);
- vector Rx = cross(dPdy, Normal);
- vector Ry = cross(Normal, dPdx);
+ vector Rx = cross(dPdy, Normal);
+ vector Ry = cross(Normal, dPdx);
- /* compute surface gradient and determinant */
- float det = dot(dPdx, Rx);
- vector surfgrad = (SampleX - SampleCenter) * Rx + (SampleY - SampleCenter) * Ry;
+ /* compute surface gradient and determinant */
+ float det = dot(dPdx, Rx);
+ vector surfgrad = (SampleX - SampleCenter) * Rx + (SampleY - SampleCenter) * Ry;
- float absdet = fabs(det);
+ float absdet = fabs(det);
- float strength = max(Strength, 0.0);
- float dist = Distance;
+ float strength = max(Strength, 0.0);
+ float dist = Distance;
- if (invert)
- dist *= -1.0;
-
- /* compute and output perturbed normal */
- NormalOut = normalize(absdet * Normal - dist * sign(det) * surfgrad);
- NormalOut = normalize(strength * NormalOut + (1.0 - strength) * Normal);
+ if (invert)
+ dist *= -1.0;
- if (use_object_space) {
- NormalOut = normalize(transform("object", "world", NormalOut));
- }
+ /* compute and output perturbed normal */
+ NormalOut = normalize(absdet * Normal - dist * sign(det) * surfgrad);
+ NormalOut = normalize(strength * NormalOut + (1.0 - strength) * Normal);
- NormalOut = ensure_valid_reflection(Ng, I, NormalOut);
-}
+ if (use_object_space) {
+ NormalOut = normalize(transform("object", "world", NormalOut));
+ }
+ NormalOut = ensure_valid_reflection(Ng, I, NormalOut);
+}
diff --git a/intern/cycles/kernel/shaders/node_camera.osl b/intern/cycles/kernel/shaders/node_camera.osl
index 5e90cb8b8ee..833e9e775fe 100644
--- a/intern/cycles/kernel/shaders/node_camera.osl
+++ b/intern/cycles/kernel/shaders/node_camera.osl
@@ -16,16 +16,14 @@
#include "stdosl.h"
-shader node_camera(
- output vector ViewVector = vector(0.0, 0.0, 0.0),
- output float ViewZDepth = 0.0,
- output float ViewDistance = 0.0)
+shader node_camera(output vector ViewVector = vector(0.0, 0.0, 0.0),
+ output float ViewZDepth = 0.0,
+ output float ViewDistance = 0.0)
{
- ViewVector = (vector)transform("world", "camera", P);
+ ViewVector = (vector)transform("world", "camera", P);
- ViewZDepth = fabs(ViewVector[2]);
- ViewDistance = length(ViewVector);
+ ViewZDepth = fabs(ViewVector[2]);
+ ViewDistance = length(ViewVector);
- ViewVector = normalize(ViewVector);
+ ViewVector = normalize(ViewVector);
}
-
diff --git a/intern/cycles/kernel/shaders/node_checker_texture.osl b/intern/cycles/kernel/shaders/node_checker_texture.osl
index e745cfaee06..e068f7952ed 100644
--- a/intern/cycles/kernel/shaders/node_checker_texture.osl
+++ b/intern/cycles/kernel/shaders/node_checker_texture.osl
@@ -21,44 +21,43 @@
float checker(point ip)
{
- point p;
- p[0] = (ip[0] + 0.000001) * 0.999999;
- p[1] = (ip[1] + 0.000001) * 0.999999;
- p[2] = (ip[2] + 0.000001) * 0.999999;
-
- int xi = (int)fabs(floor(p[0]));
- int yi = (int)fabs(floor(p[1]));
- int zi = (int)fabs(floor(p[2]));
-
- if ((xi % 2 == yi % 2) == (zi % 2)) {
- return 1.0;
- }
- else {
- return 0.0;
- }
+ point p;
+ p[0] = (ip[0] + 0.000001) * 0.999999;
+ p[1] = (ip[1] + 0.000001) * 0.999999;
+ p[2] = (ip[2] + 0.000001) * 0.999999;
+
+ int xi = (int)fabs(floor(p[0]));
+ int yi = (int)fabs(floor(p[1]));
+ int zi = (int)fabs(floor(p[2]));
+
+ if ((xi % 2 == yi % 2) == (zi % 2)) {
+ return 1.0;
+ }
+ else {
+ return 0.0;
+ }
}
shader node_checker_texture(
- int use_mapping = 0,
- matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- float Scale = 5.0,
- point Vector = P,
- color Color1 = 0.8,
- color Color2 = 0.2,
- output float Fac = 0.0,
- output color Color = 0.0)
+ int use_mapping = 0,
+ matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+ float Scale = 5.0,
+ point Vector = P,
+ color Color1 = 0.8,
+ color Color2 = 0.2,
+ output float Fac = 0.0,
+ output color Color = 0.0)
{
- point p = Vector;
-
- if (use_mapping)
- p = transform(mapping, p);
-
- Fac = checker(p * Scale);
- if (Fac == 1.0) {
- Color = Color1;
- }
- else {
- Color = Color2;
- }
+ point p = Vector;
+
+ if (use_mapping)
+ p = transform(mapping, p);
+
+ Fac = checker(p * Scale);
+ if (Fac == 1.0) {
+ Color = Color1;
+ }
+ else {
+ Color = Color2;
+ }
}
-
diff --git a/intern/cycles/kernel/shaders/node_color.h b/intern/cycles/kernel/shaders/node_color.h
index fc758bef1fa..276c91843e8 100644
--- a/intern/cycles/kernel/shaders/node_color.h
+++ b/intern/cycles/kernel/shaders/node_color.h
@@ -18,135 +18,146 @@
float color_srgb_to_scene_linear(float c)
{
- if (c < 0.04045)
- return (c < 0.0) ? 0.0 : c * (1.0 / 12.92);
- else
- return pow((c + 0.055) * (1.0 / 1.055), 2.4);
+ if (c < 0.04045)
+ return (c < 0.0) ? 0.0 : c * (1.0 / 12.92);
+ else
+ return pow((c + 0.055) * (1.0 / 1.055), 2.4);
}
float color_scene_linear_to_srgb(float c)
{
- if (c < 0.0031308)
- return (c < 0.0) ? 0.0 : c * 12.92;
- else
- return 1.055 * pow(c, 1.0 / 2.4) - 0.055;
+ if (c < 0.0031308)
+ return (c < 0.0) ? 0.0 : c * 12.92;
+ else
+ return 1.055 * pow(c, 1.0 / 2.4) - 0.055;
}
color color_srgb_to_scene_linear(color c)
{
- return color(
- color_srgb_to_scene_linear(c[0]),
- color_srgb_to_scene_linear(c[1]),
- color_srgb_to_scene_linear(c[2]));
+ return color(color_srgb_to_scene_linear(c[0]),
+ color_srgb_to_scene_linear(c[1]),
+ color_srgb_to_scene_linear(c[2]));
}
color color_scene_linear_to_srgb(color c)
{
- return color(
- color_scene_linear_to_srgb(c[0]),
- color_scene_linear_to_srgb(c[1]),
- color_scene_linear_to_srgb(c[2]));
+ return color(color_scene_linear_to_srgb(c[0]),
+ color_scene_linear_to_srgb(c[1]),
+ color_scene_linear_to_srgb(c[2]));
}
color color_unpremultiply(color c, float alpha)
{
- if (alpha != 1.0 && alpha != 0.0)
- return c / alpha;
+ if (alpha != 1.0 && alpha != 0.0)
+ return c / alpha;
- return c;
+ return c;
}
/* Color Operations */
color xyY_to_xyz(float x, float y, float Y)
{
- float X, Z;
+ float X, Z;
- if (y != 0.0) X = (x / y) * Y;
- else X = 0.0;
+ if (y != 0.0)
+ X = (x / y) * Y;
+ else
+ X = 0.0;
- if (y != 0.0 && Y != 0.0) Z = ((1.0 - x - y) / y) * Y;
- else Z = 0.0;
+ if (y != 0.0 && Y != 0.0)
+ Z = ((1.0 - x - y) / y) * Y;
+ else
+ Z = 0.0;
- return color(X, Y, Z);
+ return color(X, Y, Z);
}
color xyz_to_rgb(float x, float y, float z)
{
- return color( 3.240479 * x + -1.537150 * y + -0.498535 * z,
- -0.969256 * x + 1.875991 * y + 0.041556 * z,
- 0.055648 * x + -0.204043 * y + 1.057311 * z);
+ return color(3.240479 * x + -1.537150 * y + -0.498535 * z,
+ -0.969256 * x + 1.875991 * y + 0.041556 * z,
+ 0.055648 * x + -0.204043 * y + 1.057311 * z);
}
color rgb_to_hsv(color rgb)
{
- float cmax, cmin, h, s, v, cdelta;
- color c;
-
- cmax = max(rgb[0], max(rgb[1], rgb[2]));
- cmin = min(rgb[0], min(rgb[1], rgb[2]));
- cdelta = cmax - cmin;
-
- v = cmax;
-
- if (cmax != 0.0) {
- s = cdelta / cmax;
- }
- else {
- s = 0.0;
- h = 0.0;
- }
-
- if (s == 0.0) {
- h = 0.0;
- }
- else {
- c = (color(cmax, cmax, cmax) - rgb) / cdelta;
-
- if (rgb[0] == cmax) h = c[2] - c[1];
- else if (rgb[1] == cmax) h = 2.0 + c[0] - c[2];
- else h = 4.0 + c[1] - c[0];
-
- h /= 6.0;
-
- if (h < 0.0)
- h += 1.0;
- }
-
- return color(h, s, v);
+ float cmax, cmin, h, s, v, cdelta;
+ color c;
+
+ cmax = max(rgb[0], max(rgb[1], rgb[2]));
+ cmin = min(rgb[0], min(rgb[1], rgb[2]));
+ cdelta = cmax - cmin;
+
+ v = cmax;
+
+ if (cmax != 0.0) {
+ s = cdelta / cmax;
+ }
+ else {
+ s = 0.0;
+ h = 0.0;
+ }
+
+ if (s == 0.0) {
+ h = 0.0;
+ }
+ else {
+ c = (color(cmax, cmax, cmax) - rgb) / cdelta;
+
+ if (rgb[0] == cmax)
+ h = c[2] - c[1];
+ else if (rgb[1] == cmax)
+ h = 2.0 + c[0] - c[2];
+ else
+ h = 4.0 + c[1] - c[0];
+
+ h /= 6.0;
+
+ if (h < 0.0)
+ h += 1.0;
+ }
+
+ return color(h, s, v);
}
color hsv_to_rgb(color hsv)
{
- float i, f, p, q, t, h, s, v;
- color rgb;
-
- h = hsv[0];
- s = hsv[1];
- v = hsv[2];
-
- if (s == 0.0) {
- rgb = color(v, v, v);
- }
- else {
- if (h == 1.0)
- h = 0.0;
-
- h *= 6.0;
- i = floor(h);
- f = h - i;
- rgb = color(f, f, f);
- p = v * (1.0 - s);
- q = v * (1.0 - (s * f));
- t = v * (1.0 - (s * (1.0 - f)));
-
- if (i == 0.0) rgb = color(v, t, p);
- else if (i == 1.0) rgb = color(q, v, p);
- else if (i == 2.0) rgb = color(p, v, t);
- else if (i == 3.0) rgb = color(p, q, v);
- else if (i == 4.0) rgb = color(t, p, v);
- else rgb = color(v, p, q);
- }
-
- return rgb;
+ float i, f, p, q, t, h, s, v;
+ color rgb;
+
+ h = hsv[0];
+ s = hsv[1];
+ v = hsv[2];
+
+ if (s == 0.0) {
+ rgb = color(v, v, v);
+ }
+ else {
+ if (h == 1.0)
+ h = 0.0;
+
+ h *= 6.0;
+ i = floor(h);
+ f = h - i;
+ rgb = color(f, f, f);
+ p = v * (1.0 - s);
+ q = v * (1.0 - (s * f));
+ t = v * (1.0 - (s * (1.0 - f)));
+
+ if (i == 0.0)
+ rgb = color(v, t, p);
+ else if (i == 1.0)
+ rgb = color(q, v, p);
+ else if (i == 2.0)
+ rgb = color(p, v, t);
+ else if (i == 3.0)
+ rgb = color(p, q, v);
+ else if (i == 4.0)
+ rgb = color(t, p, v);
+ else
+ rgb = color(v, p, q);
+ }
+
+ return rgb;
}
diff --git a/intern/cycles/kernel/shaders/node_combine_hsv.osl b/intern/cycles/kernel/shaders/node_combine_hsv.osl
index 6b922bf4e6b..1658cf3d774 100644
--- a/intern/cycles/kernel/shaders/node_combine_hsv.osl
+++ b/intern/cycles/kernel/shaders/node_combine_hsv.osl
@@ -16,12 +16,7 @@
#include "stdosl.h"
-shader node_combine_hsv(
- float H = 0.0,
- float S = 0.0,
- float V = 0.0,
- output color Color = 0.8)
+shader node_combine_hsv(float H = 0.0, float S = 0.0, float V = 0.0, output color Color = 0.8)
{
- Color = color("hsv", H, S, V);
+ Color = color("hsv", H, S, V);
}
-
diff --git a/intern/cycles/kernel/shaders/node_combine_rgb.osl b/intern/cycles/kernel/shaders/node_combine_rgb.osl
index f343fdefd84..aaa95e9c5af 100644
--- a/intern/cycles/kernel/shaders/node_combine_rgb.osl
+++ b/intern/cycles/kernel/shaders/node_combine_rgb.osl
@@ -16,12 +16,7 @@
#include "stdosl.h"
-shader node_combine_rgb(
- float R = 0.0,
- float G = 0.0,
- float B = 0.0,
- output color Image = 0.8)
+shader node_combine_rgb(float R = 0.0, float G = 0.0, float B = 0.0, output color Image = 0.8)
{
- Image = color(R, G, B);
+ Image = color(R, G, B);
}
-
diff --git a/intern/cycles/kernel/shaders/node_combine_xyz.osl b/intern/cycles/kernel/shaders/node_combine_xyz.osl
index 86182056b09..4ab49168704 100644
--- a/intern/cycles/kernel/shaders/node_combine_xyz.osl
+++ b/intern/cycles/kernel/shaders/node_combine_xyz.osl
@@ -16,12 +16,7 @@
#include "stdosl.h"
-shader node_combine_xyz(
- float X = 0.0,
- float Y = 0.0,
- float Z = 0.0,
- output vector Vector = 0.8)
+shader node_combine_xyz(float X = 0.0, float Y = 0.0, float Z = 0.0, output vector Vector = 0.8)
{
- Vector = vector(X, Y, Z);
+ Vector = vector(X, Y, Z);
}
-
diff --git a/intern/cycles/kernel/shaders/node_convert_from_color.osl b/intern/cycles/kernel/shaders/node_convert_from_color.osl
index e95a17f6fa1..7ea9a1e4fb3 100644
--- a/intern/cycles/kernel/shaders/node_convert_from_color.osl
+++ b/intern/cycles/kernel/shaders/node_convert_from_color.osl
@@ -16,19 +16,17 @@
#include "stdosl.h"
-shader node_convert_from_color(
- color value_color = 0.0,
- output string value_string = "",
- output float value_float = 0.0,
- output int value_int = 0,
- output vector value_vector = vector(0.0, 0.0, 0.0),
- output point value_point = point(0.0, 0.0, 0.0),
- output normal value_normal = normal(0.0, 0.0, 0.0))
+shader node_convert_from_color(color value_color = 0.0,
+ output string value_string = "",
+ output float value_float = 0.0,
+ output int value_int = 0,
+ output vector value_vector = vector(0.0, 0.0, 0.0),
+ output point value_point = point(0.0, 0.0, 0.0),
+ output normal value_normal = normal(0.0, 0.0, 0.0))
{
- value_float = value_color[0] * 0.2126 + value_color[1] * 0.7152 + value_color[2] * 0.0722;
- value_int = (int)(value_color[0] * 0.2126 + value_color[1] * 0.7152 + value_color[2] * 0.0722);
- value_vector = vector(value_color[0], value_color[1], value_color[2]);
- value_point = point(value_color[0], value_color[1], value_color[2]);
- value_normal = normal(value_color[0], value_color[1], value_color[2]);
+ value_float = value_color[0] * 0.2126 + value_color[1] * 0.7152 + value_color[2] * 0.0722;
+ value_int = (int)(value_color[0] * 0.2126 + value_color[1] * 0.7152 + value_color[2] * 0.0722);
+ value_vector = vector(value_color[0], value_color[1], value_color[2]);
+ value_point = point(value_color[0], value_color[1], value_color[2]);
+ value_normal = normal(value_color[0], value_color[1], value_color[2]);
}
-
diff --git a/intern/cycles/kernel/shaders/node_convert_from_float.osl b/intern/cycles/kernel/shaders/node_convert_from_float.osl
index a5c2e3b26ad..13b5dea0838 100644
--- a/intern/cycles/kernel/shaders/node_convert_from_float.osl
+++ b/intern/cycles/kernel/shaders/node_convert_from_float.osl
@@ -16,19 +16,17 @@
#include "stdosl.h"
-shader node_convert_from_float(
- float value_float = 0.0,
- output string value_string = "",
- output int value_int = 0,
- output color value_color = 0.0,
- output vector value_vector = vector(0.0, 0.0, 0.0),
- output point value_point = point(0.0, 0.0, 0.0),
- output normal value_normal = normal(0.0, 0.0, 0.0))
+shader node_convert_from_float(float value_float = 0.0,
+ output string value_string = "",
+ output int value_int = 0,
+ output color value_color = 0.0,
+ output vector value_vector = vector(0.0, 0.0, 0.0),
+ output point value_point = point(0.0, 0.0, 0.0),
+ output normal value_normal = normal(0.0, 0.0, 0.0))
{
- value_int = (int)value_float;
- value_color = color(value_float, value_float, value_float);
- value_vector = vector(value_float, value_float, value_float);
- value_point = point(value_float, value_float, value_float);
- value_normal = normal(value_float, value_float, value_float);
+ value_int = (int)value_float;
+ value_color = color(value_float, value_float, value_float);
+ value_vector = vector(value_float, value_float, value_float);
+ value_point = point(value_float, value_float, value_float);
+ value_normal = normal(value_float, value_float, value_float);
}
-
diff --git a/intern/cycles/kernel/shaders/node_convert_from_int.osl b/intern/cycles/kernel/shaders/node_convert_from_int.osl
index 0e6ae711210..a59e025d822 100644
--- a/intern/cycles/kernel/shaders/node_convert_from_int.osl
+++ b/intern/cycles/kernel/shaders/node_convert_from_int.osl
@@ -16,20 +16,18 @@
#include "stdosl.h"
-shader node_convert_from_int(
- int value_int = 0,
- output string value_string = "",
- output float value_float = 0.0,
- output color value_color = 0.0,
- output vector value_vector = vector(0.0, 0.0, 0.0),
- output point value_point = point(0.0, 0.0, 0.0),
- output normal value_normal = normal(0.0, 0.0, 0.0))
+shader node_convert_from_int(int value_int = 0,
+ output string value_string = "",
+ output float value_float = 0.0,
+ output color value_color = 0.0,
+ output vector value_vector = vector(0.0, 0.0, 0.0),
+ output point value_point = point(0.0, 0.0, 0.0),
+ output normal value_normal = normal(0.0, 0.0, 0.0))
{
- float f = (float)value_int;
- value_float = f;
- value_color = color(f, f, f);
- value_vector = vector(f, f, f);
- value_point = point(f, f, f);
- value_normal = normal(f, f, f);
+ float f = (float)value_int;
+ value_float = f;
+ value_color = color(f, f, f);
+ value_vector = vector(f, f, f);
+ value_point = point(f, f, f);
+ value_normal = normal(f, f, f);
}
-
diff --git a/intern/cycles/kernel/shaders/node_convert_from_normal.osl b/intern/cycles/kernel/shaders/node_convert_from_normal.osl
index 7fffa7f6169..7bdd94d1941 100644
--- a/intern/cycles/kernel/shaders/node_convert_from_normal.osl
+++ b/intern/cycles/kernel/shaders/node_convert_from_normal.osl
@@ -16,19 +16,17 @@
#include "stdosl.h"
-shader node_convert_from_normal(
- normal value_normal = normal(0.0, 0.0, 0.0),
- output string value_string = "",
- output float value_float = 0.0,
- output int value_int = 0,
- output vector value_vector = vector(0.0, 0.0, 0.0),
- output color value_color = 0.0,
- output point value_point = point(0.0, 0.0, 0.0))
+shader node_convert_from_normal(normal value_normal = normal(0.0, 0.0, 0.0),
+ output string value_string = "",
+ output float value_float = 0.0,
+ output int value_int = 0,
+ output vector value_vector = vector(0.0, 0.0, 0.0),
+ output color value_color = 0.0,
+ output point value_point = point(0.0, 0.0, 0.0))
{
- value_float = (value_normal[0] + value_normal[1] + value_normal[2]) * (1.0 / 3.0);
- value_int = (int)((value_normal[0] + value_normal[1] + value_normal[2]) * (1.0 / 3.0));
- value_vector = vector(value_normal[0], value_normal[1], value_normal[2]);
- value_color = color(value_normal[0], value_normal[1], value_normal[2]);
- value_point = point(value_normal[0], value_normal[1], value_normal[2]);
+ value_float = (value_normal[0] + value_normal[1] + value_normal[2]) * (1.0 / 3.0);
+ value_int = (int)((value_normal[0] + value_normal[1] + value_normal[2]) * (1.0 / 3.0));
+ value_vector = vector(value_normal[0], value_normal[1], value_normal[2]);
+ value_color = color(value_normal[0], value_normal[1], value_normal[2]);
+ value_point = point(value_normal[0], value_normal[1], value_normal[2]);
}
-
diff --git a/intern/cycles/kernel/shaders/node_convert_from_point.osl b/intern/cycles/kernel/shaders/node_convert_from_point.osl
index 9e4930296bb..79c1719e7a7 100644
--- a/intern/cycles/kernel/shaders/node_convert_from_point.osl
+++ b/intern/cycles/kernel/shaders/node_convert_from_point.osl
@@ -16,19 +16,17 @@
#include "stdosl.h"
-shader node_convert_from_point(
- point value_point = point(0.0, 0.0, 0.0),
- output string value_string = "",
- output float value_float = 0.0,
- output int value_int = 0,
- output vector value_vector = vector(0.0, 0.0, 0.0),
- output color value_color = 0.0,
- output normal value_normal = normal(0.0, 0.0, 0.0))
+shader node_convert_from_point(point value_point = point(0.0, 0.0, 0.0),
+ output string value_string = "",
+ output float value_float = 0.0,
+ output int value_int = 0,
+ output vector value_vector = vector(0.0, 0.0, 0.0),
+ output color value_color = 0.0,
+ output normal value_normal = normal(0.0, 0.0, 0.0))
{
- value_float = (value_point[0] + value_point[1] + value_point[2]) * (1.0 / 3.0);
- value_int = (int)((value_normal[0] + value_normal[1] + value_normal[2]) * (1.0 / 3.0));
- value_vector = vector(value_point[0], value_point[1], value_point[2]);
- value_color = color(value_point[0], value_point[1], value_point[2]);
- value_normal = normal(value_point[0], value_point[1], value_point[2]);
+ value_float = (value_point[0] + value_point[1] + value_point[2]) * (1.0 / 3.0);
+ value_int = (int)((value_normal[0] + value_normal[1] + value_normal[2]) * (1.0 / 3.0));
+ value_vector = vector(value_point[0], value_point[1], value_point[2]);
+ value_color = color(value_point[0], value_point[1], value_point[2]);
+ value_normal = normal(value_point[0], value_point[1], value_point[2]);
}
-
diff --git a/intern/cycles/kernel/shaders/node_convert_from_string.osl b/intern/cycles/kernel/shaders/node_convert_from_string.osl
index cbc6653eada..48d894a6b3e 100644
--- a/intern/cycles/kernel/shaders/node_convert_from_string.osl
+++ b/intern/cycles/kernel/shaders/node_convert_from_string.osl
@@ -16,14 +16,12 @@
#include "stdosl.h"
-shader node_convert_from_string(
- string value_string = "",
- output color value_color = color(0.0, 0.0, 0.0),
- output float value_float = 0.0,
- output int value_int = 0,
- output vector value_vector = vector(0.0, 0.0, 0.0),
- output point value_point = point(0.0, 0.0, 0.0),
- output normal value_normal = normal(0.0, 0.0, 0.0))
+shader node_convert_from_string(string value_string = "",
+ output color value_color = color(0.0, 0.0, 0.0),
+ output float value_float = 0.0,
+ output int value_int = 0,
+ output vector value_vector = vector(0.0, 0.0, 0.0),
+ output point value_point = point(0.0, 0.0, 0.0),
+ output normal value_normal = normal(0.0, 0.0, 0.0))
{
}
-
diff --git a/intern/cycles/kernel/shaders/node_convert_from_vector.osl b/intern/cycles/kernel/shaders/node_convert_from_vector.osl
index 8bdca469b90..92ab2313bcb 100644
--- a/intern/cycles/kernel/shaders/node_convert_from_vector.osl
+++ b/intern/cycles/kernel/shaders/node_convert_from_vector.osl
@@ -16,19 +16,17 @@
#include "stdosl.h"
-shader node_convert_from_vector(
- vector value_vector = vector(0.0, 0.0, 0.0),
- output string value_string = "",
- output float value_float = 0.0,
- output int value_int = 0,
- output color value_color = color(0.0, 0.0, 0.0),
- output point value_point = point(0.0, 0.0, 0.0),
- output normal value_normal = normal(0.0, 0.0, 0.0))
+shader node_convert_from_vector(vector value_vector = vector(0.0, 0.0, 0.0),
+ output string value_string = "",
+ output float value_float = 0.0,
+ output int value_int = 0,
+ output color value_color = color(0.0, 0.0, 0.0),
+ output point value_point = point(0.0, 0.0, 0.0),
+ output normal value_normal = normal(0.0, 0.0, 0.0))
{
- value_float = (value_vector[0] + value_vector[1] + value_vector[2]) * (1.0 / 3.0);
- value_int = (int)((value_normal[0] + value_normal[1] + value_normal[2]) * (1.0 / 3.0));
- value_color = color(value_vector[0], value_vector[1], value_vector[2]);
- value_point = point(value_vector[0], value_vector[1], value_vector[2]);
- value_normal = normal(value_vector[0], value_vector[1], value_vector[2]);
+ value_float = (value_vector[0] + value_vector[1] + value_vector[2]) * (1.0 / 3.0);
+ value_int = (int)((value_normal[0] + value_normal[1] + value_normal[2]) * (1.0 / 3.0));
+ value_color = color(value_vector[0], value_vector[1], value_vector[2]);
+ value_point = point(value_vector[0], value_vector[1], value_vector[2]);
+ value_normal = normal(value_vector[0], value_vector[1], value_vector[2]);
}
-
diff --git a/intern/cycles/kernel/shaders/node_diffuse_bsdf.osl b/intern/cycles/kernel/shaders/node_diffuse_bsdf.osl
index 2bef2d65baa..bd5554b838a 100644
--- a/intern/cycles/kernel/shaders/node_diffuse_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_diffuse_bsdf.osl
@@ -16,15 +16,13 @@
#include "stdosl.h"
-shader node_diffuse_bsdf(
- color Color = 0.8,
- float Roughness = 0.0,
- normal Normal = N,
- output closure color BSDF = 0)
+shader node_diffuse_bsdf(color Color = 0.8,
+ float Roughness = 0.0,
+ normal Normal = N,
+ output closure color BSDF = 0)
{
- if (Roughness == 0.0)
- BSDF = Color * diffuse(Normal);
- else
- BSDF = Color * oren_nayar(Normal, Roughness);
+ if (Roughness == 0.0)
+ BSDF = Color * diffuse(Normal);
+ else
+ BSDF = Color * oren_nayar(Normal, Roughness);
}
-
diff --git a/intern/cycles/kernel/shaders/node_displacement.osl b/intern/cycles/kernel/shaders/node_displacement.osl
index 89f35841527..a1f3b7b7737 100644
--- a/intern/cycles/kernel/shaders/node_displacement.osl
+++ b/intern/cycles/kernel/shaders/node_displacement.osl
@@ -16,23 +16,21 @@
#include "stdosl.h"
-shader node_displacement(
- string space = "object",
- float Height = 0.0,
- float Midlevel = 0.5,
- float Scale = 1.0,
- normal Normal = N,
- output vector Displacement = vector(0.0, 0.0, 0.0))
+shader node_displacement(string space = "object",
+ float Height = 0.0,
+ float Midlevel = 0.5,
+ float Scale = 1.0,
+ normal Normal = N,
+ output vector Displacement = vector(0.0, 0.0, 0.0))
{
- Displacement = Normal;
- if(space == "object") {
- Displacement = transform("object", Displacement);
- }
+ Displacement = Normal;
+ if (space == "object") {
+ Displacement = transform("object", Displacement);
+ }
- Displacement = normalize(Displacement) * (Height - Midlevel) * Scale;
+ Displacement = normalize(Displacement) * (Height - Midlevel) * Scale;
- if(space == "object") {
- Displacement = transform("object", "world", Displacement);
- }
+ if (space == "object") {
+ Displacement = transform("object", "world", Displacement);
+ }
}
-
diff --git a/intern/cycles/kernel/shaders/node_emission.osl b/intern/cycles/kernel/shaders/node_emission.osl
index c36e2a4c0f3..57973f57ac6 100644
--- a/intern/cycles/kernel/shaders/node_emission.osl
+++ b/intern/cycles/kernel/shaders/node_emission.osl
@@ -16,11 +16,7 @@
#include "stdosl.h"
-shader node_emission(
- color Color = 0.8,
- float Strength = 1.0,
- output closure color Emission = 0)
+shader node_emission(color Color = 0.8, float Strength = 1.0, output closure color Emission = 0)
{
- Emission = (Strength * Color) * emission();
+ Emission = (Strength * Color) * emission();
}
-
diff --git a/intern/cycles/kernel/shaders/node_environment_texture.osl b/intern/cycles/kernel/shaders/node_environment_texture.osl
index 95d9d813969..eb32dad392f 100644
--- a/intern/cycles/kernel/shaders/node_environment_texture.osl
+++ b/intern/cycles/kernel/shaders/node_environment_texture.osl
@@ -19,63 +19,63 @@
vector environment_texture_direction_to_equirectangular(vector dir)
{
- float u = -atan2(dir[1], dir[0]) / (M_2PI) + 0.5;
- float v = atan2(dir[2], hypot(dir[0], dir[1])) / M_PI + 0.5;
+ float u = -atan2(dir[1], dir[0]) / (M_2PI) + 0.5;
+ float v = atan2(dir[2], hypot(dir[0], dir[1])) / M_PI + 0.5;
- return vector(u, v, 0.0);
+ return vector(u, v, 0.0);
}
vector environment_texture_direction_to_mirrorball(vector idir)
{
- vector dir = idir;
- dir[1] -= 1.0;
+ vector dir = idir;
+ dir[1] -= 1.0;
- float div = 2.0 * sqrt(max(-0.5 * dir[1], 0.0));
- if (div > 0.0)
- dir /= div;
+ float div = 2.0 * sqrt(max(-0.5 * dir[1], 0.0));
+ if (div > 0.0)
+ dir /= div;
- float u = 0.5 * (dir[0] + 1.0);
- float v = 0.5 * (dir[2] + 1.0);
+ float u = 0.5 * (dir[0] + 1.0);
+ float v = 0.5 * (dir[2] + 1.0);
- return vector(u, v, 0.0);
+ return vector(u, v, 0.0);
}
shader node_environment_texture(
- int use_mapping = 0,
- matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- vector Vector = P,
- string filename = "",
- string projection = "equirectangular",
- string interpolation = "linear",
- string color_space = "sRGB",
- int is_float = 1,
- int use_alpha = 1,
- output color Color = 0.0,
- output float Alpha = 1.0)
+ int use_mapping = 0,
+ matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+ vector Vector = P,
+ string filename = "",
+ string projection = "equirectangular",
+ string interpolation = "linear",
+ string color_space = "sRGB",
+ int is_float = 1,
+ int use_alpha = 1,
+ output color Color = 0.0,
+ output float Alpha = 1.0)
{
- vector p = Vector;
+ vector p = Vector;
- if (use_mapping)
- p = transform(mapping, p);
-
- p = normalize(p);
+ if (use_mapping)
+ p = transform(mapping, p);
- if (projection == "equirectangular")
- p = environment_texture_direction_to_equirectangular(p);
- else
- p = environment_texture_direction_to_mirrorball(p);
+ p = normalize(p);
- /* todo: use environment for better texture filtering of equirectangular */
- Color = (color)texture(filename, p[0], 1.0 - p[1], "wrap", "periodic", "interp", interpolation, "alpha", Alpha);
+ if (projection == "equirectangular")
+ p = environment_texture_direction_to_equirectangular(p);
+ else
+ p = environment_texture_direction_to_mirrorball(p);
- if (use_alpha) {
- Color = color_unpremultiply(Color, Alpha);
+ /* todo: use environment for better texture filtering of equirectangular */
+ Color = (color)texture(
+ filename, p[0], 1.0 - p[1], "wrap", "periodic", "interp", interpolation, "alpha", Alpha);
- if (!is_float)
- Color = min(Color, 1.0);
- }
+ if (use_alpha) {
+ Color = color_unpremultiply(Color, Alpha);
- if (color_space == "sRGB")
- Color = color_srgb_to_scene_linear(Color);
-}
+ if (!is_float)
+ Color = min(Color, 1.0);
+ }
+ if (color_space == "sRGB")
+ Color = color_srgb_to_scene_linear(Color);
+}
diff --git a/intern/cycles/kernel/shaders/node_fresnel.h b/intern/cycles/kernel/shaders/node_fresnel.h
index 40793479d8a..ade1d4c6207 100644
--- a/intern/cycles/kernel/shaders/node_fresnel.h
+++ b/intern/cycles/kernel/shaders/node_fresnel.h
@@ -32,33 +32,31 @@
float fresnel_dielectric_cos(float cosi, float eta)
{
- /* compute fresnel reflectance without explicitly computing
- * the refracted direction */
- float c = fabs(cosi);
- float g = eta * eta - 1 + c * c;
- float result;
+ /* compute fresnel reflectance without explicitly computing
+ * the refracted direction */
+ float c = fabs(cosi);
+ float g = eta * eta - 1 + c * c;
+ float result;
- if (g > 0) {
- g = sqrt(g);
- float A = (g - c) / (g + c);
- float B = (c * (g + c) - 1) / (c * (g - c) + 1);
- result = 0.5 * A * A * (1 + B * B);
- }
- else
- result = 1.0; /* TIR (no refracted component) */
+ if (g > 0) {
+ g = sqrt(g);
+ float A = (g - c) / (g + c);
+ float B = (c * (g + c) - 1) / (c * (g - c) + 1);
+ result = 0.5 * A * A * (1 + B * B);
+ }
+ else
+ result = 1.0; /* TIR (no refracted component) */
- return result;
+ return result;
}
color fresnel_conductor(float cosi, color eta, color k)
{
- color cosi2 = color(cosi * cosi);
- color one = color(1, 1, 1);
- color tmp_f = eta * eta + k * k;
- color tmp = tmp_f * cosi2;
- color Rparl2 = (tmp - (2.0 * eta * cosi) + one) /
- (tmp + (2.0 * eta * cosi) + one);
- color Rperp2 = (tmp_f - (2.0 * eta * cosi) + cosi2) /
- (tmp_f + (2.0 * eta * cosi) + cosi2);
- return (Rparl2 + Rperp2) * 0.5;
+ color cosi2 = color(cosi * cosi);
+ color one = color(1, 1, 1);
+ color tmp_f = eta * eta + k * k;
+ color tmp = tmp_f * cosi2;
+ color Rparl2 = (tmp - (2.0 * eta * cosi) + one) / (tmp + (2.0 * eta * cosi) + one);
+ color Rperp2 = (tmp_f - (2.0 * eta * cosi) + cosi2) / (tmp_f + (2.0 * eta * cosi) + cosi2);
+ return (Rparl2 + Rperp2) * 0.5;
}
diff --git a/intern/cycles/kernel/shaders/node_fresnel.osl b/intern/cycles/kernel/shaders/node_fresnel.osl
index 8bec7b432f5..89250db40f3 100644
--- a/intern/cycles/kernel/shaders/node_fresnel.osl
+++ b/intern/cycles/kernel/shaders/node_fresnel.osl
@@ -17,14 +17,10 @@
#include "stdosl.h"
#include "node_fresnel.h"
-shader node_fresnel(
- float IOR = 1.45,
- normal Normal = N,
- output float Fac = 0.0)
+shader node_fresnel(float IOR = 1.45, normal Normal = N, output float Fac = 0.0)
{
- float f = max(IOR, 1e-5);
- float eta = backfacing() ? 1.0 / f : f;
- float cosi = dot(I, Normal);
- Fac = fresnel_dielectric_cos(cosi, eta);
+ float f = max(IOR, 1e-5);
+ float eta = backfacing() ? 1.0 / f : f;
+ float cosi = dot(I, Normal);
+ Fac = fresnel_dielectric_cos(cosi, eta);
}
-
diff --git a/intern/cycles/kernel/shaders/node_gamma.osl b/intern/cycles/kernel/shaders/node_gamma.osl
index bc4c1b34266..9b9c17dc8af 100644
--- a/intern/cycles/kernel/shaders/node_gamma.osl
+++ b/intern/cycles/kernel/shaders/node_gamma.osl
@@ -16,10 +16,7 @@
#include "stdosl.h"
-shader node_gamma(
- color ColorIn = 0.8,
- float Gamma = 1.0,
- output color ColorOut = 0.0)
+shader node_gamma(color ColorIn = 0.8, float Gamma = 1.0, output color ColorOut = 0.0)
{
- ColorOut = pow(ColorIn, Gamma);
+ ColorOut = pow(ColorIn, Gamma);
}
diff --git a/intern/cycles/kernel/shaders/node_geometry.osl b/intern/cycles/kernel/shaders/node_geometry.osl
index b0bd7692489..b5c1c6611c1 100644
--- a/intern/cycles/kernel/shaders/node_geometry.osl
+++ b/intern/cycles/kernel/shaders/node_geometry.osl
@@ -16,55 +16,53 @@
#include "stdosl.h"
-shader node_geometry(
- normal NormalIn = N,
- string bump_offset = "center",
+shader node_geometry(normal NormalIn = N,
+ string bump_offset = "center",
- output point Position = point(0.0, 0.0, 0.0),
- output normal Normal = normal(0.0, 0.0, 0.0),
- output normal Tangent = normal(0.0, 0.0, 0.0),
- output normal TrueNormal = normal(0.0, 0.0, 0.0),
- output vector Incoming = vector(0.0, 0.0, 0.0),
- output point Parametric = point(0.0, 0.0, 0.0),
- output float Backfacing = 0.0,
- output float Pointiness = 0.0)
+ output point Position = point(0.0, 0.0, 0.0),
+ output normal Normal = normal(0.0, 0.0, 0.0),
+ output normal Tangent = normal(0.0, 0.0, 0.0),
+ output normal TrueNormal = normal(0.0, 0.0, 0.0),
+ output vector Incoming = vector(0.0, 0.0, 0.0),
+ output point Parametric = point(0.0, 0.0, 0.0),
+ output float Backfacing = 0.0,
+ output float Pointiness = 0.0)
{
- Position = P;
- Normal = NormalIn;
- TrueNormal = Ng;
- Incoming = I;
- Parametric = point(u, v, 0.0);
- Backfacing = backfacing();
+ Position = P;
+ Normal = NormalIn;
+ TrueNormal = Ng;
+ Incoming = I;
+ Parametric = point(u, v, 0.0);
+ Backfacing = backfacing();
- if (bump_offset == "dx") {
- Position += Dx(Position);
- Parametric += Dx(Parametric);
- }
- else if (bump_offset == "dy") {
- Position += Dy(Position);
- Parametric += Dy(Parametric);
- }
+ if (bump_offset == "dx") {
+ Position += Dx(Position);
+ Parametric += Dx(Parametric);
+ }
+ else if (bump_offset == "dy") {
+ Position += Dy(Position);
+ Parametric += Dy(Parametric);
+ }
- /* first try to get tangent attribute */
- point generated;
+ /* first try to get tangent attribute */
+ point generated;
- /* try to create spherical tangent from generated coordinates */
- if (getattribute("geom:generated", generated)) {
- normal data = normal(-(generated[1] - 0.5), (generated[0] - 0.5), 0.0);
- vector T = transform("object", "world", data);
- Tangent = cross(Normal, normalize(cross(T, Normal)));
- }
- else {
- /* otherwise use surface derivatives */
- Tangent = normalize(dPdu);
- }
+ /* try to create spherical tangent from generated coordinates */
+ if (getattribute("geom:generated", generated)) {
+ normal data = normal(-(generated[1] - 0.5), (generated[0] - 0.5), 0.0);
+ vector T = transform("object", "world", data);
+ Tangent = cross(Normal, normalize(cross(T, Normal)));
+ }
+ else {
+ /* otherwise use surface derivatives */
+ Tangent = normalize(dPdu);
+ }
- getattribute("geom:pointiness", Pointiness);
- if (bump_offset == "dx") {
- Pointiness += Dx(Pointiness);
- }
- else if (bump_offset == "dy") {
- Pointiness += Dy(Pointiness);
- }
+ getattribute("geom:pointiness", Pointiness);
+ if (bump_offset == "dx") {
+ Pointiness += Dx(Pointiness);
+ }
+ else if (bump_offset == "dy") {
+ Pointiness += Dy(Pointiness);
+ }
}
-
diff --git a/intern/cycles/kernel/shaders/node_glass_bsdf.osl b/intern/cycles/kernel/shaders/node_glass_bsdf.osl
index 2e713861c58..c0b8a002536 100644
--- a/intern/cycles/kernel/shaders/node_glass_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_glass_bsdf.osl
@@ -17,29 +17,27 @@
#include "stdosl.h"
#include "node_fresnel.h"
-shader node_glass_bsdf(
- color Color = 0.8,
- string distribution = "sharp",
- float Roughness = 0.2,
- float IOR = 1.45,
- normal Normal = N,
- output closure color BSDF = 0)
+shader node_glass_bsdf(color Color = 0.8,
+ string distribution = "sharp",
+ float Roughness = 0.2,
+ float IOR = 1.45,
+ normal Normal = N,
+ output closure color BSDF = 0)
{
- float f = max(IOR, 1e-5);
- float eta = backfacing() ? 1.0 / f : f;
- float cosi = dot(I, Normal);
- float Fr = fresnel_dielectric_cos(cosi, eta);
- float roughness = Roughness * Roughness;
+ float f = max(IOR, 1e-5);
+ float eta = backfacing() ? 1.0 / f : f;
+ float cosi = dot(I, Normal);
+ float Fr = fresnel_dielectric_cos(cosi, eta);
+ float roughness = Roughness * Roughness;
- if (distribution == "sharp")
- BSDF = Color * (Fr * reflection(Normal) + (1.0 - Fr) * refraction(Normal, eta));
- else if (distribution == "beckmann")
- BSDF = Color * (Fr * microfacet_beckmann(Normal, roughness) +
- (1.0 - Fr) * microfacet_beckmann_refraction(Normal, roughness, eta));
- else if (distribution == "Multiscatter GGX")
- BSDF = Color * microfacet_multi_ggx_glass(Normal, roughness, eta, Color);
- else if (distribution == "GGX")
- BSDF = Color * (Fr * microfacet_ggx(Normal, roughness) +
- (1.0 - Fr) * microfacet_ggx_refraction(Normal, roughness, eta));
+ if (distribution == "sharp")
+ BSDF = Color * (Fr * reflection(Normal) + (1.0 - Fr) * refraction(Normal, eta));
+ else if (distribution == "beckmann")
+ BSDF = Color * (Fr * microfacet_beckmann(Normal, roughness) +
+ (1.0 - Fr) * microfacet_beckmann_refraction(Normal, roughness, eta));
+ else if (distribution == "Multiscatter GGX")
+ BSDF = Color * microfacet_multi_ggx_glass(Normal, roughness, eta, Color);
+ else if (distribution == "GGX")
+ BSDF = Color * (Fr * microfacet_ggx(Normal, roughness) +
+ (1.0 - Fr) * microfacet_ggx_refraction(Normal, roughness, eta));
}
-
diff --git a/intern/cycles/kernel/shaders/node_glossy_bsdf.osl b/intern/cycles/kernel/shaders/node_glossy_bsdf.osl
index 7415211b56d..2d40ee8d3f6 100644
--- a/intern/cycles/kernel/shaders/node_glossy_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_glossy_bsdf.osl
@@ -17,25 +17,22 @@
#include "stdosl.h"
#include "node_fresnel.h"
-shader node_glossy_bsdf(
- color Color = 0.8,
- string distribution = "GGX",
- float Roughness = 0.2,
- normal Normal = N,
- output closure color BSDF = 0)
+shader node_glossy_bsdf(color Color = 0.8,
+ string distribution = "GGX",
+ float Roughness = 0.2,
+ normal Normal = N,
+ output closure color BSDF = 0)
{
- float roughness = Roughness * Roughness;
-
- if (distribution == "sharp")
- BSDF = Color * reflection(Normal);
- else if (distribution == "beckmann")
- BSDF = Color * microfacet_beckmann(Normal, roughness);
- else if (distribution == "GGX")
- BSDF = Color * microfacet_ggx(Normal, roughness);
- else if (distribution == "Multiscatter GGX")
- BSDF = Color * microfacet_multi_ggx(Normal, roughness, Color);
- else
- BSDF = Color * ashikhmin_shirley(Normal, vector(0, 0, 0), roughness, roughness);
+ float roughness = Roughness * Roughness;
+ if (distribution == "sharp")
+ BSDF = Color * reflection(Normal);
+ else if (distribution == "beckmann")
+ BSDF = Color * microfacet_beckmann(Normal, roughness);
+ else if (distribution == "GGX")
+ BSDF = Color * microfacet_ggx(Normal, roughness);
+ else if (distribution == "Multiscatter GGX")
+ BSDF = Color * microfacet_multi_ggx(Normal, roughness, Color);
+ else
+ BSDF = Color * ashikhmin_shirley(Normal, vector(0, 0, 0), roughness, roughness);
}
-
diff --git a/intern/cycles/kernel/shaders/node_gradient_texture.osl b/intern/cycles/kernel/shaders/node_gradient_texture.osl
index f458937a18f..52bf466673d 100644
--- a/intern/cycles/kernel/shaders/node_gradient_texture.osl
+++ b/intern/cycles/kernel/shaders/node_gradient_texture.osl
@@ -21,59 +21,58 @@
float gradient(point p, string type)
{
- float x, y, z;
-
- x = p[0];
- y = p[1];
- z = p[2];
+ float x, y, z;
- float result = 0.0;
+ x = p[0];
+ y = p[1];
+ z = p[2];
- if (type == "linear") {
- result = x;
- }
- else if (type == "quadratic") {
- float r = max(x, 0.0);
- result = r * r;
- }
- else if (type == "easing") {
- float r = min(max(x, 0.0), 1.0);
- float t = r * r;
-
- result = (3.0 * t - 2.0 * t * r);
- }
- else if (type == "diagonal") {
- result = (x + y) * 0.5;
- }
- else if (type == "radial") {
- result = atan2(y, x) / M_2PI + 0.5;
- }
- else {
- float r = max(1.0 - sqrt(x * x + y * y + z * z), 0.0);
+ float result = 0.0;
- if (type == "quadratic_sphere")
- result = r * r;
- else if (type == "spherical")
- result = r;
- }
+ if (type == "linear") {
+ result = x;
+ }
+ else if (type == "quadratic") {
+ float r = max(x, 0.0);
+ result = r * r;
+ }
+ else if (type == "easing") {
+ float r = min(max(x, 0.0), 1.0);
+ float t = r * r;
- return result;
+ result = (3.0 * t - 2.0 * t * r);
+ }
+ else if (type == "diagonal") {
+ result = (x + y) * 0.5;
+ }
+ else if (type == "radial") {
+ result = atan2(y, x) / M_2PI + 0.5;
+ }
+ else {
+ float r = max(1.0 - sqrt(x * x + y * y + z * z), 0.0);
+
+ if (type == "quadratic_sphere")
+ result = r * r;
+ else if (type == "spherical")
+ result = r;
+ }
+
+ return result;
}
shader node_gradient_texture(
- int use_mapping = 0,
- matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- string type = "linear",
- point Vector = P,
- output float Fac = 0.0,
- output color Color = 0.0)
+ int use_mapping = 0,
+ matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+ string type = "linear",
+ point Vector = P,
+ output float Fac = 0.0,
+ output color Color = 0.0)
{
- point p = Vector;
+ point p = Vector;
- if (use_mapping)
- p = transform(mapping, p);
+ if (use_mapping)
+ p = transform(mapping, p);
- Fac = gradient(p, type);
- Color = color(Fac, Fac, Fac);
+ Fac = gradient(p, type);
+ Color = color(Fac, Fac, Fac);
}
-
diff --git a/intern/cycles/kernel/shaders/node_hair_bsdf.osl b/intern/cycles/kernel/shaders/node_hair_bsdf.osl
index ef8f2fae894..bc912087666 100644
--- a/intern/cycles/kernel/shaders/node_hair_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_hair_bsdf.osl
@@ -18,41 +18,40 @@
#include "stdosl.h"
-shader node_hair_bsdf(
- color Color = 0.8,
- string component = "reflection",
- float Offset = 0.0,
- float RoughnessU = 0.1,
- float RoughnessV = 1.0,
- normal Tangent = normal(0, 0, 0),
- output closure color BSDF = 0)
+shader node_hair_bsdf(color Color = 0.8,
+ string component = "reflection",
+ float Offset = 0.0,
+ float RoughnessU = 0.1,
+ float RoughnessV = 1.0,
+ normal Tangent = normal(0, 0, 0),
+ output closure color BSDF = 0)
{
- float roughnessh = clamp(RoughnessU, 0.001, 1.0);
- float roughnessv = clamp(RoughnessV, 0.001, 1.0);
- float offset = -Offset;
+ float roughnessh = clamp(RoughnessU, 0.001, 1.0);
+ float roughnessv = clamp(RoughnessV, 0.001, 1.0);
+ float offset = -Offset;
- normal T;
- float IsCurve = 0;
- getattribute("geom:is_curve", IsCurve);
+ normal T;
+ float IsCurve = 0;
+ getattribute("geom:is_curve", IsCurve);
- if (isconnected(Tangent)) {
- T = Tangent;
- }
- else if(!IsCurve) {
- T = normalize(dPdv);
- offset = 0.0;
- }
- else {
- T = normalize(dPdu);
- }
+ if (isconnected(Tangent)) {
+ T = Tangent;
+ }
+ else if (!IsCurve) {
+ T = normalize(dPdv);
+ offset = 0.0;
+ }
+ else {
+ T = normalize(dPdu);
+ }
- if (backfacing() && IsCurve) {
- BSDF = transparent();
- }
- else {
- if (component == "reflection")
- BSDF = Color * hair_reflection(Ng, roughnessh, roughnessv, T, offset);
- else
- BSDF = Color * hair_transmission(Ng, roughnessh, roughnessv, T, offset);
- }
+ if (backfacing() && IsCurve) {
+ BSDF = transparent();
+ }
+ else {
+ if (component == "reflection")
+ BSDF = Color * hair_reflection(Ng, roughnessh, roughnessv, T, offset);
+ else
+ BSDF = Color * hair_transmission(Ng, roughnessh, roughnessv, T, offset);
+ }
}
diff --git a/intern/cycles/kernel/shaders/node_hair_info.osl b/intern/cycles/kernel/shaders/node_hair_info.osl
index 19216f67579..991a27c4103 100644
--- a/intern/cycles/kernel/shaders/node_hair_info.osl
+++ b/intern/cycles/kernel/shaders/node_hair_info.osl
@@ -16,17 +16,15 @@
#include "stdosl.h"
-shader node_hair_info(
- output float IsStrand = 0.0,
- output float Intercept = 0.0,
- output float Thickness = 0.0,
- output normal TangentNormal = N,
- output float Random = 0)
+shader node_hair_info(output float IsStrand = 0.0,
+ output float Intercept = 0.0,
+ output float Thickness = 0.0,
+ output normal TangentNormal = N,
+ output float Random = 0)
{
- getattribute("geom:is_curve", IsStrand);
- getattribute("geom:curve_intercept", Intercept);
- getattribute("geom:curve_thickness", Thickness);
- getattribute("geom:curve_tangent_normal", TangentNormal);
- getattribute("geom:curve_random", Random);
+ getattribute("geom:is_curve", IsStrand);
+ getattribute("geom:curve_intercept", Intercept);
+ getattribute("geom:curve_thickness", Thickness);
+ getattribute("geom:curve_tangent_normal", TangentNormal);
+ getattribute("geom:curve_random", Random);
}
-
diff --git a/intern/cycles/kernel/shaders/node_holdout.osl b/intern/cycles/kernel/shaders/node_holdout.osl
index 78a9f46fd15..b51bc0543a5 100644
--- a/intern/cycles/kernel/shaders/node_holdout.osl
+++ b/intern/cycles/kernel/shaders/node_holdout.osl
@@ -16,9 +16,6 @@
#include "stdosl.h"
-shader node_holdout(
- output closure color Holdout = holdout())
+shader node_holdout(output closure color Holdout = holdout())
{
-
}
-
diff --git a/intern/cycles/kernel/shaders/node_hsv.osl b/intern/cycles/kernel/shaders/node_hsv.osl
index d72a87a951f..30c56a20a92 100644
--- a/intern/cycles/kernel/shaders/node_hsv.osl
+++ b/intern/cycles/kernel/shaders/node_hsv.osl
@@ -17,28 +17,26 @@
#include "stdosl.h"
#include "node_color.h"
-shader node_hsv(
- float Hue = 0.5,
- float Saturation = 1.0,
- float Value = 1.0,
- float Fac = 0.5,
- color ColorIn = 0.0,
- output color ColorOut = 0.0)
+shader node_hsv(float Hue = 0.5,
+ float Saturation = 1.0,
+ float Value = 1.0,
+ float Fac = 0.5,
+ color ColorIn = 0.0,
+ output color ColorOut = 0.0)
{
- color Color = rgb_to_hsv(ColorIn);
+ color Color = rgb_to_hsv(ColorIn);
- // remember: fmod doesn't work for negative numbers
- Color[0] = fmod(Color[0] + Hue + 0.5, 1.0);
- Color[1] = clamp(Color[1] * Saturation, 0.0, 1.0);
- Color[2] *= Value;
+ // remember: fmod doesn't work for negative numbers
+ Color[0] = fmod(Color[0] + Hue + 0.5, 1.0);
+ Color[1] = clamp(Color[1] * Saturation, 0.0, 1.0);
+ Color[2] *= Value;
- Color = hsv_to_rgb(Color);
+ Color = hsv_to_rgb(Color);
- // Clamp color to prevent negative values cauzed by oversaturation.
- Color[0] = max(Color[0], 0.0);
- Color[1] = max(Color[1], 0.0);
- Color[2] = max(Color[2], 0.0);
+ // Clamp color to prevent negative values cauzed by oversaturation.
+ Color[0] = max(Color[0], 0.0);
+ Color[1] = max(Color[1], 0.0);
+ Color[2] = max(Color[2], 0.0);
- ColorOut = mix(ColorIn, Color, Fac);
+ ColorOut = mix(ColorIn, Color, Fac);
}
-
diff --git a/intern/cycles/kernel/shaders/node_ies_light.osl b/intern/cycles/kernel/shaders/node_ies_light.osl
index a0954e3a444..ea8c44e09de 100644
--- a/intern/cycles/kernel/shaders/node_ies_light.osl
+++ b/intern/cycles/kernel/shaders/node_ies_light.osl
@@ -19,24 +19,23 @@
/* IES Light */
-shader node_ies_light(
- int use_mapping = 0,
- matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- int slot = 0,
- float Strength = 1.0,
- point Vector = I,
- output float Fac = 0.0)
+shader node_ies_light(int use_mapping = 0,
+ matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+ int slot = 0,
+ float Strength = 1.0,
+ point Vector = I,
+ output float Fac = 0.0)
{
- point p = Vector;
+ point p = Vector;
- if (use_mapping) {
- p = transform(mapping, p);
- }
+ if (use_mapping) {
+ p = transform(mapping, p);
+ }
- p = normalize(p);
+ p = normalize(p);
- float v_angle = acos(-p[2]);
- float h_angle = atan2(p[0], p[1]) + M_PI;
+ float v_angle = acos(-p[2]);
+ float h_angle = atan2(p[0], p[1]) + M_PI;
- Fac = Strength * texture(format("@l%d", slot), h_angle, v_angle);
+ Fac = Strength * texture(format("@l%d", slot), h_angle, v_angle);
}
diff --git a/intern/cycles/kernel/shaders/node_image_texture.osl b/intern/cycles/kernel/shaders/node_image_texture.osl
index 7cd2922dd4f..df5eda39985 100644
--- a/intern/cycles/kernel/shaders/node_image_texture.osl
+++ b/intern/cycles/kernel/shaders/node_image_texture.osl
@@ -19,217 +19,217 @@
point texco_remap_square(point co)
{
- return (co - point(0.5, 0.5, 0.5)) * 2.0;
+ return (co - point(0.5, 0.5, 0.5)) * 2.0;
}
point map_to_tube(vector dir)
{
- float u, v;
- v = (dir[2] + 1.0) * 0.5;
- float len = sqrt(dir[0] * dir[0] + dir[1] * dir[1]);
- if (len > 0.0) {
- u = (1.0 - (atan2(dir[0] / len, dir[1] / len) / M_PI)) * 0.5;
- }
- else {
- v = u = 0.0; /* To avoid un-initialized variables. */
- }
- return point(u, v, 0.0);
+ float u, v;
+ v = (dir[2] + 1.0) * 0.5;
+ float len = sqrt(dir[0] * dir[0] + dir[1] * dir[1]);
+ if (len > 0.0) {
+ u = (1.0 - (atan2(dir[0] / len, dir[1] / len) / M_PI)) * 0.5;
+ }
+ else {
+ v = u = 0.0; /* To avoid un-initialized variables. */
+ }
+ return point(u, v, 0.0);
}
point map_to_sphere(vector dir)
{
- float len = length(dir);
- float v, u;
- if (len > 0.0) {
- if (dir[0] == 0.0 && dir[1] == 0.0) {
- u = 0.0; /* Othwise domain error. */
- }
- else {
- u = (1.0 - atan2(dir[0], dir[1]) / M_PI) / 2.0;
- }
- v = 1.0 - acos(dir[2] / len) / M_PI;
- }
- else {
- v = u = 0.0; /* To avoid un-initialized variables. */
- }
- return point(u, v, 0.0);
+ float len = length(dir);
+ float v, u;
+ if (len > 0.0) {
+ if (dir[0] == 0.0 && dir[1] == 0.0) {
+ u = 0.0; /* Othwise domain error. */
+ }
+ else {
+ u = (1.0 - atan2(dir[0], dir[1]) / M_PI) / 2.0;
+ }
+ v = 1.0 - acos(dir[2] / len) / M_PI;
+ }
+ else {
+ v = u = 0.0; /* To avoid un-initialized variables. */
+ }
+ return point(u, v, 0.0);
}
color image_texture_lookup(string filename,
string color_space,
- float u, float v,
+ float u,
+ float v,
output float Alpha,
int use_alpha,
int is_float,
string interpolation,
string extension)
{
- color rgb = (color)texture(filename, u, 1.0 - v, "wrap", extension, "interp", interpolation, "alpha", Alpha);
+ color rgb = (color)texture(
+ filename, u, 1.0 - v, "wrap", extension, "interp", interpolation, "alpha", Alpha);
- if (use_alpha) {
- rgb = color_unpremultiply(rgb, Alpha);
-
- if (!is_float)
- rgb = min(rgb, 1.0);
- }
+ if (use_alpha) {
+ rgb = color_unpremultiply(rgb, Alpha);
- if (color_space == "sRGB") {
- rgb = color_srgb_to_scene_linear(rgb);
- }
+ if (!is_float)
+ rgb = min(rgb, 1.0);
+ }
- return rgb;
+ if (color_space == "sRGB") {
+ rgb = color_srgb_to_scene_linear(rgb);
+ }
+
+ return rgb;
}
-shader node_image_texture(
- int use_mapping = 0,
- matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- point Vector = P,
- string filename = "",
- string color_space = "sRGB",
- string projection = "flat",
- string interpolation = "smartcubic",
- string extension = "periodic",
- float projection_blend = 0.0,
- int is_float = 1,
- int use_alpha = 1,
- output color Color = 0.0,
- output float Alpha = 1.0)
+shader node_image_texture(int use_mapping = 0,
+ matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+ point Vector = P,
+ string filename = "",
+ string color_space = "sRGB",
+ string projection = "flat",
+ string interpolation = "smartcubic",
+ string extension = "periodic",
+ float projection_blend = 0.0,
+ int is_float = 1,
+ int use_alpha = 1,
+ output color Color = 0.0,
+ output float Alpha = 1.0)
{
- point p = Vector;
-
- if (use_mapping)
- p = transform(mapping, p);
-
- if (projection == "flat") {
- Color = image_texture_lookup(filename,
- color_space,
- p[0], p[1],
- Alpha,
- use_alpha,
- is_float,
- interpolation,
- extension);
- }
- else if (projection == "box") {
- /* object space normal */
- vector Nob = transform("world", "object", N);
-
- /* project from direction vector to barycentric coordinates in triangles */
- Nob = vector(fabs(Nob[0]), fabs(Nob[1]), fabs(Nob[2]));
- Nob /= (Nob[0] + Nob[1] + Nob[2]);
-
- /* basic idea is to think of this as a triangle, each corner representing
- * one of the 3 faces of the cube. in the corners we have single textures,
- * in between we blend between two textures, and in the middle we a blend
- * between three textures.
- *
- * the Nxyz values are the barycentric coordinates in an equilateral
- * triangle, which in case of blending, in the middle has a smaller
- * equilateral triangle where 3 textures blend. this divides things into
- * 7 zones, with an if () test for each zone */
-
- vector weight = vector(0.0, 0.0, 0.0);
- float blend = projection_blend;
- float limit = 0.5 * (1.0 + blend);
-
- /* first test for corners with single texture */
- if (Nob[0] > limit * (Nob[0] + Nob[1]) && Nob[0] > limit * (Nob[0] + Nob[2])) {
- weight[0] = 1.0;
- }
- else if (Nob[1] > limit * (Nob[0] + Nob[1]) && Nob[1] > limit * (Nob[1] + Nob[2])) {
- weight[1] = 1.0;
- }
- else if (Nob[2] > limit * (Nob[0] + Nob[2]) && Nob[2] > limit * (Nob[1] + Nob[2])) {
- weight[2] = 1.0;
- }
- else if (blend > 0.0) {
- /* in case of blending, test for mixes between two textures */
- if (Nob[2] < (1.0 - limit) * (Nob[1] + Nob[0])) {
- weight[0] = Nob[0] / (Nob[0] + Nob[1]);
- weight[0] = clamp((weight[0] - 0.5 * (1.0 - blend)) / blend, 0.0, 1.0);
- weight[1] = 1.0 - weight[0];
- }
- else if (Nob[0] < (1.0 - limit) * (Nob[1] + Nob[2])) {
- weight[1] = Nob[1] / (Nob[1] + Nob[2]);
- weight[1] = clamp((weight[1] - 0.5 * (1.0 - blend)) / blend, 0.0, 1.0);
- weight[2] = 1.0 - weight[1];
- }
- else if (Nob[1] < (1.0 - limit) * (Nob[0] + Nob[2])) {
- weight[0] = Nob[0] / (Nob[0] + Nob[2]);
- weight[0] = clamp((weight[0] - 0.5 * (1.0 - blend)) / blend, 0.0, 1.0);
- weight[2] = 1.0 - weight[0];
- }
- else {
- /* last case, we have a mix between three */
- weight[0] = ((2.0 - limit) * Nob[0] + (limit - 1.0)) / (2.0 * limit - 1.0);
- weight[1] = ((2.0 - limit) * Nob[1] + (limit - 1.0)) / (2.0 * limit - 1.0);
- weight[2] = ((2.0 - limit) * Nob[2] + (limit - 1.0)) / (2.0 * limit - 1.0);
- }
- }
- else {
- /* Desperate mode, no valid choice anyway, fallback to one side.*/
- weight[0] = 1.0;
- }
-
- Color = color(0.0, 0.0, 0.0);
- Alpha = 0.0;
-
- float tmp_alpha;
-
- if (weight[0] > 0.0) {
- Color += weight[0] * image_texture_lookup(filename,
- color_space,
- p[1], p[2],
- tmp_alpha,
- use_alpha,
- is_float,
- interpolation,
- extension);
- Alpha += weight[0] * tmp_alpha;
- }
- if (weight[1] > 0.0) {
- Color += weight[1] * image_texture_lookup(filename,
- color_space,
- p[0], p[2],
- tmp_alpha,
- use_alpha,
- is_float,
- interpolation,
- extension);
- Alpha += weight[1] * tmp_alpha;
- }
- if (weight[2] > 0.0) {
- Color += weight[2] * image_texture_lookup(filename,
- color_space,
- p[1], p[0],
- tmp_alpha,
- use_alpha,
- is_float,
- interpolation,
- extension);
- Alpha += weight[2] * tmp_alpha;
- }
- }
- else if (projection == "sphere") {
- point projected = map_to_sphere(texco_remap_square(p));
- Color = image_texture_lookup(filename,
- color_space,
- projected[0], projected[1],
- Alpha,
- use_alpha,
- is_float,
- interpolation,
- extension);
- }
- else if (projection == "tube") {
- point projected = map_to_tube(texco_remap_square(p));
- Color = image_texture_lookup(filename,
- color_space,
- projected[0], projected[1],
- Alpha,
- use_alpha,
- is_float,
- interpolation,
- extension);
- }
+ point p = Vector;
+
+ if (use_mapping)
+ p = transform(mapping, p);
+
+ if (projection == "flat") {
+ Color = image_texture_lookup(
+ filename, color_space, p[0], p[1], Alpha, use_alpha, is_float, interpolation, extension);
+ }
+ else if (projection == "box") {
+ /* object space normal */
+ vector Nob = transform("world", "object", N);
+
+ /* project from direction vector to barycentric coordinates in triangles */
+ Nob = vector(fabs(Nob[0]), fabs(Nob[1]), fabs(Nob[2]));
+ Nob /= (Nob[0] + Nob[1] + Nob[2]);
+
+ /* basic idea is to think of this as a triangle, each corner representing
+ * one of the 3 faces of the cube. in the corners we have single textures,
+ * in between we blend between two textures, and in the middle we a blend
+ * between three textures.
+ *
+ * the Nxyz values are the barycentric coordinates in an equilateral
+ * triangle, which in case of blending, in the middle has a smaller
+ * equilateral triangle where 3 textures blend. this divides things into
+ * 7 zones, with an if () test for each zone */
+
+ vector weight = vector(0.0, 0.0, 0.0);
+ float blend = projection_blend;
+ float limit = 0.5 * (1.0 + blend);
+
+ /* first test for corners with single texture */
+ if (Nob[0] > limit * (Nob[0] + Nob[1]) && Nob[0] > limit * (Nob[0] + Nob[2])) {
+ weight[0] = 1.0;
+ }
+ else if (Nob[1] > limit * (Nob[0] + Nob[1]) && Nob[1] > limit * (Nob[1] + Nob[2])) {
+ weight[1] = 1.0;
+ }
+ else if (Nob[2] > limit * (Nob[0] + Nob[2]) && Nob[2] > limit * (Nob[1] + Nob[2])) {
+ weight[2] = 1.0;
+ }
+ else if (blend > 0.0) {
+ /* in case of blending, test for mixes between two textures */
+ if (Nob[2] < (1.0 - limit) * (Nob[1] + Nob[0])) {
+ weight[0] = Nob[0] / (Nob[0] + Nob[1]);
+ weight[0] = clamp((weight[0] - 0.5 * (1.0 - blend)) / blend, 0.0, 1.0);
+ weight[1] = 1.0 - weight[0];
+ }
+ else if (Nob[0] < (1.0 - limit) * (Nob[1] + Nob[2])) {
+ weight[1] = Nob[1] / (Nob[1] + Nob[2]);
+ weight[1] = clamp((weight[1] - 0.5 * (1.0 - blend)) / blend, 0.0, 1.0);
+ weight[2] = 1.0 - weight[1];
+ }
+ else if (Nob[1] < (1.0 - limit) * (Nob[0] + Nob[2])) {
+ weight[0] = Nob[0] / (Nob[0] + Nob[2]);
+ weight[0] = clamp((weight[0] - 0.5 * (1.0 - blend)) / blend, 0.0, 1.0);
+ weight[2] = 1.0 - weight[0];
+ }
+ else {
+ /* last case, we have a mix between three */
+ weight[0] = ((2.0 - limit) * Nob[0] + (limit - 1.0)) / (2.0 * limit - 1.0);
+ weight[1] = ((2.0 - limit) * Nob[1] + (limit - 1.0)) / (2.0 * limit - 1.0);
+ weight[2] = ((2.0 - limit) * Nob[2] + (limit - 1.0)) / (2.0 * limit - 1.0);
+ }
+ }
+ else {
+ /* Desperate mode, no valid choice anyway, fallback to one side.*/
+ weight[0] = 1.0;
+ }
+
+ Color = color(0.0, 0.0, 0.0);
+ Alpha = 0.0;
+
+ float tmp_alpha;
+
+ if (weight[0] > 0.0) {
+ Color += weight[0] * image_texture_lookup(filename,
+ color_space,
+ p[1],
+ p[2],
+ tmp_alpha,
+ use_alpha,
+ is_float,
+ interpolation,
+ extension);
+ Alpha += weight[0] * tmp_alpha;
+ }
+ if (weight[1] > 0.0) {
+ Color += weight[1] * image_texture_lookup(filename,
+ color_space,
+ p[0],
+ p[2],
+ tmp_alpha,
+ use_alpha,
+ is_float,
+ interpolation,
+ extension);
+ Alpha += weight[1] * tmp_alpha;
+ }
+ if (weight[2] > 0.0) {
+ Color += weight[2] * image_texture_lookup(filename,
+ color_space,
+ p[1],
+ p[0],
+ tmp_alpha,
+ use_alpha,
+ is_float,
+ interpolation,
+ extension);
+ Alpha += weight[2] * tmp_alpha;
+ }
+ }
+ else if (projection == "sphere") {
+ point projected = map_to_sphere(texco_remap_square(p));
+ Color = image_texture_lookup(filename,
+ color_space,
+ projected[0],
+ projected[1],
+ Alpha,
+ use_alpha,
+ is_float,
+ interpolation,
+ extension);
+ }
+ else if (projection == "tube") {
+ point projected = map_to_tube(texco_remap_square(p));
+ Color = image_texture_lookup(filename,
+ color_space,
+ projected[0],
+ projected[1],
+ Alpha,
+ use_alpha,
+ is_float,
+ interpolation,
+ extension);
+ }
}
diff --git a/intern/cycles/kernel/shaders/node_invert.osl b/intern/cycles/kernel/shaders/node_invert.osl
index b33b0a43d63..c7d41e4e129 100644
--- a/intern/cycles/kernel/shaders/node_invert.osl
+++ b/intern/cycles/kernel/shaders/node_invert.osl
@@ -16,12 +16,8 @@
#include "stdosl.h"
-shader node_invert(
- float Fac = 1.0,
- color ColorIn = 0.8,
- output color ColorOut = 0.8)
+shader node_invert(float Fac = 1.0, color ColorIn = 0.8, output color ColorOut = 0.8)
{
- color ColorInv = color(1.0) - ColorIn;
- ColorOut = mix(ColorIn, ColorInv, Fac);
+ color ColorInv = color(1.0) - ColorIn;
+ ColorOut = mix(ColorIn, ColorInv, Fac);
}
-
diff --git a/intern/cycles/kernel/shaders/node_layer_weight.osl b/intern/cycles/kernel/shaders/node_layer_weight.osl
index f583df25773..7c46f28b41b 100644
--- a/intern/cycles/kernel/shaders/node_layer_weight.osl
+++ b/intern/cycles/kernel/shaders/node_layer_weight.osl
@@ -17,29 +17,28 @@
#include "stdosl.h"
#include "node_fresnel.h"
-shader node_layer_weight(
- float Blend = 0.5,
- normal Normal = N,
- output float Fresnel = 0.0,
- output float Facing = 0.0)
+shader node_layer_weight(float Blend = 0.5,
+ normal Normal = N,
+ output float Fresnel = 0.0,
+ output float Facing = 0.0)
{
- float blend = Blend;
- float cosi = dot(I, Normal);
+ float blend = Blend;
+ float cosi = dot(I, Normal);
- /* Fresnel */
- float eta = max(1.0 - Blend, 1e-5);
- eta = backfacing() ? eta : 1.0 / eta;
- Fresnel = fresnel_dielectric_cos(cosi, eta);
+ /* Fresnel */
+ float eta = max(1.0 - Blend, 1e-5);
+ eta = backfacing() ? eta : 1.0 / eta;
+ Fresnel = fresnel_dielectric_cos(cosi, eta);
- /* Facing */
- Facing = fabs(cosi);
+ /* Facing */
+ Facing = fabs(cosi);
- if (blend != 0.5) {
- blend = clamp(blend, 0.0, 1.0 - 1e-5);
- blend = (blend < 0.5) ? 2.0 * blend : 0.5 / (1.0 - blend);
+ if (blend != 0.5) {
+ blend = clamp(blend, 0.0, 1.0 - 1e-5);
+ blend = (blend < 0.5) ? 2.0 * blend : 0.5 / (1.0 - blend);
- Facing = pow(Facing, blend);
- }
+ Facing = pow(Facing, blend);
+ }
- Facing = 1.0 - Facing;
+ Facing = 1.0 - Facing;
}
diff --git a/intern/cycles/kernel/shaders/node_light_falloff.osl b/intern/cycles/kernel/shaders/node_light_falloff.osl
index a594e33d643..d0d7dd9c5aa 100644
--- a/intern/cycles/kernel/shaders/node_light_falloff.osl
+++ b/intern/cycles/kernel/shaders/node_light_falloff.osl
@@ -16,29 +16,27 @@
#include "stdosl.h"
-shader node_light_falloff(
- float Strength = 0.0,
- float Smooth = 0.0,
- output float Quadratic = 0.0,
- output float Linear = 0.0,
- output float Constant = 0.0)
+shader node_light_falloff(float Strength = 0.0,
+ float Smooth = 0.0,
+ output float Quadratic = 0.0,
+ output float Linear = 0.0,
+ output float Constant = 0.0)
{
- float ray_length = 0.0;
- float strength = Strength;
- getattribute("path:ray_length", ray_length);
+ float ray_length = 0.0;
+ float strength = Strength;
+ getattribute("path:ray_length", ray_length);
- if (Smooth > 0.0) {
- float squared = ray_length * ray_length;
- strength *= squared / (Smooth + squared);
- }
+ if (Smooth > 0.0) {
+ float squared = ray_length * ray_length;
+ strength *= squared / (Smooth + squared);
+ }
- /* Quadratic */
- Quadratic = strength;
-
- /* Linear */
- Linear = (strength * ray_length);
+ /* Quadratic */
+ Quadratic = strength;
- /* Constant */
- Constant = (strength * ray_length * ray_length);
-}
+ /* Linear */
+ Linear = (strength * ray_length);
+ /* Constant */
+ Constant = (strength * ray_length * ray_length);
+}
diff --git a/intern/cycles/kernel/shaders/node_light_path.osl b/intern/cycles/kernel/shaders/node_light_path.osl
index 64fe4c20132..c4a3624a67f 100644
--- a/intern/cycles/kernel/shaders/node_light_path.osl
+++ b/intern/cycles/kernel/shaders/node_light_path.osl
@@ -16,51 +16,49 @@
#include "stdosl.h"
-shader node_light_path(
- output float IsCameraRay = 0.0,
- output float IsShadowRay = 0.0,
- output float IsDiffuseRay = 0.0,
- output float IsGlossyRay = 0.0,
- output float IsSingularRay = 0.0,
- output float IsReflectionRay = 0.0,
- output float IsTransmissionRay = 0.0,
- output float IsVolumeScatterRay = 0.0,
- output float RayLength = 0.0,
- output float RayDepth = 0.0,
- output float DiffuseDepth = 0.0,
- output float GlossyDepth = 0.0,
- output float TransparentDepth = 0.0,
- output float TransmissionDepth = 0.0)
+shader node_light_path(output float IsCameraRay = 0.0,
+ output float IsShadowRay = 0.0,
+ output float IsDiffuseRay = 0.0,
+ output float IsGlossyRay = 0.0,
+ output float IsSingularRay = 0.0,
+ output float IsReflectionRay = 0.0,
+ output float IsTransmissionRay = 0.0,
+ output float IsVolumeScatterRay = 0.0,
+ output float RayLength = 0.0,
+ output float RayDepth = 0.0,
+ output float DiffuseDepth = 0.0,
+ output float GlossyDepth = 0.0,
+ output float TransparentDepth = 0.0,
+ output float TransmissionDepth = 0.0)
{
- IsCameraRay = raytype("camera");
- IsShadowRay = raytype("shadow");
- IsDiffuseRay = raytype("diffuse");
- IsGlossyRay = raytype("glossy");
- IsSingularRay = raytype("singular");
- IsReflectionRay = raytype("reflection");
- IsTransmissionRay = raytype("refraction");
- IsVolumeScatterRay = raytype("volume_scatter");
+ IsCameraRay = raytype("camera");
+ IsShadowRay = raytype("shadow");
+ IsDiffuseRay = raytype("diffuse");
+ IsGlossyRay = raytype("glossy");
+ IsSingularRay = raytype("singular");
+ IsReflectionRay = raytype("reflection");
+ IsTransmissionRay = raytype("refraction");
+ IsVolumeScatterRay = raytype("volume_scatter");
- getattribute("path:ray_length", RayLength);
+ getattribute("path:ray_length", RayLength);
- int ray_depth;
- getattribute("path:ray_depth", ray_depth);
- RayDepth = (float)ray_depth;
+ int ray_depth;
+ getattribute("path:ray_depth", ray_depth);
+ RayDepth = (float)ray_depth;
- int diffuse_depth;
- getattribute("path:diffuse_depth", diffuse_depth);
- DiffuseDepth = (float)diffuse_depth;
+ int diffuse_depth;
+ getattribute("path:diffuse_depth", diffuse_depth);
+ DiffuseDepth = (float)diffuse_depth;
- int glossy_depth;
- getattribute("path:glossy_depth", glossy_depth);
- GlossyDepth = (float)glossy_depth;
+ int glossy_depth;
+ getattribute("path:glossy_depth", glossy_depth);
+ GlossyDepth = (float)glossy_depth;
- int transparent_depth;
- getattribute("path:transparent_depth", transparent_depth);
- TransparentDepth = (float)transparent_depth;
+ int transparent_depth;
+ getattribute("path:transparent_depth", transparent_depth);
+ TransparentDepth = (float)transparent_depth;
- int transmission_depth;
- getattribute("path:transmission_depth", transmission_depth);
- TransmissionDepth = (float)transmission_depth;
+ int transmission_depth;
+ getattribute("path:transmission_depth", transmission_depth);
+ TransmissionDepth = (float)transmission_depth;
}
-
diff --git a/intern/cycles/kernel/shaders/node_magic_texture.osl b/intern/cycles/kernel/shaders/node_magic_texture.osl
index 8d6af391e04..aa700e575ef 100644
--- a/intern/cycles/kernel/shaders/node_magic_texture.osl
+++ b/intern/cycles/kernel/shaders/node_magic_texture.osl
@@ -21,91 +21,89 @@
color magic(point p, int n, float distortion)
{
- float dist = distortion;
-
- float x = sin(( p[0] + p[1] + p[2]) * 5.0);
- float y = cos((-p[0] + p[1] - p[2]) * 5.0);
- float z = -cos((-p[0] - p[1] + p[2]) * 5.0);
-
- if (n > 0) {
- x *= dist;
- y *= dist;
- z *= dist;
- y = -cos(x - y + z);
- y *= dist;
-
- if (n > 1) {
- x = cos(x - y - z);
- x *= dist;
-
- if (n > 2) {
- z = sin(-x - y - z);
- z *= dist;
-
- if (n > 3) {
- x = -cos(-x + y - z);
- x *= dist;
-
- if (n > 4) {
- y = -sin(-x + y + z);
- y *= dist;
-
- if (n > 5) {
- y = -cos(-x + y + z);
- y *= dist;
-
- if (n > 6) {
- x = cos(x + y + z);
- x *= dist;
-
- if (n > 7) {
- z = sin(x + y - z);
- z *= dist;
-
- if (n > 8) {
- x = -cos(-x - y + z);
- x *= dist;
-
- if (n > 9) {
- y = -sin(x - y + z);
- y *= dist;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- if (dist != 0.0) {
- dist *= 2.0;
- x /= dist;
- y /= dist;
- z /= dist;
- }
-
- return color(0.5 - x, 0.5 - y, 0.5 - z);
+ float dist = distortion;
+
+ float x = sin((p[0] + p[1] + p[2]) * 5.0);
+ float y = cos((-p[0] + p[1] - p[2]) * 5.0);
+ float z = -cos((-p[0] - p[1] + p[2]) * 5.0);
+
+ if (n > 0) {
+ x *= dist;
+ y *= dist;
+ z *= dist;
+ y = -cos(x - y + z);
+ y *= dist;
+
+ if (n > 1) {
+ x = cos(x - y - z);
+ x *= dist;
+
+ if (n > 2) {
+ z = sin(-x - y - z);
+ z *= dist;
+
+ if (n > 3) {
+ x = -cos(-x + y - z);
+ x *= dist;
+
+ if (n > 4) {
+ y = -sin(-x + y + z);
+ y *= dist;
+
+ if (n > 5) {
+ y = -cos(-x + y + z);
+ y *= dist;
+
+ if (n > 6) {
+ x = cos(x + y + z);
+ x *= dist;
+
+ if (n > 7) {
+ z = sin(x + y - z);
+ z *= dist;
+
+ if (n > 8) {
+ x = -cos(-x - y + z);
+ x *= dist;
+
+ if (n > 9) {
+ y = -sin(x - y + z);
+ y *= dist;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (dist != 0.0) {
+ dist *= 2.0;
+ x /= dist;
+ y /= dist;
+ z /= dist;
+ }
+
+ return color(0.5 - x, 0.5 - y, 0.5 - z);
}
-shader node_magic_texture(
- int use_mapping = 0,
- matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- int depth = 2,
- float Distortion = 5.0,
- float Scale = 5.0,
- point Vector = P,
- output float Fac = 0.0,
- output color Color = 0.0)
+shader node_magic_texture(int use_mapping = 0,
+ matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+ int depth = 2,
+ float Distortion = 5.0,
+ float Scale = 5.0,
+ point Vector = P,
+ output float Fac = 0.0,
+ output color Color = 0.0)
{
- point p = Vector;
+ point p = Vector;
- if (use_mapping)
- p = transform(mapping, p);
+ if (use_mapping)
+ p = transform(mapping, p);
- Color = magic(p * Scale, depth, Distortion);
- Fac = (Color[0] + Color[1] + Color[2]) * (1.0 / 3.0);
+ Color = magic(p * Scale, depth, Distortion);
+ Fac = (Color[0] + Color[1] + Color[2]) * (1.0 / 3.0);
}
-
diff --git a/intern/cycles/kernel/shaders/node_mapping.osl b/intern/cycles/kernel/shaders/node_mapping.osl
index 69106957ee4..f5cc2d1c5dd 100644
--- a/intern/cycles/kernel/shaders/node_mapping.osl
+++ b/intern/cycles/kernel/shaders/node_mapping.osl
@@ -16,18 +16,17 @@
#include "stdosl.h"
-shader node_mapping(
- matrix Matrix = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- point mapping_min = point(0.0, 0.0, 0.0),
- point mapping_max = point(0.0, 0.0, 0.0),
- int use_minmax = 0,
- point VectorIn = point(0.0, 0.0, 0.0),
- output point VectorOut = point(0.0, 0.0, 0.0))
+shader node_mapping(matrix Matrix = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+ point mapping_min = point(0.0, 0.0, 0.0),
+ point mapping_max = point(0.0, 0.0, 0.0),
+ int use_minmax = 0,
+ point VectorIn = point(0.0, 0.0, 0.0),
+ output point VectorOut = point(0.0, 0.0, 0.0))
{
- point p = transform(Matrix, VectorIn);
+ point p = transform(Matrix, VectorIn);
- if (use_minmax)
- p = min(max(mapping_min, p), mapping_max);
-
- VectorOut = p;
+ if (use_minmax)
+ p = min(max(mapping_min, p), mapping_max);
+
+ VectorOut = p;
}
diff --git a/intern/cycles/kernel/shaders/node_math.osl b/intern/cycles/kernel/shaders/node_math.osl
index aa9f6e671c3..8830339e05f 100644
--- a/intern/cycles/kernel/shaders/node_math.osl
+++ b/intern/cycles/kernel/shaders/node_math.osl
@@ -18,107 +18,105 @@
float safe_divide(float a, float b)
{
- float result;
+ float result;
- if (b == 0.0)
- result = 0.0;
- else
- result = a / b;
-
- return result;
+ if (b == 0.0)
+ result = 0.0;
+ else
+ result = a / b;
+
+ return result;
}
float safe_modulo(float a, float b)
{
- float result;
+ float result;
+
+ if (b == 0.0)
+ result = 0.0;
+ else
+ result = fmod(a, b);
- if (b == 0.0)
- result = 0.0;
- else
- result = fmod(a, b);
-
- return result;
+ return result;
}
float safe_sqrt(float a)
{
- float result;
+ float result;
- if (a > 0.0)
- result = sqrt(a);
- else
- result = 0.0;
+ if (a > 0.0)
+ result = sqrt(a);
+ else
+ result = 0.0;
- return result;
+ return result;
}
float safe_log(float a, float b)
{
- if (a < 0.0 || b < 0.0)
- return 0.0;
-
- return log(a) / log(b);
+ if (a < 0.0 || b < 0.0)
+ return 0.0;
+
+ return log(a) / log(b);
}
-shader node_math(
- string type = "add",
- int use_clamp = 0,
- float Value1 = 0.0,
- float Value2 = 0.0,
- output float Value = 0.0)
+shader node_math(string type = "add",
+ int use_clamp = 0,
+ float Value1 = 0.0,
+ float Value2 = 0.0,
+ output float Value = 0.0)
{
- /* OSL asin, acos, pow check for values that could give rise to nan */
+ /* OSL asin, acos, pow check for values that could give rise to nan */
- if (type == "add")
- Value = Value1 + Value2;
- else if (type == "subtract")
- Value = Value1 - Value2;
- else if (type == "multiply")
- Value = Value1 * Value2;
- else if (type == "divide")
- Value = safe_divide(Value1, Value2);
- else if (type == "sine")
- Value = sin(Value1);
- else if (type == "cosine")
- Value = cos(Value1);
- else if (type == "tangent")
- Value = tan(Value1);
- else if (type == "arcsine")
- Value = asin(Value1);
- else if (type == "arccosine")
- Value = acos(Value1);
- else if (type == "arctangent")
- Value = atan(Value1);
- else if (type == "power")
- Value = pow(Value1, Value2);
- else if (type == "logarithm")
- Value = safe_log(Value1, Value2);
- else if (type == "minimum")
- Value = min(Value1, Value2);
- else if (type == "maximum")
- Value = max(Value1, Value2);
- else if (type == "round")
- Value = floor(Value1 + 0.5);
- else if (type == "less_than")
- Value = Value1 < Value2;
- else if (type == "greater_than")
- Value = Value1 > Value2;
- else if (type == "modulo")
- Value = safe_modulo(Value1, Value2);
- else if (type == "absolute")
- Value = fabs(Value1);
- else if (type == "arctan2")
- Value = atan2(Value1, Value2);
- else if (type == "floor")
- Value = floor(Value1);
- else if (type == "ceil")
- Value = ceil(Value1);
- else if (type == "fract")
- Value = Value1 - floor(Value1);
- else if (type == "sqrt")
- Value = safe_sqrt(Value1);
+ if (type == "add")
+ Value = Value1 + Value2;
+ else if (type == "subtract")
+ Value = Value1 - Value2;
+ else if (type == "multiply")
+ Value = Value1 * Value2;
+ else if (type == "divide")
+ Value = safe_divide(Value1, Value2);
+ else if (type == "sine")
+ Value = sin(Value1);
+ else if (type == "cosine")
+ Value = cos(Value1);
+ else if (type == "tangent")
+ Value = tan(Value1);
+ else if (type == "arcsine")
+ Value = asin(Value1);
+ else if (type == "arccosine")
+ Value = acos(Value1);
+ else if (type == "arctangent")
+ Value = atan(Value1);
+ else if (type == "power")
+ Value = pow(Value1, Value2);
+ else if (type == "logarithm")
+ Value = safe_log(Value1, Value2);
+ else if (type == "minimum")
+ Value = min(Value1, Value2);
+ else if (type == "maximum")
+ Value = max(Value1, Value2);
+ else if (type == "round")
+ Value = floor(Value1 + 0.5);
+ else if (type == "less_than")
+ Value = Value1 < Value2;
+ else if (type == "greater_than")
+ Value = Value1 > Value2;
+ else if (type == "modulo")
+ Value = safe_modulo(Value1, Value2);
+ else if (type == "absolute")
+ Value = fabs(Value1);
+ else if (type == "arctan2")
+ Value = atan2(Value1, Value2);
+ else if (type == "floor")
+ Value = floor(Value1);
+ else if (type == "ceil")
+ Value = ceil(Value1);
+ else if (type == "fract")
+ Value = Value1 - floor(Value1);
+ else if (type == "sqrt")
+ Value = safe_sqrt(Value1);
- if (use_clamp)
- Value = clamp(Value, 0.0, 1.0);
+ if (use_clamp)
+ Value = clamp(Value, 0.0, 1.0);
}
-
diff --git a/intern/cycles/kernel/shaders/node_mix.osl b/intern/cycles/kernel/shaders/node_mix.osl
index 0862c34b6e1..8caea6803ed 100644
--- a/intern/cycles/kernel/shaders/node_mix.osl
+++ b/intern/cycles/kernel/shaders/node_mix.osl
@@ -19,311 +19,312 @@
color node_mix_blend(float t, color col1, color col2)
{
- return mix(col1, col2, t);
+ return mix(col1, col2, t);
}
color node_mix_add(float t, color col1, color col2)
{
- return mix(col1, col1 + col2, t);
+ return mix(col1, col1 + col2, t);
}
color node_mix_mul(float t, color col1, color col2)
{
- return mix(col1, col1 * col2, t);
+ return mix(col1, col1 * col2, t);
}
color node_mix_screen(float t, color col1, color col2)
{
- float tm = 1.0 - t;
+ float tm = 1.0 - t;
- return color(1.0) - (color(tm) + t * (color(1.0) - col2)) * (color(1.0) - col1);
+ return color(1.0) - (color(tm) + t * (color(1.0) - col2)) * (color(1.0) - col1);
}
color node_mix_overlay(float t, color col1, color col2)
{
- float tm = 1.0 - t;
-
- color outcol = col1;
-
- if (outcol[0] < 0.5)
- outcol[0] *= tm + 2.0 * t * col2[0];
- else
- outcol[0] = 1.0 - (tm + 2.0 * t * (1.0 - col2[0])) * (1.0 - outcol[0]);
-
- if (outcol[1] < 0.5)
- outcol[1] *= tm + 2.0 * t * col2[1];
- else
- outcol[1] = 1.0 - (tm + 2.0 * t * (1.0 - col2[1])) * (1.0 - outcol[1]);
-
- if (outcol[2] < 0.5)
- outcol[2] *= tm + 2.0 * t * col2[2];
- else
- outcol[2] = 1.0 - (tm + 2.0 * t * (1.0 - col2[2])) * (1.0 - outcol[2]);
-
- return outcol;
+ float tm = 1.0 - t;
+
+ color outcol = col1;
+
+ if (outcol[0] < 0.5)
+ outcol[0] *= tm + 2.0 * t * col2[0];
+ else
+ outcol[0] = 1.0 - (tm + 2.0 * t * (1.0 - col2[0])) * (1.0 - outcol[0]);
+
+ if (outcol[1] < 0.5)
+ outcol[1] *= tm + 2.0 * t * col2[1];
+ else
+ outcol[1] = 1.0 - (tm + 2.0 * t * (1.0 - col2[1])) * (1.0 - outcol[1]);
+
+ if (outcol[2] < 0.5)
+ outcol[2] *= tm + 2.0 * t * col2[2];
+ else
+ outcol[2] = 1.0 - (tm + 2.0 * t * (1.0 - col2[2])) * (1.0 - outcol[2]);
+
+ return outcol;
}
color node_mix_sub(float t, color col1, color col2)
{
- return mix(col1, col1 - col2, t);
+ return mix(col1, col1 - col2, t);
}
color node_mix_div(float t, color col1, color col2)
{
- float tm = 1.0 - t;
+ float tm = 1.0 - t;
- color outcol = col1;
+ color outcol = col1;
- if (col2[0] != 0.0) outcol[0] = tm * outcol[0] + t * outcol[0] / col2[0];
- if (col2[1] != 0.0) outcol[1] = tm * outcol[1] + t * outcol[1] / col2[1];
- if (col2[2] != 0.0) outcol[2] = tm * outcol[2] + t * outcol[2] / col2[2];
+ if (col2[0] != 0.0)
+ outcol[0] = tm * outcol[0] + t * outcol[0] / col2[0];
+ if (col2[1] != 0.0)
+ outcol[1] = tm * outcol[1] + t * outcol[1] / col2[1];
+ if (col2[2] != 0.0)
+ outcol[2] = tm * outcol[2] + t * outcol[2] / col2[2];
- return outcol;
+ return outcol;
}
color node_mix_diff(float t, color col1, color col2)
{
- return mix(col1, abs(col1 - col2), t);
+ return mix(col1, abs(col1 - col2), t);
}
color node_mix_dark(float t, color col1, color col2)
{
- return min(col1, col2) * t + col1 * (1.0 - t);
+ return min(col1, col2) * t + col1 * (1.0 - t);
}
color node_mix_light(float t, color col1, color col2)
{
- return max(col1, col2 * t);
+ return max(col1, col2 * t);
}
color node_mix_dodge(float t, color col1, color col2)
{
- color outcol = col1;
-
- if (outcol[0] != 0.0) {
- float tmp = 1.0 - t * col2[0];
- if (tmp <= 0.0)
- outcol[0] = 1.0;
- else if ((tmp = outcol[0] / tmp) > 1.0)
- outcol[0] = 1.0;
- else
- outcol[0] = tmp;
- }
- if (outcol[1] != 0.0) {
- float tmp = 1.0 - t * col2[1];
- if (tmp <= 0.0)
- outcol[1] = 1.0;
- else if ((tmp = outcol[1] / tmp) > 1.0)
- outcol[1] = 1.0;
- else
- outcol[1] = tmp;
- }
- if (outcol[2] != 0.0) {
- float tmp = 1.0 - t * col2[2];
- if (tmp <= 0.0)
- outcol[2] = 1.0;
- else if ((tmp = outcol[2] / tmp) > 1.0)
- outcol[2] = 1.0;
- else
- outcol[2] = tmp;
- }
-
- return outcol;
+ color outcol = col1;
+
+ if (outcol[0] != 0.0) {
+ float tmp = 1.0 - t * col2[0];
+ if (tmp <= 0.0)
+ outcol[0] = 1.0;
+ else if ((tmp = outcol[0] / tmp) > 1.0)
+ outcol[0] = 1.0;
+ else
+ outcol[0] = tmp;
+ }
+ if (outcol[1] != 0.0) {
+ float tmp = 1.0 - t * col2[1];
+ if (tmp <= 0.0)
+ outcol[1] = 1.0;
+ else if ((tmp = outcol[1] / tmp) > 1.0)
+ outcol[1] = 1.0;
+ else
+ outcol[1] = tmp;
+ }
+ if (outcol[2] != 0.0) {
+ float tmp = 1.0 - t * col2[2];
+ if (tmp <= 0.0)
+ outcol[2] = 1.0;
+ else if ((tmp = outcol[2] / tmp) > 1.0)
+ outcol[2] = 1.0;
+ else
+ outcol[2] = tmp;
+ }
+
+ return outcol;
}
color node_mix_burn(float t, color col1, color col2)
{
- float tmp, tm = 1.0 - t;
-
- color outcol = col1;
-
- tmp = tm + t * col2[0];
- if (tmp <= 0.0)
- outcol[0] = 0.0;
- else if ((tmp = (1.0 - (1.0 - outcol[0]) / tmp)) < 0.0)
- outcol[0] = 0.0;
- else if (tmp > 1.0)
- outcol[0] = 1.0;
- else
- outcol[0] = tmp;
-
- tmp = tm + t * col2[1];
- if (tmp <= 0.0)
- outcol[1] = 0.0;
- else if ((tmp = (1.0 - (1.0 - outcol[1]) / tmp)) < 0.0)
- outcol[1] = 0.0;
- else if (tmp > 1.0)
- outcol[1] = 1.0;
- else
- outcol[1] = tmp;
-
- tmp = tm + t * col2[2];
- if (tmp <= 0.0)
- outcol[2] = 0.0;
- else if ((tmp = (1.0 - (1.0 - outcol[2]) / tmp)) < 0.0)
- outcol[2] = 0.0;
- else if (tmp > 1.0)
- outcol[2] = 1.0;
- else
- outcol[2] = tmp;
-
- return outcol;
+ float tmp, tm = 1.0 - t;
+
+ color outcol = col1;
+
+ tmp = tm + t * col2[0];
+ if (tmp <= 0.0)
+ outcol[0] = 0.0;
+ else if ((tmp = (1.0 - (1.0 - outcol[0]) / tmp)) < 0.0)
+ outcol[0] = 0.0;
+ else if (tmp > 1.0)
+ outcol[0] = 1.0;
+ else
+ outcol[0] = tmp;
+
+ tmp = tm + t * col2[1];
+ if (tmp <= 0.0)
+ outcol[1] = 0.0;
+ else if ((tmp = (1.0 - (1.0 - outcol[1]) / tmp)) < 0.0)
+ outcol[1] = 0.0;
+ else if (tmp > 1.0)
+ outcol[1] = 1.0;
+ else
+ outcol[1] = tmp;
+
+ tmp = tm + t * col2[2];
+ if (tmp <= 0.0)
+ outcol[2] = 0.0;
+ else if ((tmp = (1.0 - (1.0 - outcol[2]) / tmp)) < 0.0)
+ outcol[2] = 0.0;
+ else if (tmp > 1.0)
+ outcol[2] = 1.0;
+ else
+ outcol[2] = tmp;
+
+ return outcol;
}
color node_mix_hue(float t, color col1, color col2)
{
- color outcol = col1;
- color hsv2 = rgb_to_hsv(col2);
+ color outcol = col1;
+ color hsv2 = rgb_to_hsv(col2);
- if (hsv2[1] != 0.0) {
- color hsv = rgb_to_hsv(outcol);
- hsv[0] = hsv2[0];
- color tmp = hsv_to_rgb(hsv);
+ if (hsv2[1] != 0.0) {
+ color hsv = rgb_to_hsv(outcol);
+ hsv[0] = hsv2[0];
+ color tmp = hsv_to_rgb(hsv);
- outcol = mix(outcol, tmp, t);
- }
+ outcol = mix(outcol, tmp, t);
+ }
- return outcol;
+ return outcol;
}
color node_mix_sat(float t, color col1, color col2)
{
- float tm = 1.0 - t;
+ float tm = 1.0 - t;
- color outcol = col1;
+ color outcol = col1;
- color hsv = rgb_to_hsv(outcol);
+ color hsv = rgb_to_hsv(outcol);
- if (hsv[1] != 0.0) {
- color hsv2 = rgb_to_hsv(col2);
+ if (hsv[1] != 0.0) {
+ color hsv2 = rgb_to_hsv(col2);
- hsv[1] = tm * hsv[1] + t * hsv2[1];
- outcol = hsv_to_rgb(hsv);
- }
+ hsv[1] = tm * hsv[1] + t * hsv2[1];
+ outcol = hsv_to_rgb(hsv);
+ }
- return outcol;
+ return outcol;
}
color node_mix_val(float t, color col1, color col2)
{
- float tm = 1.0 - t;
+ float tm = 1.0 - t;
- color hsv = rgb_to_hsv(col1);
- color hsv2 = rgb_to_hsv(col2);
+ color hsv = rgb_to_hsv(col1);
+ color hsv2 = rgb_to_hsv(col2);
- hsv[2] = tm * hsv[2] + t * hsv2[2];
+ hsv[2] = tm * hsv[2] + t * hsv2[2];
- return hsv_to_rgb(hsv);
+ return hsv_to_rgb(hsv);
}
color node_mix_color(float t, color col1, color col2)
{
- color outcol = col1;
- color hsv2 = rgb_to_hsv(col2);
+ color outcol = col1;
+ color hsv2 = rgb_to_hsv(col2);
- if (hsv2[1] != 0.0) {
- color hsv = rgb_to_hsv(outcol);
- hsv[0] = hsv2[0];
- hsv[1] = hsv2[1];
- color tmp = hsv_to_rgb(hsv);
+ if (hsv2[1] != 0.0) {
+ color hsv = rgb_to_hsv(outcol);
+ hsv[0] = hsv2[0];
+ hsv[1] = hsv2[1];
+ color tmp = hsv_to_rgb(hsv);
- outcol = mix(outcol, tmp, t);
- }
+ outcol = mix(outcol, tmp, t);
+ }
- return outcol;
+ return outcol;
}
color node_mix_soft(float t, color col1, color col2)
{
- float tm = 1.0 - t;
+ float tm = 1.0 - t;
- color one = color(1.0);
- color scr = one - (one - col2) * (one - col1);
+ color one = color(1.0);
+ color scr = one - (one - col2) * (one - col1);
- return tm * col1 + t * ((one - col1) * col2 * col1 + col1 * scr);
+ return tm * col1 + t * ((one - col1) * col2 * col1 + col1 * scr);
}
color node_mix_linear(float t, color col1, color col2)
{
- color outcol = col1;
-
- if (col2[0] > 0.5)
- outcol[0] = col1[0] + t * (2.0 * (col2[0] - 0.5));
- else
- outcol[0] = col1[0] + t * (2.0 * (col2[0]) - 1.0);
-
- if (col2[1] > 0.5)
- outcol[1] = col1[1] + t * (2.0 * (col2[1] - 0.5));
- else
- outcol[1] = col1[1] + t * (2.0 * (col2[1]) - 1.0);
-
- if (col2[2] > 0.5)
- outcol[2] = col1[2] + t * (2.0 * (col2[2] - 0.5));
- else
- outcol[2] = col1[2] + t * (2.0 * (col2[2]) - 1.0);
-
- return outcol;
+ color outcol = col1;
+
+ if (col2[0] > 0.5)
+ outcol[0] = col1[0] + t * (2.0 * (col2[0] - 0.5));
+ else
+ outcol[0] = col1[0] + t * (2.0 * (col2[0]) - 1.0);
+
+ if (col2[1] > 0.5)
+ outcol[1] = col1[1] + t * (2.0 * (col2[1] - 0.5));
+ else
+ outcol[1] = col1[1] + t * (2.0 * (col2[1]) - 1.0);
+
+ if (col2[2] > 0.5)
+ outcol[2] = col1[2] + t * (2.0 * (col2[2] - 0.5));
+ else
+ outcol[2] = col1[2] + t * (2.0 * (col2[2]) - 1.0);
+
+ return outcol;
}
color node_mix_clamp(color col)
{
- color outcol = col;
+ color outcol = col;
- outcol[0] = clamp(col[0], 0.0, 1.0);
- outcol[1] = clamp(col[1], 0.0, 1.0);
- outcol[2] = clamp(col[2], 0.0, 1.0);
+ outcol[0] = clamp(col[0], 0.0, 1.0);
+ outcol[1] = clamp(col[1], 0.0, 1.0);
+ outcol[2] = clamp(col[2], 0.0, 1.0);
- return outcol;
+ return outcol;
}
-shader node_mix(
- string type = "mix",
- int use_clamp = 0,
- float Fac = 0.5,
- color Color1 = 0.0,
- color Color2 = 0.0,
- output color Color = 0.0)
+shader node_mix(string type = "mix",
+ int use_clamp = 0,
+ float Fac = 0.5,
+ color Color1 = 0.0,
+ color Color2 = 0.0,
+ output color Color = 0.0)
{
- float t = clamp(Fac, 0.0, 1.0);
-
- if (type == "mix")
- Color = node_mix_blend(t, Color1, Color2);
- if (type == "add")
- Color = node_mix_add(t, Color1, Color2);
- if (type == "multiply")
- Color = node_mix_mul(t, Color1, Color2);
- if (type == "screen")
- Color = node_mix_screen(t, Color1, Color2);
- if (type == "overlay")
- Color = node_mix_overlay(t, Color1, Color2);
- if (type == "subtract")
- Color = node_mix_sub(t, Color1, Color2);
- if (type == "divide")
- Color = node_mix_div(t, Color1, Color2);
- if (type == "difference")
- Color = node_mix_diff(t, Color1, Color2);
- if (type == "darken")
- Color = node_mix_dark(t, Color1, Color2);
- if (type == "lighten")
- Color = node_mix_light(t, Color1, Color2);
- if (type == "dodge")
- Color = node_mix_dodge(t, Color1, Color2);
- if (type == "burn")
- Color = node_mix_burn(t, Color1, Color2);
- if (type == "hue")
- Color = node_mix_hue(t, Color1, Color2);
- if (type == "saturation")
- Color = node_mix_sat(t, Color1, Color2);
- if (type == "value")
- Color = node_mix_val (t, Color1, Color2);
- if (type == "color")
- Color = node_mix_color(t, Color1, Color2);
- if (type == "soft_light")
- Color = node_mix_soft(t, Color1, Color2);
- if (type == "linear_light")
- Color = node_mix_linear(t, Color1, Color2);
-
- if (use_clamp)
- Color = node_mix_clamp(Color);
+ float t = clamp(Fac, 0.0, 1.0);
+
+ if (type == "mix")
+ Color = node_mix_blend(t, Color1, Color2);
+ if (type == "add")
+ Color = node_mix_add(t, Color1, Color2);
+ if (type == "multiply")
+ Color = node_mix_mul(t, Color1, Color2);
+ if (type == "screen")
+ Color = node_mix_screen(t, Color1, Color2);
+ if (type == "overlay")
+ Color = node_mix_overlay(t, Color1, Color2);
+ if (type == "subtract")
+ Color = node_mix_sub(t, Color1, Color2);
+ if (type == "divide")
+ Color = node_mix_div(t, Color1, Color2);
+ if (type == "difference")
+ Color = node_mix_diff(t, Color1, Color2);
+ if (type == "darken")
+ Color = node_mix_dark(t, Color1, Color2);
+ if (type == "lighten")
+ Color = node_mix_light(t, Color1, Color2);
+ if (type == "dodge")
+ Color = node_mix_dodge(t, Color1, Color2);
+ if (type == "burn")
+ Color = node_mix_burn(t, Color1, Color2);
+ if (type == "hue")
+ Color = node_mix_hue(t, Color1, Color2);
+ if (type == "saturation")
+ Color = node_mix_sat(t, Color1, Color2);
+ if (type == "value")
+ Color = node_mix_val(t, Color1, Color2);
+ if (type == "color")
+ Color = node_mix_color(t, Color1, Color2);
+ if (type == "soft_light")
+ Color = node_mix_soft(t, Color1, Color2);
+ if (type == "linear_light")
+ Color = node_mix_linear(t, Color1, Color2);
+
+ if (use_clamp)
+ Color = node_mix_clamp(Color);
}
-
diff --git a/intern/cycles/kernel/shaders/node_mix_closure.osl b/intern/cycles/kernel/shaders/node_mix_closure.osl
index 5946dfdaaba..517c59c8786 100644
--- a/intern/cycles/kernel/shaders/node_mix_closure.osl
+++ b/intern/cycles/kernel/shaders/node_mix_closure.osl
@@ -16,13 +16,11 @@
#include "stdosl.h"
-shader node_mix_closure(
- float Fac = 0.5,
- closure color Closure1 = 0,
- closure color Closure2 = 0,
- output closure color Closure = 0)
+shader node_mix_closure(float Fac = 0.5,
+ closure color Closure1 = 0,
+ closure color Closure2 = 0,
+ output closure color Closure = 0)
{
- float t = clamp(Fac, 0.0, 1.0);
- Closure = (1.0 - t) * Closure1 + t * Closure2;
+ float t = clamp(Fac, 0.0, 1.0);
+ Closure = (1.0 - t) * Closure1 + t * Closure2;
}
-
diff --git a/intern/cycles/kernel/shaders/node_musgrave_texture.osl b/intern/cycles/kernel/shaders/node_musgrave_texture.osl
index 454b3834081..a7877c43d46 100644
--- a/intern/cycles/kernel/shaders/node_musgrave_texture.osl
+++ b/intern/cycles/kernel/shaders/node_musgrave_texture.osl
@@ -28,24 +28,24 @@
float noise_musgrave_fBm(point ip, float H, float lacunarity, float octaves)
{
- float rmd;
- float value = 0.0;
- float pwr = 1.0;
- float pwHL = pow(lacunarity, -H);
- int i;
- point p = ip;
-
- for (i = 0; i < (int)octaves; i++) {
- value += safe_noise(p, "signed") * pwr;
- pwr *= pwHL;
- p *= lacunarity;
- }
-
- rmd = octaves - floor(octaves);
- if (rmd != 0.0)
- value += rmd * safe_noise(p, "signed") * pwr;
-
- return value;
+ float rmd;
+ float value = 0.0;
+ float pwr = 1.0;
+ float pwHL = pow(lacunarity, -H);
+ int i;
+ point p = ip;
+
+ for (i = 0; i < (int)octaves; i++) {
+ value += safe_noise(p, "signed") * pwr;
+ pwr *= pwHL;
+ p *= lacunarity;
+ }
+
+ rmd = octaves - floor(octaves);
+ if (rmd != 0.0)
+ value += rmd * safe_noise(p, "signed") * pwr;
+
+ return value;
}
/* Musgrave Multifractal
@@ -57,24 +57,24 @@ float noise_musgrave_fBm(point ip, float H, float lacunarity, float octaves)
float noise_musgrave_multi_fractal(point ip, float H, float lacunarity, float octaves)
{
- float rmd;
- float value = 1.0;
- float pwr = 1.0;
- float pwHL = pow(lacunarity, -H);
- int i;
- point p = ip;
-
- for (i = 0; i < (int)octaves; i++) {
- value *= (pwr * safe_noise(p, "signed") + 1.0);
- pwr *= pwHL;
- p *= lacunarity;
- }
-
- rmd = octaves - floor(octaves);
- if (rmd != 0.0)
- value *= (rmd * pwr * safe_noise(p, "signed") + 1.0); /* correct? */
-
- return value;
+ float rmd;
+ float value = 1.0;
+ float pwr = 1.0;
+ float pwHL = pow(lacunarity, -H);
+ int i;
+ point p = ip;
+
+ for (i = 0; i < (int)octaves; i++) {
+ value *= (pwr * safe_noise(p, "signed") + 1.0);
+ pwr *= pwHL;
+ p *= lacunarity;
+ }
+
+ rmd = octaves - floor(octaves);
+ if (rmd != 0.0)
+ value *= (rmd * pwr * safe_noise(p, "signed") + 1.0); /* correct? */
+
+ return value;
}
/* Musgrave Heterogeneous Terrain
@@ -85,32 +85,33 @@ float noise_musgrave_multi_fractal(point ip, float H, float lacunarity, float oc
* offset: raises the terrain from `sea level'
*/
-float noise_musgrave_hetero_terrain(point ip, float H, float lacunarity, float octaves, float offset)
+float noise_musgrave_hetero_terrain(
+ point ip, float H, float lacunarity, float octaves, float offset)
{
- float value, increment, rmd;
- float pwHL = pow(lacunarity, -H);
- float pwr = pwHL;
- int i;
- point p = ip;
-
- /* first unscaled octave of function; later octaves are scaled */
- value = offset + safe_noise(p, "signed");
- p *= lacunarity;
-
- for (i = 1; i < (int)octaves; i++) {
- increment = (safe_noise(p, "signed") + offset) * pwr * value;
- value += increment;
- pwr *= pwHL;
- p *= lacunarity;
- }
-
- rmd = octaves - floor(octaves);
- if (rmd != 0.0) {
- increment = (safe_noise(p, "signed") + offset) * pwr * value;
- value += rmd * increment;
- }
-
- return value;
+ float value, increment, rmd;
+ float pwHL = pow(lacunarity, -H);
+ float pwr = pwHL;
+ int i;
+ point p = ip;
+
+ /* first unscaled octave of function; later octaves are scaled */
+ value = offset + safe_noise(p, "signed");
+ p *= lacunarity;
+
+ for (i = 1; i < (int)octaves; i++) {
+ increment = (safe_noise(p, "signed") + offset) * pwr * value;
+ value += increment;
+ pwr *= pwHL;
+ p *= lacunarity;
+ }
+
+ rmd = octaves - floor(octaves);
+ if (rmd != 0.0) {
+ increment = (safe_noise(p, "signed") + offset) * pwr * value;
+ value += rmd * increment;
+ }
+
+ return value;
}
/* Hybrid Additive/Multiplicative Multifractal Terrain
@@ -121,35 +122,35 @@ float noise_musgrave_hetero_terrain(point ip, float H, float lacunarity, float o
* offset: raises the terrain from `sea level'
*/
-float noise_musgrave_hybrid_multi_fractal(point ip, float H, float lacunarity,
- float octaves, float offset, float gain)
+float noise_musgrave_hybrid_multi_fractal(
+ point ip, float H, float lacunarity, float octaves, float offset, float gain)
{
- float result, signal, weight, rmd;
- float pwHL = pow(lacunarity, -H);
- float pwr = pwHL;
- int i;
- point p = ip;
-
- result = safe_noise(p, "signed") + offset;
- weight = gain * result;
- p *= lacunarity;
-
- for (i = 1; (weight > 0.001) && (i < (int)octaves); i++) {
- if (weight > 1.0)
- weight = 1.0;
-
- signal = (safe_noise(p, "signed") + offset) * pwr;
- pwr *= pwHL;
- result += weight * signal;
- weight *= gain * signal;
- p *= lacunarity;
- }
-
- rmd = octaves - floor(octaves);
- if (rmd != 0.0)
- result += rmd * ((safe_noise(p, "signed") + offset) * pwr);
-
- return result;
+ float result, signal, weight, rmd;
+ float pwHL = pow(lacunarity, -H);
+ float pwr = pwHL;
+ int i;
+ point p = ip;
+
+ result = safe_noise(p, "signed") + offset;
+ weight = gain * result;
+ p *= lacunarity;
+
+ for (i = 1; (weight > 0.001) && (i < (int)octaves); i++) {
+ if (weight > 1.0)
+ weight = 1.0;
+
+ signal = (safe_noise(p, "signed") + offset) * pwr;
+ pwr *= pwHL;
+ result += weight * signal;
+ weight *= gain * signal;
+ p *= lacunarity;
+ }
+
+ rmd = octaves - floor(octaves);
+ if (rmd != 0.0)
+ result += rmd * ((safe_noise(p, "signed") + offset) * pwr);
+
+ return result;
}
/* Ridged Multifractal Terrain
@@ -160,72 +161,73 @@ float noise_musgrave_hybrid_multi_fractal(point ip, float H, float lacunarity,
* offset: raises the terrain from `sea level'
*/
-float noise_musgrave_ridged_multi_fractal(point ip, float H, float lacunarity,
- float octaves, float offset, float gain)
+float noise_musgrave_ridged_multi_fractal(
+ point ip, float H, float lacunarity, float octaves, float offset, float gain)
{
- float result, signal, weight;
- float pwHL = pow(lacunarity, -H);
- float pwr = pwHL;
- int i;
- point p = ip;
-
- signal = offset - fabs(safe_noise(p, "signed"));
- signal *= signal;
- result = signal;
- weight = 1.0;
-
- for (i = 1; i < (int)octaves; i++) {
- p *= lacunarity;
- weight = clamp(signal * gain, 0.0, 1.0);
- signal = offset - fabs(safe_noise(p, "signed"));
- signal *= signal;
- signal *= weight;
- result += signal * pwr;
- pwr *= pwHL;
- }
-
- return result;
+ float result, signal, weight;
+ float pwHL = pow(lacunarity, -H);
+ float pwr = pwHL;
+ int i;
+ point p = ip;
+
+ signal = offset - fabs(safe_noise(p, "signed"));
+ signal *= signal;
+ result = signal;
+ weight = 1.0;
+
+ for (i = 1; i < (int)octaves; i++) {
+ p *= lacunarity;
+ weight = clamp(signal * gain, 0.0, 1.0);
+ signal = offset - fabs(safe_noise(p, "signed"));
+ signal *= signal;
+ signal *= weight;
+ result += signal * pwr;
+ pwr *= pwHL;
+ }
+
+ return result;
}
/* Shader */
shader node_musgrave_texture(
- int use_mapping = 0,
- matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- string type = "fBM",
- float Dimension = 2.0,
- float Lacunarity = 1.0,
- float Detail = 2.0,
- float Offset = 0.0,
- float Gain = 1.0,
- float Scale = 5.0,
- point Vector = P,
- output float Fac = 0.0,
- output color Color = 0.0)
+ int use_mapping = 0,
+ matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+ string type = "fBM",
+ float Dimension = 2.0,
+ float Lacunarity = 1.0,
+ float Detail = 2.0,
+ float Offset = 0.0,
+ float Gain = 1.0,
+ float Scale = 5.0,
+ point Vector = P,
+ output float Fac = 0.0,
+ output color Color = 0.0)
{
- float dimension = max(Dimension, 1e-5);
- float octaves = clamp(Detail, 0.0, 16.0);
- float lacunarity = max(Lacunarity, 1e-5);
- float intensity = 1.0;
-
- point p = Vector;
-
- if (use_mapping)
- p = transform(mapping, p);
-
- p = p * Scale;
-
- if (type == "multifractal")
- Fac = intensity * noise_musgrave_multi_fractal(p, dimension, lacunarity, octaves);
- else if (type == "fBM")
- Fac = intensity * noise_musgrave_fBm(p, dimension, lacunarity, octaves);
- else if (type == "hybrid_multifractal")
- Fac = intensity * noise_musgrave_hybrid_multi_fractal(p, dimension, lacunarity, octaves, Offset, Gain);
- else if (type == "ridged_multifractal")
- Fac = intensity * noise_musgrave_ridged_multi_fractal(p, dimension, lacunarity, octaves, Offset, Gain);
- else if (type == "hetero_terrain")
- Fac = intensity * noise_musgrave_hetero_terrain(p, dimension, lacunarity, octaves, Offset);
-
- Color = color(Fac, Fac, Fac);
+ float dimension = max(Dimension, 1e-5);
+ float octaves = clamp(Detail, 0.0, 16.0);
+ float lacunarity = max(Lacunarity, 1e-5);
+ float intensity = 1.0;
+
+ point p = Vector;
+
+ if (use_mapping)
+ p = transform(mapping, p);
+
+ p = p * Scale;
+
+ if (type == "multifractal")
+ Fac = intensity * noise_musgrave_multi_fractal(p, dimension, lacunarity, octaves);
+ else if (type == "fBM")
+ Fac = intensity * noise_musgrave_fBm(p, dimension, lacunarity, octaves);
+ else if (type == "hybrid_multifractal")
+ Fac = intensity *
+ noise_musgrave_hybrid_multi_fractal(p, dimension, lacunarity, octaves, Offset, Gain);
+ else if (type == "ridged_multifractal")
+ Fac = intensity *
+ noise_musgrave_ridged_multi_fractal(p, dimension, lacunarity, octaves, Offset, Gain);
+ else if (type == "hetero_terrain")
+ Fac = intensity * noise_musgrave_hetero_terrain(p, dimension, lacunarity, octaves, Offset);
+
+ Color = color(Fac, Fac, Fac);
}
-
diff --git a/intern/cycles/kernel/shaders/node_noise_texture.osl b/intern/cycles/kernel/shaders/node_noise_texture.osl
index 42a30897341..2cbd571e206 100644
--- a/intern/cycles/kernel/shaders/node_noise_texture.osl
+++ b/intern/cycles/kernel/shaders/node_noise_texture.osl
@@ -21,41 +21,40 @@
float noise(point ip, float distortion, float detail, output color Color)
{
- point r;
- point p = ip;
- int hard = 0;
-
- if (distortion != 0.0) {
- r[0] = safe_noise(p + point(13.5), "unsigned") * distortion;
- r[1] = safe_noise(p, "unsigned") * distortion;
- r[2] = safe_noise(p - point(13.5), "unsigned") * distortion;
-
- p += r;
- }
-
- float fac = noise_turbulence(p, detail, hard);
-
- Color = color(fac, noise_turbulence(point(p[1], p[0], p[2]), detail, hard),
- noise_turbulence(point(p[1], p[2], p[0]), detail, hard));
-
- return fac;
+ point r;
+ point p = ip;
+ int hard = 0;
+
+ if (distortion != 0.0) {
+ r[0] = safe_noise(p + point(13.5), "unsigned") * distortion;
+ r[1] = safe_noise(p, "unsigned") * distortion;
+ r[2] = safe_noise(p - point(13.5), "unsigned") * distortion;
+
+ p += r;
+ }
+
+ float fac = noise_turbulence(p, detail, hard);
+
+ Color = color(fac,
+ noise_turbulence(point(p[1], p[0], p[2]), detail, hard),
+ noise_turbulence(point(p[1], p[2], p[0]), detail, hard));
+
+ return fac;
}
-shader node_noise_texture(
- int use_mapping = 0,
- matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- float Distortion = 0.0,
- float Scale = 5.0,
- float Detail = 2.0,
- point Vector = P,
- output float Fac = 0.0,
- output color Color = 0.0)
+shader node_noise_texture(int use_mapping = 0,
+ matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+ float Distortion = 0.0,
+ float Scale = 5.0,
+ float Detail = 2.0,
+ point Vector = P,
+ output float Fac = 0.0,
+ output color Color = 0.0)
{
- point p = Vector;
+ point p = Vector;
- if (use_mapping)
- p = transform(mapping, p);
+ if (use_mapping)
+ p = transform(mapping, p);
- Fac = noise(p * Scale, Distortion, Detail, Color);
+ Fac = noise(p * Scale, Distortion, Detail, Color);
}
-
diff --git a/intern/cycles/kernel/shaders/node_normal.osl b/intern/cycles/kernel/shaders/node_normal.osl
index 7307971eddd..1d20c3e7cac 100644
--- a/intern/cycles/kernel/shaders/node_normal.osl
+++ b/intern/cycles/kernel/shaders/node_normal.osl
@@ -16,13 +16,11 @@
#include "stdosl.h"
-shader node_normal(
- normal direction = normal(0.0, 0.0, 0.0),
- normal NormalIn = normal(0.0, 0.0, 0.0),
- output normal NormalOut = normal(0.0, 0.0, 0.0),
- output float Dot = 1.0)
+shader node_normal(normal direction = normal(0.0, 0.0, 0.0),
+ normal NormalIn = normal(0.0, 0.0, 0.0),
+ output normal NormalOut = normal(0.0, 0.0, 0.0),
+ output float Dot = 1.0)
{
- NormalOut = normalize(direction);
- Dot = dot(NormalOut, normalize(NormalIn));
+ NormalOut = normalize(direction);
+ Dot = dot(NormalOut, normalize(NormalIn));
}
-
diff --git a/intern/cycles/kernel/shaders/node_normal_map.osl b/intern/cycles/kernel/shaders/node_normal_map.osl
index fda6f12a5da..90b593d00bc 100644
--- a/intern/cycles/kernel/shaders/node_normal_map.osl
+++ b/intern/cycles/kernel/shaders/node_normal_map.osl
@@ -16,79 +16,75 @@
#include "stdosl.h"
-shader node_normal_map(
- normal NormalIn = N,
- float Strength = 1.0,
- color Color = color(0.5, 0.5, 1.0),
- string space = "tangent",
- string attr_name = "geom:tangent",
- string attr_sign_name = "geom:tangent_sign",
- output normal Normal = NormalIn)
+shader node_normal_map(normal NormalIn = N,
+ float Strength = 1.0,
+ color Color = color(0.5, 0.5, 1.0),
+ string space = "tangent",
+ string attr_name = "geom:tangent",
+ string attr_sign_name = "geom:tangent_sign",
+ output normal Normal = NormalIn)
{
- color mcolor = 2.0 * color(Color[0] - 0.5, Color[1] - 0.5, Color[2] - 0.5);
- int is_backfacing = backfacing();
+ color mcolor = 2.0 * color(Color[0] - 0.5, Color[1] - 0.5, Color[2] - 0.5);
+ int is_backfacing = backfacing();
- if (space == "tangent") {
- vector tangent;
- vector ninterp;
- float tangent_sign;
- float is_smooth;
+ if (space == "tangent") {
+ vector tangent;
+ vector ninterp;
+ float tangent_sign;
+ float is_smooth;
- getattribute("geom:is_smooth", is_smooth);
- if (!is_smooth) {
- ninterp = normalize(transform("world", "object", Ng));
+ getattribute("geom:is_smooth", is_smooth);
+ if (!is_smooth) {
+ ninterp = normalize(transform("world", "object", Ng));
- /* the normal is already inverted, which is too soon for the math here */
- if (is_backfacing) {
- ninterp = -ninterp;
- }
- }
+ /* the normal is already inverted, which is too soon for the math here */
+ if (is_backfacing) {
+ ninterp = -ninterp;
+ }
+ }
- // get _unnormalized_ interpolated normal and tangent
- if (getattribute(attr_name, tangent) &&
- getattribute(attr_sign_name, tangent_sign) &&
- (!is_smooth || getattribute("geom:N", ninterp)))
- {
- // apply normal map
- vector B = tangent_sign * cross(ninterp, tangent);
- Normal = normalize(mcolor[0] * tangent + mcolor[1] * B + mcolor[2] * ninterp);
+ // get _unnormalized_ interpolated normal and tangent
+ if (getattribute(attr_name, tangent) && getattribute(attr_sign_name, tangent_sign) &&
+ (!is_smooth || getattribute("geom:N", ninterp))) {
+ // apply normal map
+ vector B = tangent_sign * cross(ninterp, tangent);
+ Normal = normalize(mcolor[0] * tangent + mcolor[1] * B + mcolor[2] * ninterp);
- // transform to world space
- Normal = normalize(transform("object", "world", Normal));
- }
- else {
- Normal = normal(0, 0, 0);
- }
- }
- else if (space == "object") {
- Normal = normalize(transform("object", "world", vector(mcolor)));
- }
- else if (space == "world") {
- Normal = normalize(vector(mcolor));
- }
- else if (space == "blender_object") {
- /* strange blender convention */
- mcolor[1] = -mcolor[1];
- mcolor[2] = -mcolor[2];
-
- Normal = normalize(transform("object", "world", vector(mcolor)));
- }
- else if (space == "blender_world") {
- /* strange blender convention */
- mcolor[1] = -mcolor[1];
- mcolor[2] = -mcolor[2];
-
- Normal = normalize(vector(mcolor));
- }
+ // transform to world space
+ Normal = normalize(transform("object", "world", Normal));
+ }
+ else {
+ Normal = normal(0, 0, 0);
+ }
+ }
+ else if (space == "object") {
+ Normal = normalize(transform("object", "world", vector(mcolor)));
+ }
+ else if (space == "world") {
+ Normal = normalize(vector(mcolor));
+ }
+ else if (space == "blender_object") {
+ /* strange blender convention */
+ mcolor[1] = -mcolor[1];
+ mcolor[2] = -mcolor[2];
- /* invert normal for backfacing polygons */
- if (is_backfacing) {
- Normal = -Normal;
- }
+ Normal = normalize(transform("object", "world", vector(mcolor)));
+ }
+ else if (space == "blender_world") {
+ /* strange blender convention */
+ mcolor[1] = -mcolor[1];
+ mcolor[2] = -mcolor[2];
- if (Strength != 1.0)
- Normal = normalize(NormalIn + (Normal - NormalIn) * max(Strength, 0.0));
+ Normal = normalize(vector(mcolor));
+ }
- Normal = ensure_valid_reflection(Ng, I, Normal);
-}
+ /* invert normal for backfacing polygons */
+ if (is_backfacing) {
+ Normal = -Normal;
+ }
+
+ if (Strength != 1.0)
+ Normal = normalize(NormalIn + (Normal - NormalIn) * max(Strength, 0.0));
+ Normal = ensure_valid_reflection(Ng, I, Normal);
+}
diff --git a/intern/cycles/kernel/shaders/node_object_info.osl b/intern/cycles/kernel/shaders/node_object_info.osl
index dd7c663b8d8..0904a30a53f 100644
--- a/intern/cycles/kernel/shaders/node_object_info.osl
+++ b/intern/cycles/kernel/shaders/node_object_info.osl
@@ -16,15 +16,13 @@
#include "stdosl.h"
-shader node_object_info(
- output point Location = point(0.0, 0.0, 0.0),
- output float ObjectIndex = 0.0,
- output float MaterialIndex = 0.0,
- output float Random = 0.0)
+shader node_object_info(output point Location = point(0.0, 0.0, 0.0),
+ output float ObjectIndex = 0.0,
+ output float MaterialIndex = 0.0,
+ output float Random = 0.0)
{
- getattribute("object:location", Location);
- getattribute("object:index", ObjectIndex);
- getattribute("material:index", MaterialIndex);
- getattribute("object:random", Random);
+ getattribute("object:location", Location);
+ getattribute("object:index", ObjectIndex);
+ getattribute("material:index", MaterialIndex);
+ getattribute("object:random", Random);
}
-
diff --git a/intern/cycles/kernel/shaders/node_output_displacement.osl b/intern/cycles/kernel/shaders/node_output_displacement.osl
index 5dbef0244fe..fa7f603980b 100644
--- a/intern/cycles/kernel/shaders/node_output_displacement.osl
+++ b/intern/cycles/kernel/shaders/node_output_displacement.osl
@@ -18,6 +18,5 @@
displacement node_output_displacement(vector Displacement = 0.0)
{
- P += Displacement;
+ P += Displacement;
}
-
diff --git a/intern/cycles/kernel/shaders/node_output_surface.osl b/intern/cycles/kernel/shaders/node_output_surface.osl
index 2cc4575a8c8..013666145da 100644
--- a/intern/cycles/kernel/shaders/node_output_surface.osl
+++ b/intern/cycles/kernel/shaders/node_output_surface.osl
@@ -18,6 +18,5 @@
surface node_output_surface(closure color Surface = 0)
{
- Ci = Surface;
+ Ci = Surface;
}
-
diff --git a/intern/cycles/kernel/shaders/node_output_volume.osl b/intern/cycles/kernel/shaders/node_output_volume.osl
index f220ba866e3..dd479e751b3 100644
--- a/intern/cycles/kernel/shaders/node_output_volume.osl
+++ b/intern/cycles/kernel/shaders/node_output_volume.osl
@@ -18,6 +18,5 @@
volume node_output_volume(closure color Volume = 0)
{
- Ci = Volume;
+ Ci = Volume;
}
-
diff --git a/intern/cycles/kernel/shaders/node_particle_info.osl b/intern/cycles/kernel/shaders/node_particle_info.osl
index 2a0252d5e45..e286c33a1ff 100644
--- a/intern/cycles/kernel/shaders/node_particle_info.osl
+++ b/intern/cycles/kernel/shaders/node_particle_info.osl
@@ -16,23 +16,21 @@
#include "stdosl.h"
-shader node_particle_info(
- output float Index = 0.0,
- output float Random = 0.0,
- output float Age = 0.0,
- output float Lifetime = 0.0,
- output point Location = point(0.0, 0.0, 0.0),
- output float Size = 0.0,
- output vector Velocity = point(0.0, 0.0, 0.0),
- output vector AngularVelocity = point(0.0, 0.0, 0.0))
+shader node_particle_info(output float Index = 0.0,
+ output float Random = 0.0,
+ output float Age = 0.0,
+ output float Lifetime = 0.0,
+ output point Location = point(0.0, 0.0, 0.0),
+ output float Size = 0.0,
+ output vector Velocity = point(0.0, 0.0, 0.0),
+ output vector AngularVelocity = point(0.0, 0.0, 0.0))
{
- getattribute("particle:index", Index);
- getattribute("particle:random", Random);
- getattribute("particle:age", Age);
- getattribute("particle:lifetime", Lifetime);
- getattribute("particle:location", Location);
- getattribute("particle:size", Size);
- getattribute("particle:velocity", Velocity);
- getattribute("particle:angular_velocity", AngularVelocity);
+ getattribute("particle:index", Index);
+ getattribute("particle:random", Random);
+ getattribute("particle:age", Age);
+ getattribute("particle:lifetime", Lifetime);
+ getattribute("particle:location", Location);
+ getattribute("particle:size", Size);
+ getattribute("particle:velocity", Velocity);
+ getattribute("particle:angular_velocity", AngularVelocity);
}
-
diff --git a/intern/cycles/kernel/shaders/node_principled_bsdf.osl b/intern/cycles/kernel/shaders/node_principled_bsdf.osl
index 6f54ba3a462..657ced9b6e6 100644
--- a/intern/cycles/kernel/shaders/node_principled_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_principled_bsdf.osl
@@ -17,111 +17,144 @@
#include "stdosl.h"
#include "node_fresnel.h"
-shader node_principled_bsdf(
- string distribution = "Multiscatter GGX",
- string subsurface_method = "burley",
- color BaseColor = color(0.8, 0.8, 0.8),
- float Subsurface = 0.0,
- vector SubsurfaceRadius = vector(1.0, 1.0, 1.0),
- color SubsurfaceColor = color(0.7, 0.1, 0.1),
- float Metallic = 0.0,
- float Specular = 0.5,
- float SpecularTint = 0.0,
- float Roughness = 0.5,
- float Anisotropic = 0.0,
- float AnisotropicRotation = 0.0,
- float Sheen = 0.0,
- float SheenTint = 0.5,
- float Clearcoat = 0.0,
- float ClearcoatRoughness = 0.03,
- float IOR = 1.45,
- float Transmission = 0.0,
- float TransmissionRoughness = 0.0,
- normal Normal = N,
- normal ClearcoatNormal = N,
- normal Tangent = normalize(dPdu),
- output closure color BSDF = 0)
+shader node_principled_bsdf(string distribution = "Multiscatter GGX",
+ string subsurface_method = "burley",
+ color BaseColor = color(0.8, 0.8, 0.8),
+ float Subsurface = 0.0,
+ vector SubsurfaceRadius = vector(1.0, 1.0, 1.0),
+ color SubsurfaceColor = color(0.7, 0.1, 0.1),
+ float Metallic = 0.0,
+ float Specular = 0.5,
+ float SpecularTint = 0.0,
+ float Roughness = 0.5,
+ float Anisotropic = 0.0,
+ float AnisotropicRotation = 0.0,
+ float Sheen = 0.0,
+ float SheenTint = 0.5,
+ float Clearcoat = 0.0,
+ float ClearcoatRoughness = 0.03,
+ float IOR = 1.45,
+ float Transmission = 0.0,
+ float TransmissionRoughness = 0.0,
+ normal Normal = N,
+ normal ClearcoatNormal = N,
+ normal Tangent = normalize(dPdu),
+ output closure color BSDF = 0)
{
- float f = max(IOR, 1e-5);
- float diffuse_weight = (1.0 - clamp(Metallic, 0.0, 1.0)) * (1.0 - clamp(Transmission, 0.0, 1.0));
- float final_transmission = clamp(Transmission, 0.0, 1.0) * (1.0 - clamp(Metallic, 0.0, 1.0));
- float specular_weight = (1.0 - final_transmission);
-
- vector T = Tangent;
-
- float m_cdlum = luminance(BaseColor);
- color m_ctint = m_cdlum > 0.0 ? BaseColor / m_cdlum : color(0.0, 0.0, 0.0); // normalize lum. to isolate hue+sat
-
- /* rotate tangent */
- if (AnisotropicRotation != 0.0)
- T = rotate(T, AnisotropicRotation * M_2PI, point(0.0, 0.0, 0.0), Normal);
-
- if (diffuse_weight > 1e-5) {
- if (Subsurface > 1e-5) {
- color mixed_ss_base_color = SubsurfaceColor * Subsurface + BaseColor * (1.0 - Subsurface);
- if (subsurface_method == "burley") {
- BSDF = mixed_ss_base_color * bssrdf("principled", Normal, Subsurface * SubsurfaceRadius, SubsurfaceColor, "roughness", Roughness);
- }
- else {
- BSDF = mixed_ss_base_color * bssrdf("principled_random_walk", Normal, Subsurface * SubsurfaceRadius, mixed_ss_base_color, "roughness", Roughness);
- }
- }
- else {
- BSDF = BaseColor * principled_diffuse(Normal, Roughness);
- }
-
- if (Sheen > 1e-5) {
- color sheen_color = color(1.0, 1.0, 1.0) * (1.0 - SheenTint) + m_ctint * SheenTint;
-
- BSDF = BSDF + sheen_color * Sheen * principled_sheen(Normal);
- }
-
- BSDF = BSDF * diffuse_weight;
- }
-
- if (specular_weight > 1e-5) {
- float aspect = sqrt(1.0 - Anisotropic * 0.9);
- float r2 = Roughness * Roughness;
-
- float alpha_x = r2 / aspect;
- float alpha_y = r2 * aspect;
-
- color tmp_col = color(1.0, 1.0, 1.0) * (1.0 - SpecularTint) + m_ctint * SpecularTint;
-
- color Cspec0 = (Specular * 0.08 * tmp_col) * (1.0 - Metallic) + BaseColor * Metallic;
-
- if (distribution == "GGX" || Roughness <= 0.075) {
- BSDF = BSDF + specular_weight * microfacet_ggx_aniso_fresnel(Normal, T, alpha_x, alpha_y, (2.0 / (1.0 - sqrt(0.08 * Specular))) - 1.0, BaseColor, Cspec0);
- } else {
- BSDF = BSDF + specular_weight * microfacet_multi_ggx_aniso_fresnel(Normal, T, alpha_x, alpha_y, (2.0 / (1.0 - sqrt(0.08 * Specular))) - 1.0, BaseColor, Cspec0);
- }
- }
-
- if (final_transmission > 1e-5) {
- color Cspec0 = BaseColor * SpecularTint + color(1.0, 1.0, 1.0) * (1.0 - SpecularTint);
- float eta = backfacing() ? 1.0 / f : f;
-
- if (distribution == "GGX" || Roughness <= 5e-2) {
- float cosNO = dot(Normal, I);
- float Fr = fresnel_dielectric_cos(cosNO, eta);
-
- float refl_roughness = Roughness;
- if (Roughness <= 1e-2)
- refl_roughness = 0.0;
-
- float transmission_roughness = refl_roughness;
- if (distribution == "GGX")
- transmission_roughness = 1.0 - (1.0 - refl_roughness) * (1.0 - TransmissionRoughness);
-
- BSDF = BSDF + final_transmission * (Fr * microfacet_ggx_fresnel(Normal, refl_roughness * refl_roughness, eta, BaseColor, Cspec0) +
- (1.0 - Fr) * BaseColor * microfacet_ggx_refraction(Normal, transmission_roughness * transmission_roughness, eta));
- } else {
- BSDF = BSDF + final_transmission * microfacet_multi_ggx_glass_fresnel(Normal, Roughness * Roughness, eta, BaseColor, Cspec0);
- }
- }
-
- if (Clearcoat > 1e-5) {
- BSDF = BSDF + principled_clearcoat(ClearcoatNormal, Clearcoat, ClearcoatRoughness * ClearcoatRoughness);
- }
+ float f = max(IOR, 1e-5);
+ float diffuse_weight = (1.0 - clamp(Metallic, 0.0, 1.0)) * (1.0 - clamp(Transmission, 0.0, 1.0));
+ float final_transmission = clamp(Transmission, 0.0, 1.0) * (1.0 - clamp(Metallic, 0.0, 1.0));
+ float specular_weight = (1.0 - final_transmission);
+
+ vector T = Tangent;
+
+ float m_cdlum = luminance(BaseColor);
+ color m_ctint = m_cdlum > 0.0 ? BaseColor / m_cdlum :
+ color(0.0, 0.0, 0.0); // normalize lum. to isolate hue+sat
+
+ /* rotate tangent */
+ if (AnisotropicRotation != 0.0)
+ T = rotate(T, AnisotropicRotation * M_2PI, point(0.0, 0.0, 0.0), Normal);
+
+ if (diffuse_weight > 1e-5) {
+ if (Subsurface > 1e-5) {
+ color mixed_ss_base_color = SubsurfaceColor * Subsurface + BaseColor * (1.0 - Subsurface);
+ if (subsurface_method == "burley") {
+ BSDF = mixed_ss_base_color * bssrdf("principled",
+ Normal,
+ Subsurface * SubsurfaceRadius,
+ SubsurfaceColor,
+ "roughness",
+ Roughness);
+ }
+ else {
+ BSDF = mixed_ss_base_color * bssrdf("principled_random_walk",
+ Normal,
+ Subsurface * SubsurfaceRadius,
+ mixed_ss_base_color,
+ "roughness",
+ Roughness);
+ }
+ }
+ else {
+ BSDF = BaseColor * principled_diffuse(Normal, Roughness);
+ }
+
+ if (Sheen > 1e-5) {
+ color sheen_color = color(1.0, 1.0, 1.0) * (1.0 - SheenTint) + m_ctint * SheenTint;
+
+ BSDF = BSDF + sheen_color * Sheen * principled_sheen(Normal);
+ }
+
+ BSDF = BSDF * diffuse_weight;
+ }
+
+ if (specular_weight > 1e-5) {
+ float aspect = sqrt(1.0 - Anisotropic * 0.9);
+ float r2 = Roughness * Roughness;
+
+ float alpha_x = r2 / aspect;
+ float alpha_y = r2 * aspect;
+
+ color tmp_col = color(1.0, 1.0, 1.0) * (1.0 - SpecularTint) + m_ctint * SpecularTint;
+
+ color Cspec0 = (Specular * 0.08 * tmp_col) * (1.0 - Metallic) + BaseColor * Metallic;
+
+ if (distribution == "GGX" || Roughness <= 0.075) {
+ BSDF = BSDF + specular_weight *
+ microfacet_ggx_aniso_fresnel(Normal,
+ T,
+ alpha_x,
+ alpha_y,
+ (2.0 / (1.0 - sqrt(0.08 * Specular))) - 1.0,
+ BaseColor,
+ Cspec0);
+ }
+ else {
+ BSDF = BSDF + specular_weight * microfacet_multi_ggx_aniso_fresnel(
+ Normal,
+ T,
+ alpha_x,
+ alpha_y,
+ (2.0 / (1.0 - sqrt(0.08 * Specular))) - 1.0,
+ BaseColor,
+ Cspec0);
+ }
+ }
+
+ if (final_transmission > 1e-5) {
+ color Cspec0 = BaseColor * SpecularTint + color(1.0, 1.0, 1.0) * (1.0 - SpecularTint);
+ float eta = backfacing() ? 1.0 / f : f;
+
+ if (distribution == "GGX" || Roughness <= 5e-2) {
+ float cosNO = dot(Normal, I);
+ float Fr = fresnel_dielectric_cos(cosNO, eta);
+
+ float refl_roughness = Roughness;
+ if (Roughness <= 1e-2)
+ refl_roughness = 0.0;
+
+ float transmission_roughness = refl_roughness;
+ if (distribution == "GGX")
+ transmission_roughness = 1.0 - (1.0 - refl_roughness) * (1.0 - TransmissionRoughness);
+
+ BSDF = BSDF +
+ final_transmission *
+ (Fr * microfacet_ggx_fresnel(
+ Normal, refl_roughness * refl_roughness, eta, BaseColor, Cspec0) +
+ (1.0 - Fr) * BaseColor *
+ microfacet_ggx_refraction(
+ Normal, transmission_roughness * transmission_roughness, eta));
+ }
+ else {
+ BSDF = BSDF +
+ final_transmission * microfacet_multi_ggx_glass_fresnel(
+ Normal, Roughness * Roughness, eta, BaseColor, Cspec0);
+ }
+ }
+
+ if (Clearcoat > 1e-5) {
+ BSDF = BSDF + principled_clearcoat(
+ ClearcoatNormal, Clearcoat, ClearcoatRoughness * ClearcoatRoughness);
+ }
}
-
diff --git a/intern/cycles/kernel/shaders/node_principled_hair_bsdf.osl b/intern/cycles/kernel/shaders/node_principled_hair_bsdf.osl
index 757a88f8ece..bf986438fca 100644
--- a/intern/cycles/kernel/shaders/node_principled_hair_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_principled_hair_bsdf.osl
@@ -18,88 +18,88 @@
color log3(color a)
{
- return color(log(a[0]), log(a[1]), log(a[2]));
+ return color(log(a[0]), log(a[1]), log(a[2]));
}
color sigma_from_concentration(float eumelanin, float pheomelanin)
{
- return eumelanin*color(0.506, 0.841, 1.653) + pheomelanin*color(0.343, 0.733, 1.924);
+ return eumelanin * color(0.506, 0.841, 1.653) + pheomelanin * color(0.343, 0.733, 1.924);
}
color sigma_from_reflectance(color c, float azimuthal_roughness)
{
- float x = azimuthal_roughness;
- float roughness_fac = (((((0.245*x) + 5.574)*x - 10.73)*x + 2.532)*x - 0.215)*x + 5.969;
- color sigma = log3(c) / roughness_fac;
- return sigma * sigma;
+ float x = azimuthal_roughness;
+ float roughness_fac = (((((0.245 * x) + 5.574) * x - 10.73) * x + 2.532) * x - 0.215) * x +
+ 5.969;
+ color sigma = log3(c) / roughness_fac;
+ return sigma * sigma;
}
-shader node_principled_hair_bsdf(
- color Color = color(0.017513, 0.005763, 0.002059),
- float Melanin = 0.8,
- float MelaninRedness = 1.0,
- float RandomColor = 0.0,
- color Tint = 1.0,
- color AbsorptionCoefficient = color(0.245531, 0.52, 1.365),
- normal Normal = Ng,
- string parametrization = "Absorption coefficient",
- float Offset = radians(2),
- float Roughness = 0.3,
- float RadialRoughness = 0.3,
- float RandomRoughness = 0.0,
- float Coat = 0.0,
- float IOR = 1.55,
- string AttrRandom = "geom:curve_random",
- float Random = 0.0,
+shader node_principled_hair_bsdf(color Color = color(0.017513, 0.005763, 0.002059),
+ float Melanin = 0.8,
+ float MelaninRedness = 1.0,
+ float RandomColor = 0.0,
+ color Tint = 1.0,
+ color AbsorptionCoefficient = color(0.245531, 0.52, 1.365),
+ normal Normal = Ng,
+ string parametrization = "Absorption coefficient",
+ float Offset = radians(2),
+ float Roughness = 0.3,
+ float RadialRoughness = 0.3,
+ float RandomRoughness = 0.0,
+ float Coat = 0.0,
+ float IOR = 1.55,
+ string AttrRandom = "geom:curve_random",
+ float Random = 0.0,
- output closure color BSDF = 0)
+ output closure color BSDF = 0)
{
- /* Get random value from curve in none is specified. */
- float random_value = 0.0;
+ /* Get random value from curve in none is specified. */
+ float random_value = 0.0;
- if (isconnected(Random)) {
- random_value = Random;
- }
- else {
- getattribute(AttrRandom, random_value);
- }
+ if (isconnected(Random)) {
+ random_value = Random;
+ }
+ else {
+ getattribute(AttrRandom, random_value);
+ }
- /* Compute roughness. */
- float factor_random_roughness = 1.0 + 2.0*(random_value - 0.5)*RandomRoughness;
- float m0_roughness = 1.0 - clamp(Coat, 0.0, 1.0);
- float roughness = Roughness*factor_random_roughness;
- float radial_roughness = RadialRoughness*factor_random_roughness;
+ /* Compute roughness. */
+ float factor_random_roughness = 1.0 + 2.0 * (random_value - 0.5) * RandomRoughness;
+ float m0_roughness = 1.0 - clamp(Coat, 0.0, 1.0);
+ float roughness = Roughness * factor_random_roughness;
+ float radial_roughness = RadialRoughness * factor_random_roughness;
- /* Compute absorption. */
- color sigma;
+ /* Compute absorption. */
+ color sigma;
- if (parametrization == "Absorption coefficient") {
- sigma = AbsorptionCoefficient;
- }
- else if (parametrization == "Melanin concentration") {
- /* Randomize melanin. */
- float factor_random_color = 1.0 + 2.0*(random_value - 0.5) * RandomColor;
- float melanin = Melanin * factor_random_color;
+ if (parametrization == "Absorption coefficient") {
+ sigma = AbsorptionCoefficient;
+ }
+ else if (parametrization == "Melanin concentration") {
+ /* Randomize melanin. */
+ float factor_random_color = 1.0 + 2.0 * (random_value - 0.5) * RandomColor;
+ float melanin = Melanin * factor_random_color;
- /* Map melanin 0..inf from more perceptually linear 0..1. */
- melanin = -log(max(1.0 - melanin, 0.0001));
+ /* Map melanin 0..inf from more perceptually linear 0..1. */
+ melanin = -log(max(1.0 - melanin, 0.0001));
- /* Benedikt Bitterli's melanin ratio remapping. */
- float eumelanin = melanin * (1.0 - MelaninRedness);
- float pheomelanin = melanin * MelaninRedness;
- color melanin_sigma = sigma_from_concentration(eumelanin, pheomelanin);
+ /* Benedikt Bitterli's melanin ratio remapping. */
+ float eumelanin = melanin * (1.0 - MelaninRedness);
+ float pheomelanin = melanin * MelaninRedness;
+ color melanin_sigma = sigma_from_concentration(eumelanin, pheomelanin);
- /* Optional tint. */
- color tint_sigma = sigma_from_reflectance(Tint, radial_roughness);
- sigma = melanin_sigma + tint_sigma;
- }
- else if (parametrization == "Direct coloring"){
- sigma = sigma_from_reflectance(Color, radial_roughness);
- }
- else {
- /* Fallback to brownish hair, same as defaults for melanin. */
- sigma = sigma_from_concentration(0.0, 0.8054375);
- }
+ /* Optional tint. */
+ color tint_sigma = sigma_from_reflectance(Tint, radial_roughness);
+ sigma = melanin_sigma + tint_sigma;
+ }
+ else if (parametrization == "Direct coloring") {
+ sigma = sigma_from_reflectance(Color, radial_roughness);
+ }
+ else {
+ /* Fallback to brownish hair, same as defaults for melanin. */
+ sigma = sigma_from_concentration(0.0, 0.8054375);
+ }
- BSDF = principled_hair(Normal, sigma, roughness, radial_roughness, m0_roughness, Offset, IOR);
+ BSDF = principled_hair(Normal, sigma, roughness, radial_roughness, m0_roughness, Offset, IOR);
}
diff --git a/intern/cycles/kernel/shaders/node_principled_volume.osl b/intern/cycles/kernel/shaders/node_principled_volume.osl
index ea8d6ab12c5..39cf6837eb2 100644
--- a/intern/cycles/kernel/shaders/node_principled_volume.osl
+++ b/intern/cycles/kernel/shaders/node_principled_volume.osl
@@ -16,80 +16,78 @@
#include "stdosl.h"
-shader node_principled_volume(
- color Color = color(0.5, 0.5, 0.5),
- float Density = 1.0,
- float Anisotropy = 0.0,
- color AbsorptionColor = color(0.0, 0.0, 0.0),
- float EmissionStrength = 0.0,
- color EmissionColor = color(1.0, 1.0, 1.0),
- float BlackbodyIntensity = 0.0,
- color BlackbodyTint = color(1.0, 1.0, 1.0),
- float Temperature = 1500.0,
- string DensityAttribute = "geom:density",
- string ColorAttribute = "geom:color",
- string TemperatureAttribute = "geom:temperature",
- output closure color Volume = 0)
+shader node_principled_volume(color Color = color(0.5, 0.5, 0.5),
+ float Density = 1.0,
+ float Anisotropy = 0.0,
+ color AbsorptionColor = color(0.0, 0.0, 0.0),
+ float EmissionStrength = 0.0,
+ color EmissionColor = color(1.0, 1.0, 1.0),
+ float BlackbodyIntensity = 0.0,
+ color BlackbodyTint = color(1.0, 1.0, 1.0),
+ float Temperature = 1500.0,
+ string DensityAttribute = "geom:density",
+ string ColorAttribute = "geom:color",
+ string TemperatureAttribute = "geom:temperature",
+ output closure color Volume = 0)
{
- /* Compute density. */
- float primitive_density = 1.0;
- float density = max(Density, 0.0);
+ /* Compute density. */
+ float primitive_density = 1.0;
+ float density = max(Density, 0.0);
- if(density > 1e-5) {
- if(getattribute(DensityAttribute, primitive_density)) {
- density = max(density * primitive_density, 0.0);
- }
- }
+ if (density > 1e-5) {
+ if (getattribute(DensityAttribute, primitive_density)) {
+ density = max(density * primitive_density, 0.0);
+ }
+ }
- if(density > 1e-5) {
- /* Compute scattering color. */
- color scatter_color = Color;
- color primitive_color;
- if(getattribute(ColorAttribute, primitive_color)) {
- scatter_color *= primitive_color;
- }
+ if (density > 1e-5) {
+ /* Compute scattering color. */
+ color scatter_color = Color;
+ color primitive_color;
+ if (getattribute(ColorAttribute, primitive_color)) {
+ scatter_color *= primitive_color;
+ }
- /* Add scattering and absorption closures. */
- color scatter_coeff = scatter_color;
- color absorption_color = sqrt(max(AbsorptionColor, 0.0));
- color absorption_coeff = max(1.0 - scatter_color, 0.0) * max(1.0 - absorption_color, 0.0);
- Volume = scatter_coeff * density * henyey_greenstein(Anisotropy) +
- absorption_coeff * density * absorption();
- }
+ /* Add scattering and absorption closures. */
+ color scatter_coeff = scatter_color;
+ color absorption_color = sqrt(max(AbsorptionColor, 0.0));
+ color absorption_coeff = max(1.0 - scatter_color, 0.0) * max(1.0 - absorption_color, 0.0);
+ Volume = scatter_coeff * density * henyey_greenstein(Anisotropy) +
+ absorption_coeff * density * absorption();
+ }
- /* Compute emission. */
- float emission_strength = max(EmissionStrength, 0.0);
- float blackbody_intensity = BlackbodyIntensity;
+ /* Compute emission. */
+ float emission_strength = max(EmissionStrength, 0.0);
+ float blackbody_intensity = BlackbodyIntensity;
- if(emission_strength > 1e-5) {
- Volume += emission_strength * EmissionColor * emission();
- }
+ if (emission_strength > 1e-5) {
+ Volume += emission_strength * EmissionColor * emission();
+ }
- if(blackbody_intensity > 1e-3) {
- float T = Temperature;
+ if (blackbody_intensity > 1e-3) {
+ float T = Temperature;
- /* Add temperature from attribute if available. */
- float temperature;
- if(getattribute(TemperatureAttribute, temperature)) {
- T *= max(temperature, 0.0);
- }
+ /* Add temperature from attribute if available. */
+ float temperature;
+ if (getattribute(TemperatureAttribute, temperature)) {
+ T *= max(temperature, 0.0);
+ }
- T = max(T, 0.0);
+ T = max(T, 0.0);
- /* Stefan-Boltzman law. */
- float T4 = (T * T) * (T * T);
- float sigma = 5.670373e-8 * 1e-6 / M_PI;
- float intensity = sigma * mix(1.0, T4, blackbody_intensity);
+ /* Stefan-Boltzman law. */
+ float T4 = (T * T) * (T * T);
+ float sigma = 5.670373e-8 * 1e-6 / M_PI;
+ float intensity = sigma * mix(1.0, T4, blackbody_intensity);
- if(intensity > 1e-5) {
- color bb = blackbody(T);
- float l = luminance(bb);
+ if (intensity > 1e-5) {
+ color bb = blackbody(T);
+ float l = luminance(bb);
- if(l != 0.0) {
- bb *= BlackbodyTint * intensity / l;
- Volume += bb * emission();
- }
- }
- }
+ if (l != 0.0) {
+ bb *= BlackbodyTint * intensity / l;
+ Volume += bb * emission();
+ }
+ }
+ }
}
-
diff --git a/intern/cycles/kernel/shaders/node_ramp_util.h b/intern/cycles/kernel/shaders/node_ramp_util.h
index d07d5a98316..f7fb07b257d 100644
--- a/intern/cycles/kernel/shaders/node_ramp_util.h
+++ b/intern/cycles/kernel/shaders/node_ramp_util.h
@@ -18,72 +18,76 @@
color rgb_ramp_lookup(color ramp[], float at, int interpolate, int extrapolate)
{
- float f = at;
- int table_size = arraylength(ramp);
+ float f = at;
+ int table_size = arraylength(ramp);
- if ((f < 0.0 || f > 1.0) && extrapolate) {
- color t0, dy;
- if (f < 0.0) {
- t0 = ramp[0];
- dy = t0 - ramp[1];
- f = -f;
- }
- else {
- t0 = ramp[table_size - 1];
- dy = t0 - ramp[table_size - 2];
- f = f - 1.0;
- }
- return t0 + dy * f * (table_size - 1);
- }
+ if ((f < 0.0 || f > 1.0) && extrapolate) {
+ color t0, dy;
+ if (f < 0.0) {
+ t0 = ramp[0];
+ dy = t0 - ramp[1];
+ f = -f;
+ }
+ else {
+ t0 = ramp[table_size - 1];
+ dy = t0 - ramp[table_size - 2];
+ f = f - 1.0;
+ }
+ return t0 + dy * f * (table_size - 1);
+ }
- f = clamp(at, 0.0, 1.0) * (table_size - 1);
+ f = clamp(at, 0.0, 1.0) * (table_size - 1);
- /* clamp int as well in case of NaN */
- int i = (int)f;
- if (i < 0) i = 0;
- if (i >= table_size) i = table_size - 1;
- float t = f - (float)i;
+ /* clamp int as well in case of NaN */
+ int i = (int)f;
+ if (i < 0)
+ i = 0;
+ if (i >= table_size)
+ i = table_size - 1;
+ float t = f - (float)i;
- color result = ramp[i];
+ color result = ramp[i];
- if (interpolate && t > 0.0)
- result = (1.0 - t) * result + t * ramp[i + 1];
+ if (interpolate && t > 0.0)
+ result = (1.0 - t) * result + t * ramp[i + 1];
- return result;
+ return result;
}
float rgb_ramp_lookup(float ramp[], float at, int interpolate, int extrapolate)
{
- float f = at;
- int table_size = arraylength(ramp);
+ float f = at;
+ int table_size = arraylength(ramp);
- if ((f < 0.0 || f > 1.0) && extrapolate) {
- float t0, dy;
- if (f < 0.0) {
- t0 = ramp[0];
- dy = t0 - ramp[1];
- f = -f;
- }
- else {
- t0 = ramp[table_size - 1];
- dy = t0 - ramp[table_size - 2];
- f = f - 1.0;
- }
- return t0 + dy * f * (table_size - 1);
- }
+ if ((f < 0.0 || f > 1.0) && extrapolate) {
+ float t0, dy;
+ if (f < 0.0) {
+ t0 = ramp[0];
+ dy = t0 - ramp[1];
+ f = -f;
+ }
+ else {
+ t0 = ramp[table_size - 1];
+ dy = t0 - ramp[table_size - 2];
+ f = f - 1.0;
+ }
+ return t0 + dy * f * (table_size - 1);
+ }
- f = clamp(at, 0.0, 1.0) * (table_size - 1);
+ f = clamp(at, 0.0, 1.0) * (table_size - 1);
- /* clamp int as well in case of NaN */
- int i = (int)f;
- if (i < 0) i = 0;
- if (i >= table_size) i = table_size - 1;
- float t = f - (float)i;
+ /* clamp int as well in case of NaN */
+ int i = (int)f;
+ if (i < 0)
+ i = 0;
+ if (i >= table_size)
+ i = table_size - 1;
+ float t = f - (float)i;
- float result = ramp[i];
+ float result = ramp[i];
- if (interpolate && t > 0.0)
- result = (1.0 - t) * result + t * ramp[i + 1];
+ if (interpolate && t > 0.0)
+ result = (1.0 - t) * result + t * ramp[i + 1];
- return result;
+ return result;
}
diff --git a/intern/cycles/kernel/shaders/node_refraction_bsdf.osl b/intern/cycles/kernel/shaders/node_refraction_bsdf.osl
index eaab7282243..941d99dd44d 100644
--- a/intern/cycles/kernel/shaders/node_refraction_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_refraction_bsdf.osl
@@ -16,23 +16,21 @@
#include "stdosl.h"
-shader node_refraction_bsdf(
- color Color = 0.8,
- string distribution = "sharp",
- float Roughness = 0.2,
- float IOR = 1.45,
- normal Normal = N,
- output closure color BSDF = 0)
+shader node_refraction_bsdf(color Color = 0.8,
+ string distribution = "sharp",
+ float Roughness = 0.2,
+ float IOR = 1.45,
+ normal Normal = N,
+ output closure color BSDF = 0)
{
- float f = max(IOR, 1e-5);
- float eta = backfacing() ? 1.0 / f : f;
- float roughness = Roughness * Roughness;
+ float f = max(IOR, 1e-5);
+ float eta = backfacing() ? 1.0 / f : f;
+ float roughness = Roughness * Roughness;
- if (distribution == "sharp")
- BSDF = Color * refraction(Normal, eta);
- else if (distribution == "beckmann")
- BSDF = Color * microfacet_beckmann_refraction(Normal, roughness, eta);
- else if (distribution == "GGX")
- BSDF = Color * microfacet_ggx_refraction(Normal, roughness, eta);
+ if (distribution == "sharp")
+ BSDF = Color * refraction(Normal, eta);
+ else if (distribution == "beckmann")
+ BSDF = Color * microfacet_beckmann_refraction(Normal, roughness, eta);
+ else if (distribution == "GGX")
+ BSDF = Color * microfacet_ggx_refraction(Normal, roughness, eta);
}
-
diff --git a/intern/cycles/kernel/shaders/node_rgb_curves.osl b/intern/cycles/kernel/shaders/node_rgb_curves.osl
index 0d5eeea5c43..e34eb027cc3 100644
--- a/intern/cycles/kernel/shaders/node_rgb_curves.osl
+++ b/intern/cycles/kernel/shaders/node_rgb_curves.osl
@@ -17,25 +17,23 @@
#include "stdosl.h"
#include "node_ramp_util.h"
-shader node_rgb_curves(
- color ramp[] = {0.0},
- float min_x = 0.0,
- float max_x = 1.0,
+shader node_rgb_curves(color ramp[] = {0.0},
+ float min_x = 0.0,
+ float max_x = 1.0,
- color ColorIn = 0.0,
- float Fac = 0.0,
- output color ColorOut = 0.0)
+ color ColorIn = 0.0,
+ float Fac = 0.0,
+ output color ColorOut = 0.0)
{
- color c = (ColorIn - color(min_x, min_x, min_x)) / (max_x - min_x);
+ color c = (ColorIn - color(min_x, min_x, min_x)) / (max_x - min_x);
- color r = rgb_ramp_lookup(ramp, c[0], 1, 1);
- color g = rgb_ramp_lookup(ramp, c[1], 1, 1);
- color b = rgb_ramp_lookup(ramp, c[2], 1, 1);
+ color r = rgb_ramp_lookup(ramp, c[0], 1, 1);
+ color g = rgb_ramp_lookup(ramp, c[1], 1, 1);
+ color b = rgb_ramp_lookup(ramp, c[2], 1, 1);
- ColorOut[0] = r[0];
- ColorOut[1] = g[1];
- ColorOut[2] = b[2];
+ ColorOut[0] = r[0];
+ ColorOut[1] = g[1];
+ ColorOut[2] = b[2];
- ColorOut = mix(ColorIn, ColorOut, Fac);
+ ColorOut = mix(ColorIn, ColorOut, Fac);
}
-
diff --git a/intern/cycles/kernel/shaders/node_rgb_ramp.osl b/intern/cycles/kernel/shaders/node_rgb_ramp.osl
index 4e7d8fdcf65..c9f9746a4fb 100644
--- a/intern/cycles/kernel/shaders/node_rgb_ramp.osl
+++ b/intern/cycles/kernel/shaders/node_rgb_ramp.osl
@@ -17,16 +17,14 @@
#include "stdosl.h"
#include "node_ramp_util.h"
-shader node_rgb_ramp(
- color ramp_color[] = {0.0},
- float ramp_alpha[] = {0.0},
- int interpolate = 1,
+shader node_rgb_ramp(color ramp_color[] = {0.0},
+ float ramp_alpha[] = {0.0},
+ int interpolate = 1,
- float Fac = 0.0,
- output color Color = 0.0,
- output float Alpha = 1.0)
+ float Fac = 0.0,
+ output color Color = 0.0,
+ output float Alpha = 1.0)
{
- Color = rgb_ramp_lookup(ramp_color, Fac, interpolate, 0);
- Alpha = rgb_ramp_lookup(ramp_alpha, Fac, interpolate, 0);
+ Color = rgb_ramp_lookup(ramp_color, Fac, interpolate, 0);
+ Alpha = rgb_ramp_lookup(ramp_alpha, Fac, interpolate, 0);
}
-
diff --git a/intern/cycles/kernel/shaders/node_rgb_to_bw.osl b/intern/cycles/kernel/shaders/node_rgb_to_bw.osl
index 903dfcdc881..837d6caf5fc 100644
--- a/intern/cycles/kernel/shaders/node_rgb_to_bw.osl
+++ b/intern/cycles/kernel/shaders/node_rgb_to_bw.osl
@@ -16,10 +16,7 @@
#include "stdosl.h"
-shader node_rgb_to_bw(
- color Color = 0.0,
- output float Val = 0.0)
+shader node_rgb_to_bw(color Color = 0.0, output float Val = 0.0)
{
- Val = Color[0] * 0.2126 + Color[1] * 0.7152 + Color[2] * 0.0722;
+ Val = Color[0] * 0.2126 + Color[1] * 0.7152 + Color[2] * 0.0722;
}
-
diff --git a/intern/cycles/kernel/shaders/node_scatter_volume.osl b/intern/cycles/kernel/shaders/node_scatter_volume.osl
index 002e2750fca..fce5716f372 100644
--- a/intern/cycles/kernel/shaders/node_scatter_volume.osl
+++ b/intern/cycles/kernel/shaders/node_scatter_volume.osl
@@ -16,12 +16,10 @@
#include "stdosl.h"
-shader node_scatter_volume(
- color Color = color(0.8, 0.8, 0.8),
- float Density = 1.0,
- float Anisotropy = 0.0,
- output closure color Volume = 0)
+shader node_scatter_volume(color Color = color(0.8, 0.8, 0.8),
+ float Density = 1.0,
+ float Anisotropy = 0.0,
+ output closure color Volume = 0)
{
- Volume = (Color * max(Density, 0.0)) * henyey_greenstein(Anisotropy);
+ Volume = (Color * max(Density, 0.0)) * henyey_greenstein(Anisotropy);
}
-
diff --git a/intern/cycles/kernel/shaders/node_separate_hsv.osl b/intern/cycles/kernel/shaders/node_separate_hsv.osl
index 2a804040294..c77ed1f3755 100644
--- a/intern/cycles/kernel/shaders/node_separate_hsv.osl
+++ b/intern/cycles/kernel/shaders/node_separate_hsv.osl
@@ -17,15 +17,14 @@
#include "stdosl.h"
#include "node_color.h"
-shader node_separate_hsv(
- color Color = 0.8,
- output float H = 0.0,
- output float S = 0.0,
- output float V = 0.0)
+shader node_separate_hsv(color Color = 0.8,
+ output float H = 0.0,
+ output float S = 0.0,
+ output float V = 0.0)
{
- color col = rgb_to_hsv(Color);
-
- H = col[0];
- S = col[1];
- V = col[2];
+ color col = rgb_to_hsv(Color);
+
+ H = col[0];
+ S = col[1];
+ V = col[2];
}
diff --git a/intern/cycles/kernel/shaders/node_separate_rgb.osl b/intern/cycles/kernel/shaders/node_separate_rgb.osl
index 43d9e3aa4b1..ee64add27e2 100644
--- a/intern/cycles/kernel/shaders/node_separate_rgb.osl
+++ b/intern/cycles/kernel/shaders/node_separate_rgb.osl
@@ -16,13 +16,12 @@
#include "stdosl.h"
-shader node_separate_rgb(
- color Image = 0.8,
- output float R = 0.0,
- output float G = 0.0,
- output float B = 0.0)
+shader node_separate_rgb(color Image = 0.8,
+ output float R = 0.0,
+ output float G = 0.0,
+ output float B = 0.0)
{
- R = Image[0];
- G = Image[1];
- B = Image[2];
+ R = Image[0];
+ G = Image[1];
+ B = Image[2];
}
diff --git a/intern/cycles/kernel/shaders/node_separate_xyz.osl b/intern/cycles/kernel/shaders/node_separate_xyz.osl
index e1963a1902f..8a563f5e920 100644
--- a/intern/cycles/kernel/shaders/node_separate_xyz.osl
+++ b/intern/cycles/kernel/shaders/node_separate_xyz.osl
@@ -16,13 +16,12 @@
#include "stdosl.h"
-shader node_separate_xyz(
- vector Vector = 0.8,
- output float X = 0.0,
- output float Y = 0.0,
- output float Z = 0.0)
+shader node_separate_xyz(vector Vector = 0.8,
+ output float X = 0.0,
+ output float Y = 0.0,
+ output float Z = 0.0)
{
- X = Vector[0];
- Y = Vector[1];
- Z = Vector[2];
+ X = Vector[0];
+ Y = Vector[1];
+ Z = Vector[2];
}
diff --git a/intern/cycles/kernel/shaders/node_set_normal.osl b/intern/cycles/kernel/shaders/node_set_normal.osl
index 7ca7ac9350c..9541b829ef7 100644
--- a/intern/cycles/kernel/shaders/node_set_normal.osl
+++ b/intern/cycles/kernel/shaders/node_set_normal.osl
@@ -16,11 +16,8 @@
#include "stdosl.h"
-surface node_set_normal(
- normal Direction = N,
- output normal Normal = N)
+surface node_set_normal(normal Direction = N, output normal Normal = N)
{
- N = Direction;
- Normal = Direction;
+ N = Direction;
+ Normal = Direction;
}
-
diff --git a/intern/cycles/kernel/shaders/node_sky_texture.osl b/intern/cycles/kernel/shaders/node_sky_texture.osl
index a6c187d15f2..9b29e5489c2 100644
--- a/intern/cycles/kernel/shaders/node_sky_texture.osl
+++ b/intern/cycles/kernel/shaders/node_sky_texture.osl
@@ -19,115 +19,122 @@
float sky_angle_between(float thetav, float phiv, float theta, float phi)
{
- float cospsi = sin(thetav) * sin(theta) * cos(phi - phiv) + cos(thetav) * cos(theta);
+ float cospsi = sin(thetav) * sin(theta) * cos(phi - phiv) + cos(thetav) * cos(theta);
- if (cospsi > 1.0)
- return 0.0;
- if (cospsi < -1.0)
- return M_PI;
+ if (cospsi > 1.0)
+ return 0.0;
+ if (cospsi < -1.0)
+ return M_PI;
- return acos(cospsi);
+ return acos(cospsi);
}
vector sky_spherical_coordinates(vector dir)
{
- return vector(acos(dir[2]), atan2(dir[0], dir[1]), 0);
+ return vector(acos(dir[2]), atan2(dir[0], dir[1]), 0);
}
/* Preetham */
float sky_perez_function(float lam[9], float theta, float gamma)
{
- float ctheta = cos(theta);
- float cgamma = cos(gamma);
+ float ctheta = cos(theta);
+ float cgamma = cos(gamma);
- return (1.0 + lam[0] * exp(lam[1] / ctheta)) * (1.0 + lam[2] * exp(lam[3] * gamma) + lam[4] * cgamma * cgamma);
+ return (1.0 + lam[0] * exp(lam[1] / ctheta)) *
+ (1.0 + lam[2] * exp(lam[3] * gamma) + lam[4] * cgamma * cgamma);
}
color sky_radiance_old(normal dir,
- float sunphi, float suntheta, color radiance,
- float config_x[9], float config_y[9], float config_z[9])
+ float sunphi,
+ float suntheta,
+ color radiance,
+ float config_x[9],
+ float config_y[9],
+ float config_z[9])
{
- /* convert vector to spherical coordinates */
- vector spherical = sky_spherical_coordinates(dir);
- float theta = spherical[0];
- float phi = spherical[1];
+ /* convert vector to spherical coordinates */
+ vector spherical = sky_spherical_coordinates(dir);
+ float theta = spherical[0];
+ float phi = spherical[1];
- /* angle between sun direction and dir */
- float gamma = sky_angle_between(theta, phi, suntheta, sunphi);
+ /* angle between sun direction and dir */
+ float gamma = sky_angle_between(theta, phi, suntheta, sunphi);
- /* clamp theta to horizon */
- theta = min(theta, M_PI_2 - 0.001);
+ /* clamp theta to horizon */
+ theta = min(theta, M_PI_2 - 0.001);
- /* compute xyY color space values */
- float x = radiance[1] * sky_perez_function(config_y, theta, gamma);
- float y = radiance[2] * sky_perez_function(config_z, theta, gamma);
- float Y = radiance[0] * sky_perez_function(config_x, theta, gamma);
+ /* compute xyY color space values */
+ float x = radiance[1] * sky_perez_function(config_y, theta, gamma);
+ float y = radiance[2] * sky_perez_function(config_z, theta, gamma);
+ float Y = radiance[0] * sky_perez_function(config_x, theta, gamma);
- /* convert to RGB */
- color xyz = xyY_to_xyz(x, y, Y);
- return xyz_to_rgb(xyz[0], xyz[1], xyz[2]);
+ /* convert to RGB */
+ color xyz = xyY_to_xyz(x, y, Y);
+ return xyz_to_rgb(xyz[0], xyz[1], xyz[2]);
}
/* Hosek / Wilkie */
float sky_radiance_internal(float config[9], float theta, float gamma)
{
- float ctheta = cos(theta);
- float cgamma = cos(gamma);
-
- float expM = exp(config[4] * gamma);
- float rayM = cgamma * cgamma;
- float mieM = (1.0 + rayM) / pow((1.0 + config[8] * config[8] - 2.0 * config[8] * cgamma), 1.5);
- float zenith = sqrt(ctheta);
-
- return (1.0 + config[0] * exp(config[1] / (ctheta + 0.01))) *
- (config[2] + config[3] * expM + config[5] * rayM + config[6] * mieM + config[7] * zenith);
+ float ctheta = cos(theta);
+ float cgamma = cos(gamma);
+
+ float expM = exp(config[4] * gamma);
+ float rayM = cgamma * cgamma;
+ float mieM = (1.0 + rayM) / pow((1.0 + config[8] * config[8] - 2.0 * config[8] * cgamma), 1.5);
+ float zenith = sqrt(ctheta);
+
+ return (1.0 + config[0] * exp(config[1] / (ctheta + 0.01))) *
+ (config[2] + config[3] * expM + config[5] * rayM + config[6] * mieM + config[7] * zenith);
}
color sky_radiance_new(normal dir,
- float sunphi, float suntheta, color radiance,
- float config_x[9], float config_y[9], float config_z[9])
+ float sunphi,
+ float suntheta,
+ color radiance,
+ float config_x[9],
+ float config_y[9],
+ float config_z[9])
{
- /* convert vector to spherical coordinates */
- vector spherical = sky_spherical_coordinates(dir);
- float theta = spherical[0];
- float phi = spherical[1];
+ /* convert vector to spherical coordinates */
+ vector spherical = sky_spherical_coordinates(dir);
+ float theta = spherical[0];
+ float phi = spherical[1];
- /* angle between sun direction and dir */
- float gamma = sky_angle_between(theta, phi, suntheta, sunphi);
+ /* angle between sun direction and dir */
+ float gamma = sky_angle_between(theta, phi, suntheta, sunphi);
- /* clamp theta to horizon */
- theta = min(theta, M_PI_2 - 0.001);
+ /* clamp theta to horizon */
+ theta = min(theta, M_PI_2 - 0.001);
- /* compute xyz color space values */
- float x = sky_radiance_internal(config_x, theta, gamma) * radiance[0];
- float y = sky_radiance_internal(config_y, theta, gamma) * radiance[1];
- float z = sky_radiance_internal(config_z, theta, gamma) * radiance[2];
+ /* compute xyz color space values */
+ float x = sky_radiance_internal(config_x, theta, gamma) * radiance[0];
+ float y = sky_radiance_internal(config_y, theta, gamma) * radiance[1];
+ float z = sky_radiance_internal(config_z, theta, gamma) * radiance[2];
- /* convert to RGB and adjust strength */
- return xyz_to_rgb(x, y, z) * (M_2PI / 683);
+ /* convert to RGB and adjust strength */
+ return xyz_to_rgb(x, y, z) * (M_2PI / 683);
}
-shader node_sky_texture(
- int use_mapping = 0,
- matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- vector Vector = P,
- string type = "hosek_wilkie",
- float theta = 0.0,
- float phi = 0.0,
- color radiance = color(0.0, 0.0, 0.0),
- float config_x[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- float config_y[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- float config_z[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- output color Color = color(0.0, 0.0, 0.0))
+shader node_sky_texture(int use_mapping = 0,
+ matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+ vector Vector = P,
+ string type = "hosek_wilkie",
+ float theta = 0.0,
+ float phi = 0.0,
+ color radiance = color(0.0, 0.0, 0.0),
+ float config_x[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ float config_y[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ float config_z[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ output color Color = color(0.0, 0.0, 0.0))
{
- vector p = Vector;
-
- if (use_mapping)
- p = transform(mapping, p);
-
- if (type == "hosek_wilkie")
- Color = sky_radiance_new(p, phi, theta, radiance, config_x, config_y, config_z);
- else
- Color = sky_radiance_old(p, phi, theta, radiance, config_x, config_y, config_z);
-}
+ vector p = Vector;
+ if (use_mapping)
+ p = transform(mapping, p);
+
+ if (type == "hosek_wilkie")
+ Color = sky_radiance_new(p, phi, theta, radiance, config_x, config_y, config_z);
+ else
+ Color = sky_radiance_old(p, phi, theta, radiance, config_x, config_y, config_z);
+}
diff --git a/intern/cycles/kernel/shaders/node_subsurface_scattering.osl b/intern/cycles/kernel/shaders/node_subsurface_scattering.osl
index 0df3256e1fd..e12199d8c3d 100644
--- a/intern/cycles/kernel/shaders/node_subsurface_scattering.osl
+++ b/intern/cycles/kernel/shaders/node_subsurface_scattering.osl
@@ -16,23 +16,30 @@
#include "stdosl.h"
-shader node_subsurface_scattering(
- color Color = 0.8,
- float Scale = 1.0,
- vector Radius = vector(0.1, 0.1, 0.1),
- float TextureBlur = 0.0,
- float Sharpness = 0.0,
- string falloff = "cubic",
- normal Normal = N,
- output closure color BSSRDF = 0)
+shader node_subsurface_scattering(color Color = 0.8,
+ float Scale = 1.0,
+ vector Radius = vector(0.1, 0.1, 0.1),
+ float TextureBlur = 0.0,
+ float Sharpness = 0.0,
+ string falloff = "cubic",
+ normal Normal = N,
+ output closure color BSSRDF = 0)
{
- if (falloff == "gaussian")
- BSSRDF = Color * bssrdf("gaussian", Normal, Scale * Radius, Color, "texture_blur", TextureBlur);
- else if (falloff == "cubic")
- BSSRDF = Color * bssrdf("cubic", Normal, Scale * Radius, Color, "texture_blur", TextureBlur, "sharpness", Sharpness);
- else if (falloff == "burley")
- BSSRDF = Color * bssrdf("burley", Normal, Scale * Radius, Color, "texture_blur", TextureBlur);
- else
- BSSRDF = Color * bssrdf("random_walk", Normal, Scale * Radius, Color, "texture_blur", TextureBlur);
+ if (falloff == "gaussian")
+ BSSRDF = Color *
+ bssrdf("gaussian", Normal, Scale * Radius, Color, "texture_blur", TextureBlur);
+ else if (falloff == "cubic")
+ BSSRDF = Color * bssrdf("cubic",
+ Normal,
+ Scale * Radius,
+ Color,
+ "texture_blur",
+ TextureBlur,
+ "sharpness",
+ Sharpness);
+ else if (falloff == "burley")
+ BSSRDF = Color * bssrdf("burley", Normal, Scale * Radius, Color, "texture_blur", TextureBlur);
+ else
+ BSSRDF = Color *
+ bssrdf("random_walk", Normal, Scale * Radius, Color, "texture_blur", TextureBlur);
}
-
diff --git a/intern/cycles/kernel/shaders/node_tangent.osl b/intern/cycles/kernel/shaders/node_tangent.osl
index c527070a2c8..44eb9973f3d 100644
--- a/intern/cycles/kernel/shaders/node_tangent.osl
+++ b/intern/cycles/kernel/shaders/node_tangent.osl
@@ -16,33 +16,31 @@
#include "stdosl.h"
-shader node_tangent(
- normal NormalIn = N,
- string attr_name = "geom:tangent",
- string direction_type = "radial",
- string axis = "z",
- output normal Tangent = normalize(dPdu))
+shader node_tangent(normal NormalIn = N,
+ string attr_name = "geom:tangent",
+ string direction_type = "radial",
+ string axis = "z",
+ output normal Tangent = normalize(dPdu))
{
- vector T;
+ vector T;
- if (direction_type == "uv_map") {
- getattribute(attr_name, T);
- }
- else if (direction_type == "radial") {
- point generated;
+ if (direction_type == "uv_map") {
+ getattribute(attr_name, T);
+ }
+ else if (direction_type == "radial") {
+ point generated;
- if (!getattribute("geom:generated", generated))
- generated = P;
+ if (!getattribute("geom:generated", generated))
+ generated = P;
- if (axis == "x")
- T = vector(0.0, -(generated[2] - 0.5), (generated[1] - 0.5));
- else if (axis == "y")
- T = vector(-(generated[2] - 0.5), 0.0, (generated[0] - 0.5));
- else
- T = vector(-(generated[1] - 0.5), (generated[0] - 0.5), 0.0);
- }
+ if (axis == "x")
+ T = vector(0.0, -(generated[2] - 0.5), (generated[1] - 0.5));
+ else if (axis == "y")
+ T = vector(-(generated[2] - 0.5), 0.0, (generated[0] - 0.5));
+ else
+ T = vector(-(generated[1] - 0.5), (generated[0] - 0.5), 0.0);
+ }
- T = transform("object", "world", T);
- Tangent = cross(NormalIn, normalize(cross(T, NormalIn)));
+ T = transform("object", "world", T);
+ Tangent = cross(NormalIn, normalize(cross(T, NormalIn)));
}
-
diff --git a/intern/cycles/kernel/shaders/node_texture.h b/intern/cycles/kernel/shaders/node_texture.h
index 88305fb320f..e1f3b900ee5 100644
--- a/intern/cycles/kernel/shaders/node_texture.h
+++ b/intern/cycles/kernel/shaders/node_texture.h
@@ -18,148 +18,148 @@
color cellnoise_color(point p)
{
- float r = cellnoise(p);
- float g = cellnoise(point(p[1], p[0], p[2]));
- float b = cellnoise(point(p[1], p[2], p[0]));
+ float r = cellnoise(p);
+ float g = cellnoise(point(p[1], p[0], p[2]));
+ float b = cellnoise(point(p[1], p[2], p[0]));
- return color(r, g, b);
+ return color(r, g, b);
}
void voronoi(point p, float e, float da[4], point pa[4])
{
- /* returns distances in da and point coords in pa */
- int xx, yy, zz, xi, yi, zi;
-
- xi = (int)floor(p[0]);
- yi = (int)floor(p[1]);
- zi = (int)floor(p[2]);
-
- da[0] = 1e10;
- da[1] = 1e10;
- da[2] = 1e10;
- da[3] = 1e10;
-
- for (xx = xi - 1; xx <= xi + 1; xx++) {
- for (yy = yi - 1; yy <= yi + 1; yy++) {
- for (zz = zi - 1; zz <= zi + 1; zz++) {
- point ip = point(xx, yy, zz);
- point vp = (point)cellnoise_color(ip);
- point pd = p - (vp + ip);
- float d = dot(pd, pd);
-
- vp += point(xx, yy, zz);
-
- if (d < da[0]) {
- da[3] = da[2];
- da[2] = da[1];
- da[1] = da[0];
- da[0] = d;
-
- pa[3] = pa[2];
- pa[2] = pa[1];
- pa[1] = pa[0];
- pa[0] = vp;
- }
- else if (d < da[1]) {
- da[3] = da[2];
- da[2] = da[1];
- da[1] = d;
-
- pa[3] = pa[2];
- pa[2] = pa[1];
- pa[1] = vp;
- }
- else if (d < da[2]) {
- da[3] = da[2];
- da[2] = d;
-
- pa[3] = pa[2];
- pa[2] = vp;
- }
- else if (d < da[3]) {
- da[3] = d;
- pa[3] = vp;
- }
- }
- }
- }
+ /* returns distances in da and point coords in pa */
+ int xx, yy, zz, xi, yi, zi;
+
+ xi = (int)floor(p[0]);
+ yi = (int)floor(p[1]);
+ zi = (int)floor(p[2]);
+
+ da[0] = 1e10;
+ da[1] = 1e10;
+ da[2] = 1e10;
+ da[3] = 1e10;
+
+ for (xx = xi - 1; xx <= xi + 1; xx++) {
+ for (yy = yi - 1; yy <= yi + 1; yy++) {
+ for (zz = zi - 1; zz <= zi + 1; zz++) {
+ point ip = point(xx, yy, zz);
+ point vp = (point)cellnoise_color(ip);
+ point pd = p - (vp + ip);
+ float d = dot(pd, pd);
+
+ vp += point(xx, yy, zz);
+
+ if (d < da[0]) {
+ da[3] = da[2];
+ da[2] = da[1];
+ da[1] = da[0];
+ da[0] = d;
+
+ pa[3] = pa[2];
+ pa[2] = pa[1];
+ pa[1] = pa[0];
+ pa[0] = vp;
+ }
+ else if (d < da[1]) {
+ da[3] = da[2];
+ da[2] = da[1];
+ da[1] = d;
+
+ pa[3] = pa[2];
+ pa[2] = pa[1];
+ pa[1] = vp;
+ }
+ else if (d < da[2]) {
+ da[3] = da[2];
+ da[2] = d;
+
+ pa[3] = pa[2];
+ pa[2] = vp;
+ }
+ else if (d < da[3]) {
+ da[3] = d;
+ pa[3] = vp;
+ }
+ }
+ }
+ }
}
/* Noise Bases */
float safe_noise(point p, string type)
{
- float f = 0.0;
+ float f = 0.0;
- /* Perlin noise in range -1..1 */
- if (type == "signed")
- f = noise("perlin", p);
+ /* Perlin noise in range -1..1 */
+ if (type == "signed")
+ f = noise("perlin", p);
- /* Perlin noise in range 0..1 */
- else
- f = noise(p);
+ /* Perlin noise in range 0..1 */
+ else
+ f = noise(p);
- /* can happen for big coordinates, things even out to 0.5 then anyway */
- if (!isfinite(f))
- return 0.5;
+ /* can happen for big coordinates, things even out to 0.5 then anyway */
+ if (!isfinite(f))
+ return 0.5;
- return f;
+ return f;
}
/* Turbulence */
float noise_turbulence(point p, float details, int hard)
{
- float fscale = 1.0;
- float amp = 1.0;
- float sum = 0.0;
- int i, n;
+ float fscale = 1.0;
+ float amp = 1.0;
+ float sum = 0.0;
+ int i, n;
- float octaves = clamp(details, 0.0, 16.0);
- n = (int)octaves;
+ float octaves = clamp(details, 0.0, 16.0);
+ n = (int)octaves;
- for (i = 0; i <= n; i++) {
- float t = safe_noise(fscale * p, "unsigned");
+ for (i = 0; i <= n; i++) {
+ float t = safe_noise(fscale * p, "unsigned");
- if (hard)
- t = fabs(2.0 * t - 1.0);
+ if (hard)
+ t = fabs(2.0 * t - 1.0);
- sum += t * amp;
- amp *= 0.5;
- fscale *= 2.0;
- }
+ sum += t * amp;
+ amp *= 0.5;
+ fscale *= 2.0;
+ }
- float rmd = octaves - floor(octaves);
+ float rmd = octaves - floor(octaves);
- if (rmd != 0.0) {
- float t = safe_noise(fscale * p, "unsigned");
+ if (rmd != 0.0) {
+ float t = safe_noise(fscale * p, "unsigned");
- if (hard)
- t = fabs(2.0 * t - 1.0);
+ if (hard)
+ t = fabs(2.0 * t - 1.0);
- float sum2 = sum + t * amp;
+ float sum2 = sum + t * amp;
- sum *= ((float)(1 << n) / (float)((1 << (n + 1)) - 1));
- sum2 *= ((float)(1 << (n + 1)) / (float)((1 << (n + 2)) - 1));
+ sum *= ((float)(1 << n) / (float)((1 << (n + 1)) - 1));
+ sum2 *= ((float)(1 << (n + 1)) / (float)((1 << (n + 2)) - 1));
- return (1.0 - rmd) * sum + rmd * sum2;
- }
- else {
- sum *= ((float)(1 << n) / (float)((1 << (n + 1)) - 1));
- return sum;
- }
+ return (1.0 - rmd) * sum + rmd * sum2;
+ }
+ else {
+ sum *= ((float)(1 << n) / (float)((1 << (n + 1)) - 1));
+ return sum;
+ }
}
/* Utility */
float nonzero(float f, float eps)
{
- float r;
+ float r;
- if (abs(f) < eps)
- r = sign(f) * eps;
- else
- r = f;
+ if (abs(f) < eps)
+ r = sign(f) * eps;
+ else
+ r = f;
- return r;
+ return r;
}
diff --git a/intern/cycles/kernel/shaders/node_texture_coordinate.osl b/intern/cycles/kernel/shaders/node_texture_coordinate.osl
index 9e2109fa082..13861653d04 100644
--- a/intern/cycles/kernel/shaders/node_texture_coordinate.osl
+++ b/intern/cycles/kernel/shaders/node_texture_coordinate.osl
@@ -17,82 +17,81 @@
#include "stdosl.h"
shader node_texture_coordinate(
- normal NormalIn = N,
- int is_background = 0,
- int is_volume = 0,
- int from_dupli = 0,
- int use_transform = 0,
- string bump_offset = "center",
- matrix object_itfm = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+ normal NormalIn = N,
+ int is_background = 0,
+ int is_volume = 0,
+ int from_dupli = 0,
+ int use_transform = 0,
+ string bump_offset = "center",
+ matrix object_itfm = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- output point Generated = point(0.0, 0.0, 0.0),
- output point UV = point(0.0, 0.0, 0.0),
- output point Object = point(0.0, 0.0, 0.0),
- output point Camera = point(0.0, 0.0, 0.0),
- output point Window = point(0.0, 0.0, 0.0),
- output normal Normal = normal(0.0, 0.0, 0.0),
- output point Reflection = point(0.0, 0.0, 0.0))
+ output point Generated = point(0.0, 0.0, 0.0),
+ output point UV = point(0.0, 0.0, 0.0),
+ output point Object = point(0.0, 0.0, 0.0),
+ output point Camera = point(0.0, 0.0, 0.0),
+ output point Window = point(0.0, 0.0, 0.0),
+ output normal Normal = normal(0.0, 0.0, 0.0),
+ output point Reflection = point(0.0, 0.0, 0.0))
{
- if (is_background) {
- Generated = P;
- UV = point(0.0, 0.0, 0.0);
- Object = P;
- point Pcam = transform("camera", "world", point(0, 0, 0));
- Camera = transform("camera", P + Pcam);
- getattribute("NDC", Window);
- Normal = NormalIn;
- Reflection = I;
- }
- else {
- if (from_dupli) {
- getattribute("geom:dupli_generated", Generated);
- getattribute("geom:dupli_uv", UV);
- }
- else if (is_volume) {
- Generated = transform("object", P);
+ if (is_background) {
+ Generated = P;
+ UV = point(0.0, 0.0, 0.0);
+ Object = P;
+ point Pcam = transform("camera", "world", point(0, 0, 0));
+ Camera = transform("camera", P + Pcam);
+ getattribute("NDC", Window);
+ Normal = NormalIn;
+ Reflection = I;
+ }
+ else {
+ if (from_dupli) {
+ getattribute("geom:dupli_generated", Generated);
+ getattribute("geom:dupli_uv", UV);
+ }
+ else if (is_volume) {
+ Generated = transform("object", P);
- matrix tfm;
- if (getattribute("geom:generated_transform", tfm))
- Generated = transform(tfm, Generated);
+ matrix tfm;
+ if (getattribute("geom:generated_transform", tfm))
+ Generated = transform(tfm, Generated);
- getattribute("geom:uv", UV);
- }
- else {
- getattribute("geom:generated", Generated);
- getattribute("geom:uv", UV);
- }
+ getattribute("geom:uv", UV);
+ }
+ else {
+ getattribute("geom:generated", Generated);
+ getattribute("geom:uv", UV);
+ }
- if (use_transform) {
- Object = transform(object_itfm, P);
- }
- else {
- Object = transform("object", P);
- }
- Camera = transform("camera", P);
- Window = transform("NDC", P);
- Normal = transform("world", "object", NormalIn);
- Reflection = -reflect(I, NormalIn);
- }
+ if (use_transform) {
+ Object = transform(object_itfm, P);
+ }
+ else {
+ Object = transform("object", P);
+ }
+ Camera = transform("camera", P);
+ Window = transform("NDC", P);
+ Normal = transform("world", "object", NormalIn);
+ Reflection = -reflect(I, NormalIn);
+ }
- if (bump_offset == "dx") {
- if (!from_dupli) {
- Generated += Dx(Generated);
- UV += Dx(UV);
- }
- Object += Dx(Object);
- Camera += Dx(Camera);
- Window += Dx(Window);
- }
- else if (bump_offset == "dy") {
- if (!from_dupli) {
- Generated += Dy(Generated);
- UV += Dy(UV);
- }
- Object += Dy(Object);
- Camera += Dy(Camera);
- Window += Dy(Window);
- }
+ if (bump_offset == "dx") {
+ if (!from_dupli) {
+ Generated += Dx(Generated);
+ UV += Dx(UV);
+ }
+ Object += Dx(Object);
+ Camera += Dx(Camera);
+ Window += Dx(Window);
+ }
+ else if (bump_offset == "dy") {
+ if (!from_dupli) {
+ Generated += Dy(Generated);
+ UV += Dy(UV);
+ }
+ Object += Dy(Object);
+ Camera += Dy(Camera);
+ Window += Dy(Window);
+ }
- Window[2] = 0.0;
+ Window[2] = 0.0;
}
-
diff --git a/intern/cycles/kernel/shaders/node_toon_bsdf.osl b/intern/cycles/kernel/shaders/node_toon_bsdf.osl
index ae68a463e46..ed3a0b25c60 100644
--- a/intern/cycles/kernel/shaders/node_toon_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_toon_bsdf.osl
@@ -16,17 +16,15 @@
#include "stdosl.h"
-shader node_toon_bsdf(
- color Color = 0.8,
- string component = "diffuse",
- float Size = 0.5,
- float Smooth = 0.0,
- normal Normal = N,
- output closure color BSDF = 0)
+shader node_toon_bsdf(color Color = 0.8,
+ string component = "diffuse",
+ float Size = 0.5,
+ float Smooth = 0.0,
+ normal Normal = N,
+ output closure color BSDF = 0)
{
- if (component == "diffuse")
- BSDF = Color * diffuse_toon(Normal, Size, Smooth);
- else if (component == "glossy")
- BSDF = Color * glossy_toon(Normal, Size, Smooth);
+ if (component == "diffuse")
+ BSDF = Color * diffuse_toon(Normal, Size, Smooth);
+ else if (component == "glossy")
+ BSDF = Color * glossy_toon(Normal, Size, Smooth);
}
-
diff --git a/intern/cycles/kernel/shaders/node_translucent_bsdf.osl b/intern/cycles/kernel/shaders/node_translucent_bsdf.osl
index 94d23d35326..7ce1ab08c59 100644
--- a/intern/cycles/kernel/shaders/node_translucent_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_translucent_bsdf.osl
@@ -16,11 +16,7 @@
#include "stdosl.h"
-shader node_translucent_bsdf(
- color Color = 0.8,
- normal Normal = N,
- output closure color BSDF = 0)
+shader node_translucent_bsdf(color Color = 0.8, normal Normal = N, output closure color BSDF = 0)
{
- BSDF = Color * translucent(Normal);
+ BSDF = Color * translucent(Normal);
}
-
diff --git a/intern/cycles/kernel/shaders/node_transparent_bsdf.osl b/intern/cycles/kernel/shaders/node_transparent_bsdf.osl
index 5d6798f19a6..a735513ba89 100644
--- a/intern/cycles/kernel/shaders/node_transparent_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_transparent_bsdf.osl
@@ -16,11 +16,7 @@
#include "stdosl.h"
-shader node_transparent_bsdf(
- color Color = 0.8,
- normal Normal = N,
- output closure color BSDF = 0)
+shader node_transparent_bsdf(color Color = 0.8, normal Normal = N, output closure color BSDF = 0)
{
- BSDF = Color * transparent();
+ BSDF = Color * transparent();
}
-
diff --git a/intern/cycles/kernel/shaders/node_uv_map.osl b/intern/cycles/kernel/shaders/node_uv_map.osl
index b46b2e73457..6f2887be63c 100644
--- a/intern/cycles/kernel/shaders/node_uv_map.osl
+++ b/intern/cycles/kernel/shaders/node_uv_map.osl
@@ -16,30 +16,29 @@
#include "stdosl.h"
-shader node_uv_map(
- int from_dupli = 0,
- string attribute = "",
- string bump_offset = "center",
- output point UV = point(0.0, 0.0, 0.0))
+shader node_uv_map(int from_dupli = 0,
+ string attribute = "",
+ string bump_offset = "center",
+ output point UV = point(0.0, 0.0, 0.0))
{
- if (from_dupli) {
- getattribute("geom:dupli_uv", UV);
- }
- else {
- if (attribute == "")
- getattribute("geom:uv", UV);
- else
- getattribute(attribute, UV);
- }
+ if (from_dupli) {
+ getattribute("geom:dupli_uv", UV);
+ }
+ else {
+ if (attribute == "")
+ getattribute("geom:uv", UV);
+ else
+ getattribute(attribute, UV);
+ }
- if (bump_offset == "dx") {
- if (!from_dupli) {
- UV += Dx(UV);
- }
- }
- else if (bump_offset == "dy") {
- if (!from_dupli) {
- UV += Dy(UV);
- }
- }
+ if (bump_offset == "dx") {
+ if (!from_dupli) {
+ UV += Dx(UV);
+ }
+ }
+ else if (bump_offset == "dy") {
+ if (!from_dupli) {
+ UV += Dy(UV);
+ }
+ }
}
diff --git a/intern/cycles/kernel/shaders/node_value.osl b/intern/cycles/kernel/shaders/node_value.osl
index f75388d1f76..398e2c0e392 100644
--- a/intern/cycles/kernel/shaders/node_value.osl
+++ b/intern/cycles/kernel/shaders/node_value.osl
@@ -16,16 +16,14 @@
#include "stdosl.h"
-shader node_value(
- float value_value = 0.0,
- vector vector_value = vector(0.0, 0.0, 0.0),
- color color_value = 0.0,
- output float Value = 0.0,
- output vector Vector = vector(0.0, 0.0, 0.0),
- output color Color = 0.0)
+shader node_value(float value_value = 0.0,
+ vector vector_value = vector(0.0, 0.0, 0.0),
+ color color_value = 0.0,
+ output float Value = 0.0,
+ output vector Vector = vector(0.0, 0.0, 0.0),
+ output color Color = 0.0)
{
- Value = value_value;
- Vector = vector_value;
- Color = color_value;
+ Value = value_value;
+ Vector = vector_value;
+ Color = color_value;
}
-
diff --git a/intern/cycles/kernel/shaders/node_vector_curves.osl b/intern/cycles/kernel/shaders/node_vector_curves.osl
index ff284c48e0a..e8c8036b550 100644
--- a/intern/cycles/kernel/shaders/node_vector_curves.osl
+++ b/intern/cycles/kernel/shaders/node_vector_curves.osl
@@ -17,25 +17,23 @@
#include "stdosl.h"
#include "node_ramp_util.h"
-shader node_vector_curves(
- color ramp[] = {0.0},
- float min_x = 0.0,
- float max_x = 1.0,
+shader node_vector_curves(color ramp[] = {0.0},
+ float min_x = 0.0,
+ float max_x = 1.0,
- vector VectorIn = vector(0.0, 0.0, 0.0),
- float Fac = 0.0,
- output vector VectorOut = vector(0.0, 0.0, 0.0))
+ vector VectorIn = vector(0.0, 0.0, 0.0),
+ float Fac = 0.0,
+ output vector VectorOut = vector(0.0, 0.0, 0.0))
{
- vector c = (VectorIn - vector(min_x, min_x, min_x)) / (max_x - min_x);
+ vector c = (VectorIn - vector(min_x, min_x, min_x)) / (max_x - min_x);
- color r = rgb_ramp_lookup(ramp, c[0], 1, 1);
- color g = rgb_ramp_lookup(ramp, c[0], 1, 1);
- color b = rgb_ramp_lookup(ramp, c[0], 1, 1);
+ color r = rgb_ramp_lookup(ramp, c[0], 1, 1);
+ color g = rgb_ramp_lookup(ramp, c[0], 1, 1);
+ color b = rgb_ramp_lookup(ramp, c[0], 1, 1);
- VectorOut[0] = r[0];
- VectorOut[1] = g[1];
- VectorOut[2] = b[2];
+ VectorOut[0] = r[0];
+ VectorOut[1] = g[1];
+ VectorOut[2] = b[2];
- VectorOut = mix(VectorIn, VectorOut, Fac);
+ VectorOut = mix(VectorIn, VectorOut, Fac);
}
-
diff --git a/intern/cycles/kernel/shaders/node_vector_displacement.osl b/intern/cycles/kernel/shaders/node_vector_displacement.osl
index b19bc228e37..e9bd336347f 100644
--- a/intern/cycles/kernel/shaders/node_vector_displacement.osl
+++ b/intern/cycles/kernel/shaders/node_vector_displacement.osl
@@ -16,45 +16,43 @@
#include "stdosl.h"
-shader node_vector_displacement(
- color Vector = color(0.0, 0.0, 0.0),
- float Midlevel = 0.0,
- float Scale = 1.0,
- string space = "tangent",
- string attr_name = "geom:tangent",
- string attr_sign_name = "geom:tangent_sign",
- output vector Displacement = vector(0.0, 0.0, 0.0))
+shader node_vector_displacement(color Vector = color(0.0, 0.0, 0.0),
+ float Midlevel = 0.0,
+ float Scale = 1.0,
+ string space = "tangent",
+ string attr_name = "geom:tangent",
+ string attr_sign_name = "geom:tangent_sign",
+ output vector Displacement = vector(0.0, 0.0, 0.0))
{
- vector offset = (Vector - vector(Midlevel)) * Scale;
-
- if(space == "tangent") {
- /* Tangent space. */
- vector N_object = normalize(transform("world", "object", N));
-
- vector T_object;
- if(getattribute(attr_name, T_object)) {
- T_object = normalize(T_object);
- }
- else {
- T_object = normalize(dPdu);
- }
-
- vector B_object = normalize(cross(N_object, T_object));
- float tangent_sign;
- if(getattribute(attr_sign_name, tangent_sign)) {
- B_object *= tangent_sign;
- }
-
- Displacement = T_object*offset[0] + N_object*offset[1] + B_object*offset[2];
- }
- else {
- /* Object or world space. */
- Displacement = offset;
- }
-
- if(space != "world") {
- /* Tangent or object space. */
- Displacement = transform("object", "world", Displacement);
- }
+ vector offset = (Vector - vector(Midlevel)) * Scale;
+
+ if (space == "tangent") {
+ /* Tangent space. */
+ vector N_object = normalize(transform("world", "object", N));
+
+ vector T_object;
+ if (getattribute(attr_name, T_object)) {
+ T_object = normalize(T_object);
+ }
+ else {
+ T_object = normalize(dPdu);
+ }
+
+ vector B_object = normalize(cross(N_object, T_object));
+ float tangent_sign;
+ if (getattribute(attr_sign_name, tangent_sign)) {
+ B_object *= tangent_sign;
+ }
+
+ Displacement = T_object * offset[0] + N_object * offset[1] + B_object * offset[2];
+ }
+ else {
+ /* Object or world space. */
+ Displacement = offset;
+ }
+
+ if (space != "world") {
+ /* Tangent or object space. */
+ Displacement = transform("object", "world", Displacement);
+ }
}
-
diff --git a/intern/cycles/kernel/shaders/node_vector_math.osl b/intern/cycles/kernel/shaders/node_vector_math.osl
index a7e3637402e..10bb0c7283c 100644
--- a/intern/cycles/kernel/shaders/node_vector_math.osl
+++ b/intern/cycles/kernel/shaders/node_vector_math.osl
@@ -16,36 +16,34 @@
#include "stdosl.h"
-shader node_vector_math(
- string type = "add",
- vector Vector1 = vector(0.0, 0.0, 0.0),
- vector Vector2 = vector(0.0, 0.0, 0.0),
- output float Value = 0.0,
- output vector Vector = vector(0.0, 0.0, 0.0))
+shader node_vector_math(string type = "add",
+ vector Vector1 = vector(0.0, 0.0, 0.0),
+ vector Vector2 = vector(0.0, 0.0, 0.0),
+ output float Value = 0.0,
+ output vector Vector = vector(0.0, 0.0, 0.0))
{
- if (type == "add") {
- Vector = Vector1 + Vector2;
- Value = (abs(Vector[0]) + abs(Vector[1]) + abs(Vector[2])) / 3.0;
- }
- else if (type == "subtract") {
- Vector = Vector1 - Vector2;
- Value = (abs(Vector[0]) + abs(Vector[1]) + abs(Vector[2])) / 3.0;
- }
- else if (type == "average") {
- Value = length(Vector1 + Vector2);
- Vector = normalize(Vector1 + Vector2);
- }
- else if (type == "dot_product") {
- Value = dot(Vector1, Vector2);
- }
- else if (type == "cross_product") {
- vector c = cross(Vector1, Vector2);
- Value = length(c);
- Vector = normalize(c);
- }
- else if (type == "normalize") {
- Value = length(Vector1);
- Vector = normalize(Vector1);
- }
+ if (type == "add") {
+ Vector = Vector1 + Vector2;
+ Value = (abs(Vector[0]) + abs(Vector[1]) + abs(Vector[2])) / 3.0;
+ }
+ else if (type == "subtract") {
+ Vector = Vector1 - Vector2;
+ Value = (abs(Vector[0]) + abs(Vector[1]) + abs(Vector[2])) / 3.0;
+ }
+ else if (type == "average") {
+ Value = length(Vector1 + Vector2);
+ Vector = normalize(Vector1 + Vector2);
+ }
+ else if (type == "dot_product") {
+ Value = dot(Vector1, Vector2);
+ }
+ else if (type == "cross_product") {
+ vector c = cross(Vector1, Vector2);
+ Value = length(c);
+ Vector = normalize(c);
+ }
+ else if (type == "normalize") {
+ Value = length(Vector1);
+ Vector = normalize(Vector1);
+ }
}
-
diff --git a/intern/cycles/kernel/shaders/node_vector_transform.osl b/intern/cycles/kernel/shaders/node_vector_transform.osl
index afb95b340d1..22939577be0 100644
--- a/intern/cycles/kernel/shaders/node_vector_transform.osl
+++ b/intern/cycles/kernel/shaders/node_vector_transform.osl
@@ -16,21 +16,19 @@
#include "stdosl.h"
-shader node_vector_transform(
- string type = "vector",
- string convert_from = "world",
- string convert_to = "object",
- vector VectorIn = vector(0.0, 0.0, 0.0),
- output vector VectorOut = vector(0.0, 0.0, 0.0))
+shader node_vector_transform(string type = "vector",
+ string convert_from = "world",
+ string convert_to = "object",
+ vector VectorIn = vector(0.0, 0.0, 0.0),
+ output vector VectorOut = vector(0.0, 0.0, 0.0))
{
- if (type == "vector" || type == "normal") {
- VectorOut = transform(convert_from, convert_to, VectorIn);
- if (type == "normal")
- VectorOut = normalize(VectorOut);
- }
- else if (type == "point") {
- point Point = (point)VectorIn;
- VectorOut = transform(convert_from, convert_to, Point);
- }
+ if (type == "vector" || type == "normal") {
+ VectorOut = transform(convert_from, convert_to, VectorIn);
+ if (type == "normal")
+ VectorOut = normalize(VectorOut);
+ }
+ else if (type == "point") {
+ point Point = (point)VectorIn;
+ VectorOut = transform(convert_from, convert_to, Point);
+ }
}
-
diff --git a/intern/cycles/kernel/shaders/node_velvet_bsdf.osl b/intern/cycles/kernel/shaders/node_velvet_bsdf.osl
index 456c26998c8..9290b845325 100644
--- a/intern/cycles/kernel/shaders/node_velvet_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_velvet_bsdf.osl
@@ -17,14 +17,12 @@
#include "stdosl.h"
#include "node_fresnel.h"
-shader node_velvet_bsdf(
- color Color = 0.8,
- float Sigma = 0.0,
- normal Normal = N,
- output closure color BSDF = 0)
+shader node_velvet_bsdf(color Color = 0.8,
+ float Sigma = 0.0,
+ normal Normal = N,
+ output closure color BSDF = 0)
{
- float sigma = clamp(Sigma, 0.0, 1.0);
+ float sigma = clamp(Sigma, 0.0, 1.0);
- BSDF = Color * ashikhmin_velvet(Normal, sigma);
+ BSDF = Color * ashikhmin_velvet(Normal, sigma);
}
-
diff --git a/intern/cycles/kernel/shaders/node_voronoi_texture.osl b/intern/cycles/kernel/shaders/node_voronoi_texture.osl
index 2e47d74a414..34c86d5b98d 100644
--- a/intern/cycles/kernel/shaders/node_voronoi_texture.osl
+++ b/intern/cycles/kernel/shaders/node_voronoi_texture.osl
@@ -19,147 +19,146 @@
void voronoi_m(point p, string metric, float e, float da[4], point pa[4])
{
- /* Compute the distance to and the position of the four closest neighbors to p.
- *
- * The neighbors are randomly placed, 1 each in a 3x3x3 grid (Worley pattern).
- * The distances and points are returned in ascending order, i.e. da[0] and pa[0] will
- * contain the distance to the closest point and its coordinates respectively.
- */
- int xx, yy, zz, xi, yi, zi;
-
- xi = (int)floor(p[0]);
- yi = (int)floor(p[1]);
- zi = (int)floor(p[2]);
-
- da[0] = 1e10;
- da[1] = 1e10;
- da[2] = 1e10;
- da[3] = 1e10;
-
- for (xx = xi - 1; xx <= xi + 1; xx++) {
- for (yy = yi - 1; yy <= yi + 1; yy++) {
- for (zz = zi - 1; zz <= zi + 1; zz++) {
- point ip = point(xx, yy, zz);
- point vp = (point)cellnoise_color(ip);
- point pd = p - (vp + ip);
-
- float d = 0.0;
- if (metric == "distance") {
- d = dot(pd, pd);
- }
- else if (metric == "manhattan") {
- d = fabs(pd[0]) + fabs(pd[1]) + fabs(pd[2]);
- }
- else if (metric == "chebychev") {
- d = max(fabs(pd[0]), max(fabs(pd[1]), fabs(pd[2])));
- }
- else if (metric == "minkowski") {
- d = pow(pow(fabs(pd[0]), e) + pow(fabs(pd[1]), e) + pow(fabs(pd[2]), e), 1.0/e);
- }
-
- vp += point(xx, yy, zz);
-
- if (d < da[0]) {
- da[3] = da[2];
- da[2] = da[1];
- da[1] = da[0];
- da[0] = d;
-
- pa[3] = pa[2];
- pa[2] = pa[1];
- pa[1] = pa[0];
- pa[0] = vp;
- }
- else if (d < da[1]) {
- da[3] = da[2];
- da[2] = da[1];
- da[1] = d;
-
- pa[3] = pa[2];
- pa[2] = pa[1];
- pa[1] = vp;
- }
- else if (d < da[2]) {
- da[3] = da[2];
- da[2] = d;
-
- pa[3] = pa[2];
- pa[2] = vp;
- }
- else if (d < da[3]) {
- da[3] = d;
- pa[3] = vp;
- }
- }
- }
- }
+ /* Compute the distance to and the position of the four closest neighbors to p.
+ *
+ * The neighbors are randomly placed, 1 each in a 3x3x3 grid (Worley pattern).
+ * The distances and points are returned in ascending order, i.e. da[0] and pa[0] will
+ * contain the distance to the closest point and its coordinates respectively.
+ */
+ int xx, yy, zz, xi, yi, zi;
+
+ xi = (int)floor(p[0]);
+ yi = (int)floor(p[1]);
+ zi = (int)floor(p[2]);
+
+ da[0] = 1e10;
+ da[1] = 1e10;
+ da[2] = 1e10;
+ da[3] = 1e10;
+
+ for (xx = xi - 1; xx <= xi + 1; xx++) {
+ for (yy = yi - 1; yy <= yi + 1; yy++) {
+ for (zz = zi - 1; zz <= zi + 1; zz++) {
+ point ip = point(xx, yy, zz);
+ point vp = (point)cellnoise_color(ip);
+ point pd = p - (vp + ip);
+
+ float d = 0.0;
+ if (metric == "distance") {
+ d = dot(pd, pd);
+ }
+ else if (metric == "manhattan") {
+ d = fabs(pd[0]) + fabs(pd[1]) + fabs(pd[2]);
+ }
+ else if (metric == "chebychev") {
+ d = max(fabs(pd[0]), max(fabs(pd[1]), fabs(pd[2])));
+ }
+ else if (metric == "minkowski") {
+ d = pow(pow(fabs(pd[0]), e) + pow(fabs(pd[1]), e) + pow(fabs(pd[2]), e), 1.0 / e);
+ }
+
+ vp += point(xx, yy, zz);
+
+ if (d < da[0]) {
+ da[3] = da[2];
+ da[2] = da[1];
+ da[1] = da[0];
+ da[0] = d;
+
+ pa[3] = pa[2];
+ pa[2] = pa[1];
+ pa[1] = pa[0];
+ pa[0] = vp;
+ }
+ else if (d < da[1]) {
+ da[3] = da[2];
+ da[2] = da[1];
+ da[1] = d;
+
+ pa[3] = pa[2];
+ pa[2] = pa[1];
+ pa[1] = vp;
+ }
+ else if (d < da[2]) {
+ da[3] = da[2];
+ da[2] = d;
+
+ pa[3] = pa[2];
+ pa[2] = vp;
+ }
+ else if (d < da[3]) {
+ da[3] = d;
+ pa[3] = vp;
+ }
+ }
+ }
+ }
}
/* Voronoi */
shader node_voronoi_texture(
- int use_mapping = 0,
- matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- string coloring = "intensity",
- string metric = "distance",
- string feature = "F1",
- float Exponent = 1.0,
- float Scale = 5.0,
- point Vector = P,
- output float Fac = 0.0,
- output color Color = 0.0)
+ int use_mapping = 0,
+ matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+ string coloring = "intensity",
+ string metric = "distance",
+ string feature = "F1",
+ float Exponent = 1.0,
+ float Scale = 5.0,
+ point Vector = P,
+ output float Fac = 0.0,
+ output color Color = 0.0)
{
- point p = Vector;
-
- if (use_mapping)
- p = transform(mapping, p);
-
- /* compute distance and point coordinate of 4 nearest neighbours */
- float da[4];
- point pa[4];
-
- /* compute distance and point coordinate of 4 nearest neighbours */
- voronoi_m(p * Scale, metric, Exponent, da, pa);
-
- if (coloring == "intensity") {
- /* Intensity output */
- if (feature == "F1") {
- Fac = fabs(da[0]);
- }
- else if (feature == "F2") {
- Fac = fabs(da[1]);
- }
- else if (feature == "F3") {
- Fac = fabs(da[2]);
- }
- else if (feature == "F4") {
- Fac = fabs(da[3]);
- }
- else if (feature == "F2F1") {
- Fac = fabs(da[1] - da[0]);
- }
- Color = color(Fac);
- }
- else {
- /* Color output */
- if (feature == "F1") {
- Color = pa[0];
- }
- else if (feature == "F2") {
- Color = pa[1];
- }
- else if (feature == "F3") {
- Color = pa[2];
- }
- else if (feature == "F4") {
- Color = pa[3];
- }
- else if (feature == "F2F1") {
- Color = fabs(pa[1] - pa[0]);
- }
-
- Color = cellnoise_color(Color);
- Fac = (Color[0] + Color[1] + Color[2]) * (1.0 / 3.0);
- }
+ point p = Vector;
+
+ if (use_mapping)
+ p = transform(mapping, p);
+
+ /* compute distance and point coordinate of 4 nearest neighbours */
+ float da[4];
+ point pa[4];
+
+ /* compute distance and point coordinate of 4 nearest neighbours */
+ voronoi_m(p * Scale, metric, Exponent, da, pa);
+
+ if (coloring == "intensity") {
+ /* Intensity output */
+ if (feature == "F1") {
+ Fac = fabs(da[0]);
+ }
+ else if (feature == "F2") {
+ Fac = fabs(da[1]);
+ }
+ else if (feature == "F3") {
+ Fac = fabs(da[2]);
+ }
+ else if (feature == "F4") {
+ Fac = fabs(da[3]);
+ }
+ else if (feature == "F2F1") {
+ Fac = fabs(da[1] - da[0]);
+ }
+ Color = color(Fac);
+ }
+ else {
+ /* Color output */
+ if (feature == "F1") {
+ Color = pa[0];
+ }
+ else if (feature == "F2") {
+ Color = pa[1];
+ }
+ else if (feature == "F3") {
+ Color = pa[2];
+ }
+ else if (feature == "F4") {
+ Color = pa[3];
+ }
+ else if (feature == "F2F1") {
+ Color = fabs(pa[1] - pa[0]);
+ }
+
+ Color = cellnoise_color(Color);
+ Fac = (Color[0] + Color[1] + Color[2]) * (1.0 / 3.0);
+ }
}
-
diff --git a/intern/cycles/kernel/shaders/node_voxel_texture.osl b/intern/cycles/kernel/shaders/node_voxel_texture.osl
index 9253febd64a..0e4484561d8 100644
--- a/intern/cycles/kernel/shaders/node_voxel_texture.osl
+++ b/intern/cycles/kernel/shaders/node_voxel_texture.osl
@@ -16,32 +16,30 @@
#include "stdosl.h"
-shader node_voxel_texture(
- string filename = "",
- string interpolation = "linear",
- int use_mapping = 0,
- matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- point Vector = P,
- output float Density = 0,
- output color Color = 0)
+shader node_voxel_texture(string filename = "",
+ string interpolation = "linear",
+ int use_mapping = 0,
+ matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+ point Vector = P,
+ output float Density = 0,
+ output color Color = 0)
{
- point p = Vector;
- if (use_mapping) {
- p = transform(mapping, p);
- }
- else {
- p = transform("object", Vector);
- matrix tfm;
- if (getattribute("geom:generated_transform", tfm))
- p = transform(tfm, p);
- }
- if (p[0] < 0.0 || p[1] < 0.0 || p[2] < 0.0 ||
- p[0] > 1.0 || p[1] > 1.0 || p[2] > 1.0)
- {
- Density = 0;
- Color = color(0, 0, 0);
- }
- else {
- Color = (color)texture3d(filename, p, "wrap", "periodic", "interp", interpolation, "alpha", Density);
- }
+ point p = Vector;
+ if (use_mapping) {
+ p = transform(mapping, p);
+ }
+ else {
+ p = transform("object", Vector);
+ matrix tfm;
+ if (getattribute("geom:generated_transform", tfm))
+ p = transform(tfm, p);
+ }
+ if (p[0] < 0.0 || p[1] < 0.0 || p[2] < 0.0 || p[0] > 1.0 || p[1] > 1.0 || p[2] > 1.0) {
+ Density = 0;
+ Color = color(0, 0, 0);
+ }
+ else {
+ Color = (color)texture3d(
+ filename, p, "wrap", "periodic", "interp", interpolation, "alpha", Density);
+ }
}
diff --git a/intern/cycles/kernel/shaders/node_wave_texture.osl b/intern/cycles/kernel/shaders/node_wave_texture.osl
index 71bc9324705..dfc2dbfb800 100644
--- a/intern/cycles/kernel/shaders/node_wave_texture.osl
+++ b/intern/cycles/kernel/shaders/node_wave_texture.osl
@@ -21,49 +21,47 @@
float wave(point p, string type, string profile, float detail, float distortion, float dscale)
{
- float n = 0.0;
+ float n = 0.0;
- if (type == "bands") {
- n = (p[0] + p[1] + p[2]) * 10.0;
- }
- else if (type == "rings") {
- n = length(p) * 20.0;
- }
+ if (type == "bands") {
+ n = (p[0] + p[1] + p[2]) * 10.0;
+ }
+ else if (type == "rings") {
+ n = length(p) * 20.0;
+ }
- if (distortion != 0.0) {
- n = n + (distortion * noise_turbulence(p * dscale, detail, 0));
- }
+ if (distortion != 0.0) {
+ n = n + (distortion * noise_turbulence(p * dscale, detail, 0));
+ }
- if (profile == "sine") {
- return 0.5 + 0.5 * sin(n);
- }
- else {
- /* Saw profile */
- n /= M_2PI;
- n -= (int) n;
- return (n < 0.0) ? n + 1.0 : n;
- }
+ if (profile == "sine") {
+ return 0.5 + 0.5 * sin(n);
+ }
+ else {
+ /* Saw profile */
+ n /= M_2PI;
+ n -= (int)n;
+ return (n < 0.0) ? n + 1.0 : n;
+ }
}
-shader node_wave_texture(
- int use_mapping = 0,
- matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- string type = "bands",
- string profile = "sine",
- float Scale = 5.0,
- float Distortion = 0.0,
- float Detail = 2.0,
- float DetailScale = 1.0,
- point Vector = P,
- output float Fac = 0.0,
- output color Color = 0.0)
+shader node_wave_texture(int use_mapping = 0,
+ matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+ string type = "bands",
+ string profile = "sine",
+ float Scale = 5.0,
+ float Distortion = 0.0,
+ float Detail = 2.0,
+ float DetailScale = 1.0,
+ point Vector = P,
+ output float Fac = 0.0,
+ output color Color = 0.0)
{
- point p = Vector;
+ point p = Vector;
- if (use_mapping)
- p = transform(mapping, p);
+ if (use_mapping)
+ p = transform(mapping, p);
- Fac = wave(p * Scale, type, profile, Detail, Distortion, DetailScale);
- Color = Fac;
+ Fac = wave(p * Scale, type, profile, Detail, Distortion, DetailScale);
+ Color = Fac;
}
-
diff --git a/intern/cycles/kernel/shaders/node_wavelength.osl b/intern/cycles/kernel/shaders/node_wavelength.osl
index 79e7043d4bf..c8c6eecb171 100644
--- a/intern/cycles/kernel/shaders/node_wavelength.osl
+++ b/intern/cycles/kernel/shaders/node_wavelength.osl
@@ -16,10 +16,7 @@
#include "stdosl.h"
-shader node_wavelength(
- float Wavelength = 500.0,
- output color Color = 0.0)
+shader node_wavelength(float Wavelength = 500.0, output color Color = 0.0)
{
- Color = wavelength_color(Wavelength);
+ Color = wavelength_color(Wavelength);
}
-
diff --git a/intern/cycles/kernel/shaders/node_wireframe.osl b/intern/cycles/kernel/shaders/node_wireframe.osl
index 5cc214495dd..ea4bd3a4c87 100644
--- a/intern/cycles/kernel/shaders/node_wireframe.osl
+++ b/intern/cycles/kernel/shaders/node_wireframe.osl
@@ -17,25 +17,24 @@
#include "stdosl.h"
#include "oslutil.h"
-shader node_wireframe(
- string bump_offset = "center",
- int use_pixel_size = 0,
- float Size = 0.01,
- output float Fac = 0.0)
+shader node_wireframe(string bump_offset = "center",
+ int use_pixel_size = 0,
+ float Size = 0.01,
+ output float Fac = 0.0)
{
- Fac = wireframe("triangles", Size, use_pixel_size);
- /* TODO(sergey): Since we can't use autodiff here we do algebraic
- * calculation of derivatives by definition. We could probably
- * optimize this a bit by doing some extra calculation in wireframe().
- */
- if (bump_offset == "dx") {
- point dx = Dx(P);
- P -= dx;
- Fac += (Fac - wireframe("triangles", Size, use_pixel_size)) / length(dx);
- }
- else if (bump_offset == "dy") {
- point dy = Dy(P);
- P -= dy;
- Fac += (Fac - wireframe("triangles", Size, use_pixel_size)) / length(dy);
- }
+ Fac = wireframe("triangles", Size, use_pixel_size);
+ /* TODO(sergey): Since we can't use autodiff here we do algebraic
+ * calculation of derivatives by definition. We could probably
+ * optimize this a bit by doing some extra calculation in wireframe().
+ */
+ if (bump_offset == "dx") {
+ point dx = Dx(P);
+ P -= dx;
+ Fac += (Fac - wireframe("triangles", Size, use_pixel_size)) / length(dx);
+ }
+ else if (bump_offset == "dy") {
+ point dy = Dy(P);
+ P -= dy;
+ Fac += (Fac - wireframe("triangles", Size, use_pixel_size)) / length(dy);
+ }
}
diff --git a/intern/cycles/kernel/shaders/oslutil.h b/intern/cycles/kernel/shaders/oslutil.h
index 592a8ad12d9..d48bfa4a665 100644
--- a/intern/cycles/kernel/shaders/oslutil.h
+++ b/intern/cycles/kernel/shaders/oslutil.h
@@ -39,57 +39,63 @@
//
float wireframe(string edge_type, float line_width, int raster)
{
- // ray differentials are so big in diffuse context that this function would always return "wire"
- if (raytype("path:diffuse")) return 0.0;
+ // ray differentials are so big in diffuse context that this function would always return "wire"
+ if (raytype("path:diffuse"))
+ return 0.0;
- int np = 0;
- point p[64];
- float pixelWidth = 1;
+ int np = 0;
+ point p[64];
+ float pixelWidth = 1;
- if (edge_type == "triangles")
- {
- np = 3;
- if (!getattribute("geom:trianglevertices", p))
- return 0.0;
- }
- else if (edge_type == "polygons" || edge_type == "patches")
- {
- getattribute("geom:numpolyvertices", np);
- if (np < 3 || !getattribute("geom:polyvertices", p))
- return 0.0;
- }
+ if (edge_type == "triangles") {
+ np = 3;
+ if (!getattribute("geom:trianglevertices", p))
+ return 0.0;
+ }
+ else if (edge_type == "polygons" || edge_type == "patches") {
+ getattribute("geom:numpolyvertices", np);
+ if (np < 3 || !getattribute("geom:polyvertices", p))
+ return 0.0;
+ }
- if (raster)
- {
- // Project the derivatives of P to the viewing plane defined
- // by I so we have a measure of how big is a pixel at this point
- float pixelWidthX = length(Dx(P) - dot(Dx(P), I) * I);
- float pixelWidthY = length(Dy(P) - dot(Dy(P), I) * I);
- // Take the average of both axis' length
- pixelWidth = (pixelWidthX + pixelWidthY) / 2;
- }
+ if (raster) {
+ // Project the derivatives of P to the viewing plane defined
+ // by I so we have a measure of how big is a pixel at this point
+ float pixelWidthX = length(Dx(P) - dot(Dx(P), I) * I);
+ float pixelWidthY = length(Dy(P) - dot(Dy(P), I) * I);
+ // Take the average of both axis' length
+ pixelWidth = (pixelWidthX + pixelWidthY) / 2;
+ }
- // Use half the width as the neighbor face will render the
- // other half. And take the square for fast comparison
- pixelWidth *= 0.5 * line_width;
- pixelWidth *= pixelWidth;
- for (int i = 0; i < np; i++)
- {
- int i2 = i ? i - 1 : np - 1;
- vector dir = P - p[i];
- vector edge = p[i] - p[i2];
- vector crs = cross(edge, dir);
- // At this point dot(crs, crs) / dot(edge, edge) is
- // the square of area / length(edge) == square of the
- // distance to the edge.
- if (dot(crs, crs) < (dot(edge, edge) * pixelWidth))
- return 1;
- }
- return 0;
+ // Use half the width as the neighbor face will render the
+ // other half. And take the square for fast comparison
+ pixelWidth *= 0.5 * line_width;
+ pixelWidth *= pixelWidth;
+ for (int i = 0; i < np; i++) {
+ int i2 = i ? i - 1 : np - 1;
+ vector dir = P - p[i];
+ vector edge = p[i] - p[i2];
+ vector crs = cross(edge, dir);
+ // At this point dot(crs, crs) / dot(edge, edge) is
+ // the square of area / length(edge) == square of the
+ // distance to the edge.
+ if (dot(crs, crs) < (dot(edge, edge) * pixelWidth))
+ return 1;
+ }
+ return 0;
}
-float wireframe(string edge_type, float line_width) { return wireframe(edge_type, line_width, 1); }
-float wireframe(string edge_type) { return wireframe(edge_type, 1.0, 1); }
-float wireframe() { return wireframe("polygons", 1.0, 1); }
+float wireframe(string edge_type, float line_width)
+{
+ return wireframe(edge_type, line_width, 1);
+}
+float wireframe(string edge_type)
+{
+ return wireframe(edge_type, 1.0, 1);
+}
+float wireframe()
+{
+ return wireframe("polygons", 1.0, 1);
+}
-#endif /* CCL_OSLUTIL_H */
+#endif /* CCL_OSLUTIL_H */
diff --git a/intern/cycles/kernel/shaders/stdosl.h b/intern/cycles/kernel/shaders/stdosl.h
index 7136c746321..9b9720ffff9 100644
--- a/intern/cycles/kernel/shaders/stdosl.h
+++ b/intern/cycles/kernel/shaders/stdosl.h
@@ -25,124 +25,215 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/////////////////////////////////////////////////////////////////////////////
-
#ifndef CCL_STDOSL_H
#define CCL_STDOSL_H
-
#ifndef M_PI
-#define M_PI 3.1415926535897932 /* pi */
-#define M_PI_2 1.5707963267948966 /* pi/2 */
-#define M_PI_4 0.7853981633974483 /* pi/4 */
-#define M_2_PI 0.6366197723675813 /* 2/pi */
-#define M_2PI 6.2831853071795865 /* 2*pi */
-#define M_4PI 12.566370614359173 /* 4*pi */
-#define M_2_SQRTPI 1.1283791670955126 /* 2/sqrt(pi) */
-#define M_E 2.7182818284590452 /* e (Euler's number) */
-#define M_LN2 0.6931471805599453 /* ln(2) */
-#define M_LN10 2.3025850929940457 /* ln(10) */
-#define M_LOG2E 1.4426950408889634 /* log_2(e) */
-#define M_LOG10E 0.4342944819032518 /* log_10(e) */
-#define M_SQRT2 1.4142135623730950 /* sqrt(2) */
-#define M_SQRT1_2 0.7071067811865475 /* 1/sqrt(2) */
+# define M_PI 3.1415926535897932 /* pi */
+# define M_PI_2 1.5707963267948966 /* pi/2 */
+# define M_PI_4 0.7853981633974483 /* pi/4 */
+# define M_2_PI 0.6366197723675813 /* 2/pi */
+# define M_2PI 6.2831853071795865 /* 2*pi */
+# define M_4PI 12.566370614359173 /* 4*pi */
+# define M_2_SQRTPI 1.1283791670955126 /* 2/sqrt(pi) */
+# define M_E 2.7182818284590452 /* e (Euler's number) */
+# define M_LN2 0.6931471805599453 /* ln(2) */
+# define M_LN10 2.3025850929940457 /* ln(10) */
+# define M_LOG2E 1.4426950408889634 /* log_2(e) */
+# define M_LOG10E 0.4342944819032518 /* log_10(e) */
+# define M_SQRT2 1.4142135623730950 /* sqrt(2) */
+# define M_SQRT1_2 0.7071067811865475 /* 1/sqrt(2) */
#endif
-
-
// Declaration of built-in functions and closures
-#define BUILTIN [[ int builtin = 1 ]]
+#define BUILTIN [[int builtin = 1]]
#define BUILTIN_DERIV [[ int builtin = 1, int deriv = 1 ]]
-#define PERCOMP1(name) \
- normal name (normal x) BUILTIN; \
- vector name (vector x) BUILTIN; \
- point name (point x) BUILTIN; \
- color name (color x) BUILTIN; \
- float name (float x) BUILTIN;
-
-#define PERCOMP2(name) \
- normal name (normal x, normal y) BUILTIN; \
- vector name (vector x, vector y) BUILTIN; \
- point name (point x, point y) BUILTIN; \
- color name (color x, color y) BUILTIN; \
- float name (float x, float y) BUILTIN;
-
-#define PERCOMP2F(name) \
- normal name (normal x, float y) BUILTIN; \
- vector name (vector x, float y) BUILTIN; \
- point name (point x, float y) BUILTIN; \
- color name (color x, float y) BUILTIN; \
- float name (float x, float y) BUILTIN;
-
+#define PERCOMP1(name) \
+ normal name(normal x) BUILTIN; \
+ vector name(vector x) BUILTIN; \
+ point name(point x) BUILTIN; \
+ color name(color x) BUILTIN; \
+ float name(float x) BUILTIN;
+
+#define PERCOMP2(name) \
+ normal name(normal x, normal y) BUILTIN; \
+ vector name(vector x, vector y) BUILTIN; \
+ point name(point x, point y) BUILTIN; \
+ color name(color x, color y) BUILTIN; \
+ float name(float x, float y) BUILTIN;
+
+#define PERCOMP2F(name) \
+ normal name(normal x, float y) BUILTIN; \
+ vector name(vector x, float y) BUILTIN; \
+ point name(point x, float y) BUILTIN; \
+ color name(color x, float y) BUILTIN; \
+ float name(float x, float y) BUILTIN;
// Basic math
-normal degrees (normal x) { return x*(180.0/M_PI); }
-vector degrees (vector x) { return x*(180.0/M_PI); }
-point degrees (point x) { return x*(180.0/M_PI); }
-color degrees (color x) { return x*(180.0/M_PI); }
-float degrees (float x) { return x*(180.0/M_PI); }
-normal radians (normal x) { return x*(M_PI/180.0); }
-vector radians (vector x) { return x*(M_PI/180.0); }
-point radians (point x) { return x*(M_PI/180.0); }
-color radians (color x) { return x*(M_PI/180.0); }
-float radians (float x) { return x*(M_PI/180.0); }
-PERCOMP1 (cos)
-PERCOMP1 (sin)
-PERCOMP1 (tan)
-PERCOMP1 (acos)
-PERCOMP1 (asin)
-PERCOMP1 (atan)
-PERCOMP2 (atan2)
-PERCOMP1 (cosh)
-PERCOMP1 (sinh)
-PERCOMP1 (tanh)
-PERCOMP2F (pow)
-PERCOMP1 (exp)
-PERCOMP1 (exp2)
-PERCOMP1 (expm1)
-PERCOMP1 (log)
-point log (point a, float b) { return log(a)/log(b); }
-vector log (vector a, float b) { return log(a)/log(b); }
-color log (color a, float b) { return log(a)/log(b); }
-float log (float a, float b) { return log(a)/log(b); }
-PERCOMP1 (log2)
-PERCOMP1 (log10)
-PERCOMP1 (logb)
-PERCOMP1 (sqrt)
-PERCOMP1 (inversesqrt)
-float hypot (float a, float b) { return sqrt (a*a + b*b); }
-float hypot (float a, float b, float c) { return sqrt (a*a + b*b + c*c); }
-PERCOMP1 (abs)
-int abs (int x) BUILTIN;
-PERCOMP1 (fabs)
-int fabs (int x) BUILTIN;
-PERCOMP1 (sign)
-PERCOMP1 (floor)
-PERCOMP1 (ceil)
-PERCOMP1 (round)
-PERCOMP1 (trunc)
-PERCOMP2 (fmod)
-PERCOMP2F (fmod)
-int mod (int a, int b) { return a - b*(int)floor(a/b); }
-point mod (point a, point b) { return a - b*floor(a/b); }
-vector mod (vector a, vector b) { return a - b*floor(a/b); }
-normal mod (normal a, normal b) { return a - b*floor(a/b); }
-color mod (color a, color b) { return a - b*floor(a/b); }
-point mod (point a, float b) { return a - b*floor(a/b); }
-vector mod (vector a, float b) { return a - b*floor(a/b); }
-normal mod (normal a, float b) { return a - b*floor(a/b); }
-color mod (color a, float b) { return a - b*floor(a/b); }
-float mod (float a, float b) { return a - b*floor(a/b); }
-PERCOMP2 (min)
-int min (int a, int b) BUILTIN;
-PERCOMP2 (max)
-int max (int a, int b) BUILTIN;
-normal clamp (normal x, normal minval, normal maxval) { return max(min(x,maxval),minval); }
-vector clamp (vector x, vector minval, vector maxval) { return max(min(x,maxval),minval); }
-point clamp (point x, point minval, point maxval) { return max(min(x,maxval),minval); }
-color clamp (color x, color minval, color maxval) { return max(min(x,maxval),minval); }
-float clamp (float x, float minval, float maxval) { return max(min(x,maxval),minval); }
-int clamp (int x, int minval, int maxval) { return max(min(x,maxval),minval); }
+normal degrees(normal x)
+{
+ return x * (180.0 / M_PI);
+}
+vector degrees(vector x)
+{
+ return x * (180.0 / M_PI);
+}
+point degrees(point x)
+{
+ return x * (180.0 / M_PI);
+}
+color degrees(color x)
+{
+ return x * (180.0 / M_PI);
+}
+float degrees(float x)
+{
+ return x * (180.0 / M_PI);
+}
+normal radians(normal x)
+{
+ return x * (M_PI / 180.0);
+}
+vector radians(vector x)
+{
+ return x * (M_PI / 180.0);
+}
+point radians(point x)
+{
+ return x * (M_PI / 180.0);
+}
+color radians(color x)
+{
+ return x * (M_PI / 180.0);
+}
+float radians(float x)
+{
+ return x * (M_PI / 180.0);
+}
+PERCOMP1(cos)
+PERCOMP1(sin)
+PERCOMP1(tan)
+PERCOMP1(acos)
+PERCOMP1(asin)
+PERCOMP1(atan)
+PERCOMP2(atan2)
+PERCOMP1(cosh)
+PERCOMP1(sinh)
+PERCOMP1(tanh)
+PERCOMP2F(pow)
+PERCOMP1(exp)
+PERCOMP1(exp2)
+PERCOMP1(expm1)
+PERCOMP1(log)
+point log(point a, float b)
+{
+ return log(a) / log(b);
+}
+vector log(vector a, float b)
+{
+ return log(a) / log(b);
+}
+color log(color a, float b)
+{
+ return log(a) / log(b);
+}
+float log(float a, float b)
+{
+ return log(a) / log(b);
+}
+PERCOMP1(log2)
+PERCOMP1(log10)
+PERCOMP1(logb)
+PERCOMP1(sqrt)
+PERCOMP1(inversesqrt)
+float hypot(float a, float b)
+{
+ return sqrt(a * a + b * b);
+}
+float hypot(float a, float b, float c)
+{
+ return sqrt(a * a + b * b + c * c);
+}
+PERCOMP1(abs)
+int abs(int x) BUILTIN;
+PERCOMP1(fabs)
+int fabs(int x) BUILTIN;
+PERCOMP1(sign)
+PERCOMP1(floor)
+PERCOMP1(ceil)
+PERCOMP1(round)
+PERCOMP1(trunc)
+PERCOMP2(fmod)
+PERCOMP2F(fmod)
+int mod(int a, int b)
+{
+ return a - b * (int)floor(a / b);
+}
+point mod(point a, point b)
+{
+ return a - b * floor(a / b);
+}
+vector mod(vector a, vector b)
+{
+ return a - b * floor(a / b);
+}
+normal mod(normal a, normal b)
+{
+ return a - b * floor(a / b);
+}
+color mod(color a, color b)
+{
+ return a - b * floor(a / b);
+}
+point mod(point a, float b)
+{
+ return a - b * floor(a / b);
+}
+vector mod(vector a, float b)
+{
+ return a - b * floor(a / b);
+}
+normal mod(normal a, float b)
+{
+ return a - b * floor(a / b);
+}
+color mod(color a, float b)
+{
+ return a - b * floor(a / b);
+}
+float mod(float a, float b)
+{
+ return a - b * floor(a / b);
+}
+PERCOMP2(min)
+int min(int a, int b) BUILTIN;
+PERCOMP2(max)
+int max(int a, int b) BUILTIN;
+normal clamp(normal x, normal minval, normal maxval)
+{
+ return max(min(x, maxval), minval);
+}
+vector clamp(vector x, vector minval, vector maxval)
+{
+ return max(min(x, maxval), minval);
+}
+point clamp(point x, point minval, point maxval)
+{
+ return max(min(x, maxval), minval);
+}
+color clamp(color x, color minval, color maxval)
+{
+ return max(min(x, maxval), minval);
+}
+float clamp(float x, float minval, float maxval)
+{
+ return max(min(x, maxval), minval);
+}
+int clamp(int x, int minval, int maxval)
+{
+ return max(min(x, maxval), minval);
+}
#if 0
normal mix (normal x, normal y, normal a) { return x*(1-a) + y*a; }
normal mix (normal x, normal y, float a) { return x*(1-a) + y*a; }
@@ -154,102 +245,121 @@ color mix (color x, color y, color a) { return x*(1-a) + y*a; }
color mix (color x, color y, float a) { return x*(1-a) + y*a; }
float mix (float x, float y, float a) { return x*(1-a) + y*a; }
#else
-normal mix (normal x, normal y, normal a) BUILTIN;
-normal mix (normal x, normal y, float a) BUILTIN;
-vector mix (vector x, vector y, vector a) BUILTIN;
-vector mix (vector x, vector y, float a) BUILTIN;
-point mix (point x, point y, point a) BUILTIN;
-point mix (point x, point y, float a) BUILTIN;
-color mix (color x, color y, color a) BUILTIN;
-color mix (color x, color y, float a) BUILTIN;
-float mix (float x, float y, float a) BUILTIN;
+normal mix(normal x, normal y, normal a) BUILTIN;
+normal mix(normal x, normal y, float a) BUILTIN;
+vector mix(vector x, vector y, vector a) BUILTIN;
+vector mix(vector x, vector y, float a) BUILTIN;
+point mix(point x, point y, point a) BUILTIN;
+point mix(point x, point y, float a) BUILTIN;
+color mix(color x, color y, color a) BUILTIN;
+color mix(color x, color y, float a) BUILTIN;
+float mix(float x, float y, float a) BUILTIN;
#endif
-int isnan (float x) BUILTIN;
-int isinf (float x) BUILTIN;
-int isfinite (float x) BUILTIN;
-float erf (float x) BUILTIN;
-float erfc (float x) BUILTIN;
+int isnan(float x) BUILTIN;
+int isinf(float x) BUILTIN;
+int isfinite(float x) BUILTIN;
+float erf(float x) BUILTIN;
+float erfc(float x) BUILTIN;
// Vector functions
-vector cross (vector a, vector b) BUILTIN;
-float dot (vector a, vector b) BUILTIN;
-float length (vector v) BUILTIN;
-float distance (point a, point b) BUILTIN;
-float distance (point a, point b, point q)
-{
- vector d = b - a;
- float dd = dot(d, d);
- if(dd == 0.0)
- return distance(q, a);
- float t = dot(q - a, d)/dd;
- return distance(q, a + clamp(t, 0.0, 1.0)*d);
-}
-normal normalize (normal v) BUILTIN;
-vector normalize (vector v) BUILTIN;
-vector faceforward (vector N, vector I, vector Nref) BUILTIN;
-vector faceforward (vector N, vector I) BUILTIN;
-vector reflect (vector I, vector N) { return I - 2*dot(N,I)*N; }
-vector refract (vector I, vector N, float eta) {
- float IdotN = dot (I, N);
- float k = 1 - eta*eta * (1 - IdotN*IdotN);
- return (k < 0) ? vector(0,0,0) : (eta*I - N * (eta*IdotN + sqrt(k)));
-}
-void fresnel (vector I, normal N, float eta,
- output float Kr, output float Kt,
- output vector R, output vector T)
-{
- float sqr(float x) { return x*x; }
- float c = dot(I, N);
- if (c < 0)
- c = -c;
- R = reflect(I, N);
- float g = 1.0 / sqr(eta) - 1.0 + c * c;
- if (g >= 0.0) {
- g = sqrt (g);
- float beta = g - c;
- float F = (c * (g+c) - 1.0) / (c * beta + 1.0);
- F = 0.5 * (1.0 + sqr(F));
- F *= sqr (beta / (g+c));
- Kr = F;
- Kt = (1.0 - Kr) * eta*eta;
- // OPT: the following recomputes some of the above values, but it
- // gives us the same result as if the shader-writer called refract()
- T = refract(I, N, eta);
- } else {
- // total internal reflection
- Kr = 1.0;
- Kt = 0.0;
- T = vector (0,0,0);
- }
+vector cross(vector a, vector b) BUILTIN;
+float dot(vector a, vector b) BUILTIN;
+float length(vector v) BUILTIN;
+float distance(point a, point b) BUILTIN;
+float distance(point a, point b, point q)
+{
+ vector d = b - a;
+ float dd = dot(d, d);
+ if (dd == 0.0)
+ return distance(q, a);
+ float t = dot(q - a, d) / dd;
+ return distance(q, a + clamp(t, 0.0, 1.0) * d);
}
-
-void fresnel (vector I, normal N, float eta,
- output float Kr, output float Kt)
+normal normalize(normal v) BUILTIN;
+vector normalize(vector v) BUILTIN;
+vector faceforward(vector N, vector I, vector Nref) BUILTIN;
+vector faceforward(vector N, vector I) BUILTIN;
+vector reflect(vector I, vector N)
{
- vector R, T;
- fresnel(I, N, eta, Kr, Kt, R, T);
+ return I - 2 * dot(N, I) * N;
+}
+vector refract(vector I, vector N, float eta)
+{
+ float IdotN = dot(I, N);
+ float k = 1 - eta * eta * (1 - IdotN * IdotN);
+ return (k < 0) ? vector(0, 0, 0) : (eta * I - N * (eta * IdotN + sqrt(k)));
+}
+void fresnel(vector I,
+ normal N,
+ float eta,
+ output float Kr,
+ output float Kt,
+ output vector R,
+ output vector T)
+{
+ float sqr(float x)
+ {
+ return x * x;
+ }
+ float c = dot(I, N);
+ if (c < 0)
+ c = -c;
+ R = reflect(I, N);
+ float g = 1.0 / sqr(eta) - 1.0 + c * c;
+ if (g >= 0.0) {
+ g = sqrt(g);
+ float beta = g - c;
+ float F = (c * (g + c) - 1.0) / (c * beta + 1.0);
+ F = 0.5 * (1.0 + sqr(F));
+ F *= sqr(beta / (g + c));
+ Kr = F;
+ Kt = (1.0 - Kr) * eta * eta;
+ // OPT: the following recomputes some of the above values, but it
+ // gives us the same result as if the shader-writer called refract()
+ T = refract(I, N, eta);
+ }
+ else {
+ // total internal reflection
+ Kr = 1.0;
+ Kt = 0.0;
+ T = vector(0, 0, 0);
+ }
}
+void fresnel(vector I, normal N, float eta, output float Kr, output float Kt)
+{
+ vector R, T;
+ fresnel(I, N, eta, Kr, Kt, R, T);
+}
-normal transform (matrix Mto, normal p) BUILTIN;
-vector transform (matrix Mto, vector p) BUILTIN;
-point transform (matrix Mto, point p) BUILTIN;
-normal transform (string from, string to, normal p) BUILTIN;
-vector transform (string from, string to, vector p) BUILTIN;
-point transform (string from, string to, point p) BUILTIN;
-normal transform (string to, normal p) { return transform("common",to,p); }
-vector transform (string to, vector p) { return transform("common",to,p); }
-point transform (string to, point p) { return transform("common",to,p); }
+normal transform(matrix Mto, normal p) BUILTIN;
+vector transform(matrix Mto, vector p) BUILTIN;
+point transform(matrix Mto, point p) BUILTIN;
+normal transform(string from, string to, normal p) BUILTIN;
+vector transform(string from, string to, vector p) BUILTIN;
+point transform(string from, string to, point p) BUILTIN;
+normal transform(string to, normal p)
+{
+ return transform("common", to, p);
+}
+vector transform(string to, vector p)
+{
+ return transform("common", to, p);
+}
+point transform(string to, point p)
+{
+ return transform("common", to, p);
+}
-float transformu (string tounits, float x) BUILTIN;
-float transformu (string fromunits, string tounits, float x) BUILTIN;
+float transformu(string tounits, float x) BUILTIN;
+float transformu(string fromunits, string tounits, float x) BUILTIN;
-point rotate (point p, float angle, point a, point b)
+point rotate(point p, float angle, point a, point b)
{
- vector axis = normalize (b - a);
- float cosang, sinang;
- /* Older OSX has major issues with sincos() function,
+ vector axis = normalize(b - a);
+ float cosang, sinang;
+ /* Older OSX has major issues with sincos() function,
* it's likely a big in OSL or LLVM. For until we've
* updated to new versions of this libraries we'll
* use a workaround to prevent possible crashes on all
@@ -261,317 +371,348 @@ point rotate (point p, float angle, point a, point b)
#if 0
sincos (angle, sinang, cosang);
#else
- sinang = sin (angle);
- cosang = cos (angle);
+ sinang = sin(angle);
+ cosang = cos(angle);
#endif
- float cosang1 = 1.0 - cosang;
- float x = axis[0], y = axis[1], z = axis[2];
- matrix M = matrix (x * x + (1.0 - x * x) * cosang,
- x * y * cosang1 + z * sinang,
- x * z * cosang1 - y * sinang,
- 0.0,
- x * y * cosang1 - z * sinang,
- y * y + (1.0 - y * y) * cosang,
- y * z * cosang1 + x * sinang,
- 0.0,
- x * z * cosang1 + y * sinang,
- y * z * cosang1 - x * sinang,
- z * z + (1.0 - z * z) * cosang,
- 0.0,
- 0.0, 0.0, 0.0, 1.0);
- return transform (M, p-a) + a;
+ float cosang1 = 1.0 - cosang;
+ float x = axis[0], y = axis[1], z = axis[2];
+ matrix M = matrix(x * x + (1.0 - x * x) * cosang,
+ x * y * cosang1 + z * sinang,
+ x * z * cosang1 - y * sinang,
+ 0.0,
+ x * y * cosang1 - z * sinang,
+ y * y + (1.0 - y * y) * cosang,
+ y * z * cosang1 + x * sinang,
+ 0.0,
+ x * z * cosang1 + y * sinang,
+ y * z * cosang1 - x * sinang,
+ z * z + (1.0 - z * z) * cosang,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 1.0);
+ return transform(M, p - a) + a;
}
normal ensure_valid_reflection(normal Ng, vector I, normal N)
{
- /* The implementation here mirrors the one in kernel_montecarlo.h,
+ /* The implementation here mirrors the one in kernel_montecarlo.h,
* check there for an explanation of the algorithm. */
- float sqr(float x) { return x*x; }
-
- vector R = 2*dot(N, I)*N - I;
+ float sqr(float x)
+ {
+ return x * x;
+ }
- float threshold = min(0.9*dot(Ng, I), 0.01);
- if(dot(Ng, R) >= threshold) {
- return N;
- }
+ vector R = 2 * dot(N, I) * N - I;
- float NdotNg = dot(N, Ng);
- vector X = normalize(N - NdotNg*Ng);
+ float threshold = min(0.9 * dot(Ng, I), 0.01);
+ if (dot(Ng, R) >= threshold) {
+ return N;
+ }
- float Ix = dot(I, X), Iz = dot(I, Ng);
- float Ix2 = sqr(Ix), Iz2 = sqr(Iz);
- float a = Ix2 + Iz2;
+ float NdotNg = dot(N, Ng);
+ vector X = normalize(N - NdotNg * Ng);
- float b = sqrt(Ix2*(a - sqr(threshold)));
- float c = Iz*threshold + a;
+ float Ix = dot(I, X), Iz = dot(I, Ng);
+ float Ix2 = sqr(Ix), Iz2 = sqr(Iz);
+ float a = Ix2 + Iz2;
- float fac = 0.5/a;
- float N1_z2 = fac*(b+c), N2_z2 = fac*(-b+c);
- int valid1 = (N1_z2 > 1e-5) && (N1_z2 <= (1.0 + 1e-5));
- int valid2 = (N2_z2 > 1e-5) && (N2_z2 <= (1.0 + 1e-5));
+ float b = sqrt(Ix2 * (a - sqr(threshold)));
+ float c = Iz * threshold + a;
- float N_new_x, N_new_z;
- if(valid1 && valid2) {
- float N1_x = sqrt(1.0 - N1_z2), N1_z = sqrt(N1_z2);
- float N2_x = sqrt(1.0 - N2_z2), N2_z = sqrt(N2_z2);
+ float fac = 0.5 / a;
+ float N1_z2 = fac * (b + c), N2_z2 = fac * (-b + c);
+ int valid1 = (N1_z2 > 1e-5) && (N1_z2 <= (1.0 + 1e-5));
+ int valid2 = (N2_z2 > 1e-5) && (N2_z2 <= (1.0 + 1e-5));
- float R1 = 2*(N1_x*Ix + N1_z*Iz)*N1_z - Iz;
- float R2 = 2*(N2_x*Ix + N2_z*Iz)*N2_z - Iz;
+ float N_new_x, N_new_z;
+ if (valid1 && valid2) {
+ float N1_x = sqrt(1.0 - N1_z2), N1_z = sqrt(N1_z2);
+ float N2_x = sqrt(1.0 - N2_z2), N2_z = sqrt(N2_z2);
- valid1 = (R1 >= 1e-5);
- valid2 = (R2 >= 1e-5);
- if(valid1 && valid2) {
- N_new_x = (R1 < R2)? N1_x : N2_x;
- N_new_z = (R1 < R2)? N1_z : N2_z;
- }
- else {
- N_new_x = (R1 > R2)? N1_x : N2_x;
- N_new_z = (R1 > R2)? N1_z : N2_z;
- }
+ float R1 = 2 * (N1_x * Ix + N1_z * Iz) * N1_z - Iz;
+ float R2 = 2 * (N2_x * Ix + N2_z * Iz) * N2_z - Iz;
- }
- else if(valid1 || valid2) {
- float Nz2 = valid1? N1_z2 : N2_z2;
- N_new_x = sqrt(1.0 - Nz2);
- N_new_z = sqrt(Nz2);
+ valid1 = (R1 >= 1e-5);
+ valid2 = (R2 >= 1e-5);
+ if (valid1 && valid2) {
+ N_new_x = (R1 < R2) ? N1_x : N2_x;
+ N_new_z = (R1 < R2) ? N1_z : N2_z;
}
else {
- return Ng;
+ N_new_x = (R1 > R2) ? N1_x : N2_x;
+ N_new_z = (R1 > R2) ? N1_z : N2_z;
}
-
- return N_new_x*X + N_new_z*Ng;
+ }
+ else if (valid1 || valid2) {
+ float Nz2 = valid1 ? N1_z2 : N2_z2;
+ N_new_x = sqrt(1.0 - Nz2);
+ N_new_z = sqrt(Nz2);
+ }
+ else {
+ return Ng;
+ }
+
+ return N_new_x * X + N_new_z * Ng;
}
-
// Color functions
-float luminance (color c) BUILTIN;
-color blackbody (float temperatureK) BUILTIN;
-color wavelength_color (float wavelength_nm) BUILTIN;
-
-
-color transformc (string to, color x)
-{
- color rgb_to_hsv (color rgb) { // See Foley & van Dam
- float r = rgb[0], g = rgb[1], b = rgb[2];
- float mincomp = min (r, min (g, b));
- float maxcomp = max (r, max (g, b));
- float delta = maxcomp - mincomp; // chroma
- float h, s, v;
- v = maxcomp;
- if (maxcomp > 0)
- s = delta / maxcomp;
- else s = 0;
- if (s <= 0)
- h = 0;
- else {
- if (r >= maxcomp) h = (g-b) / delta;
- else if (g >= maxcomp) h = 2 + (b-r) / delta;
- else h = 4 + (r-g) / delta;
- h /= 6;
- if (h < 0)
- h += 1;
- }
- return color (h, s, v);
- }
-
- color rgb_to_hsl (color rgb) { // See Foley & van Dam
- // First convert rgb to hsv, then to hsl
- float minval = min (rgb[0], min (rgb[1], rgb[2]));
- color hsv = rgb_to_hsv (rgb);
- float maxval = hsv[2]; // v == maxval
- float h = hsv[0], s, l = (minval+maxval) / 2;
- if (minval == maxval)
- s = 0; // special 'achromatic' case, hue is 0
- else if (l <= 0.5)
- s = (maxval - minval) / (maxval + minval);
- else
- s = (maxval - minval) / (2 - maxval - minval);
- return color (h, s, l);
- }
+float luminance(color c) BUILTIN;
+color blackbody(float temperatureK) BUILTIN;
+color wavelength_color(float wavelength_nm) BUILTIN;
- color r;
- if (to == "rgb" || to == "RGB")
- r = x;
- else if (to == "hsv")
- r = rgb_to_hsv (x);
- else if (to == "hsl")
- r = rgb_to_hsl (x);
- else if (to == "YIQ")
- r = color (dot (vector(0.299, 0.587, 0.114), (vector)x),
- dot (vector(0.596, -0.275, -0.321), (vector)x),
- dot (vector(0.212, -0.523, 0.311), (vector)x));
- else if (to == "XYZ")
- r = color (dot (vector(0.412453, 0.357580, 0.180423), (vector)x),
- dot (vector(0.212671, 0.715160, 0.072169), (vector)x),
- dot (vector(0.019334, 0.119193, 0.950227), (vector)x));
+color transformc(string to, color x)
+{
+ color rgb_to_hsv(color rgb)
+ { // See Foley & van Dam
+ float r = rgb[0], g = rgb[1], b = rgb[2];
+ float mincomp = min(r, min(g, b));
+ float maxcomp = max(r, max(g, b));
+ float delta = maxcomp - mincomp; // chroma
+ float h, s, v;
+ v = maxcomp;
+ if (maxcomp > 0)
+ s = delta / maxcomp;
+ else
+ s = 0;
+ if (s <= 0)
+ h = 0;
else {
- error ("Unknown color space \"%s\"", to);
- r = x;
+ if (r >= maxcomp)
+ h = (g - b) / delta;
+ else if (g >= maxcomp)
+ h = 2 + (b - r) / delta;
+ else
+ h = 4 + (r - g) / delta;
+ h /= 6;
+ if (h < 0)
+ h += 1;
}
- return r;
+ return color(h, s, v);
+ }
+
+ color rgb_to_hsl(color rgb)
+ { // See Foley & van Dam
+ // First convert rgb to hsv, then to hsl
+ float minval = min(rgb[0], min(rgb[1], rgb[2]));
+ color hsv = rgb_to_hsv(rgb);
+ float maxval = hsv[2]; // v == maxval
+ float h = hsv[0], s, l = (minval + maxval) / 2;
+ if (minval == maxval)
+ s = 0; // special 'achromatic' case, hue is 0
+ else if (l <= 0.5)
+ s = (maxval - minval) / (maxval + minval);
+ else
+ s = (maxval - minval) / (2 - maxval - minval);
+ return color(h, s, l);
+ }
+
+ color r;
+ if (to == "rgb" || to == "RGB")
+ r = x;
+ else if (to == "hsv")
+ r = rgb_to_hsv(x);
+ else if (to == "hsl")
+ r = rgb_to_hsl(x);
+ else if (to == "YIQ")
+ r = color(dot(vector(0.299, 0.587, 0.114), (vector)x),
+ dot(vector(0.596, -0.275, -0.321), (vector)x),
+ dot(vector(0.212, -0.523, 0.311), (vector)x));
+ else if (to == "XYZ")
+ r = color(dot(vector(0.412453, 0.357580, 0.180423), (vector)x),
+ dot(vector(0.212671, 0.715160, 0.072169), (vector)x),
+ dot(vector(0.019334, 0.119193, 0.950227), (vector)x));
+ else {
+ error("Unknown color space \"%s\"", to);
+ r = x;
+ }
+ return r;
}
-
-color transformc (string from, string to, color x)
-{
- color hsv_to_rgb (color c) { // Reference: Foley & van Dam
- float h = c[0], s = c[1], v = c[2];
- color r;
- if (s < 0.0001) {
- r = v;
- } else {
- h = 6 * (h - floor(h)); // expand to [0..6)
- int hi = (int)h;
- float f = h - hi;
- float p = v * (1-s);
- float q = v * (1-s*f);
- float t = v * (1-s*(1-f));
- if (hi == 0) r = color (v, t, p);
- else if (hi == 1) r = color (q, v, p);
- else if (hi == 2) r = color (p, v, t);
- else if (hi == 3) r = color (p, q, v);
- else if (hi == 4) r = color (t, p, v);
- else r = color (v, p, q);
- }
- return r;
+color transformc(string from, string to, color x)
+{
+ color hsv_to_rgb(color c)
+ { // Reference: Foley & van Dam
+ float h = c[0], s = c[1], v = c[2];
+ color r;
+ if (s < 0.0001) {
+ r = v;
}
-
- color hsl_to_rgb (color c) {
- float h = c[0], s = c[1], l = c[2];
- // Easiest to convert hsl -> hsv, then hsv -> RGB (per Foley & van Dam)
- float v = (l <= 0.5) ? (l * (1 + s)) : (l * (1 - s) + s);
- color r;
- if (v <= 0) {
- r = 0;
- } else {
- float min = 2 * l - v;
- s = (v - min) / v;
- r = hsv_to_rgb (color (h, s, v));
- }
- return r;
+ else {
+ h = 6 * (h - floor(h)); // expand to [0..6)
+ int hi = (int)h;
+ float f = h - hi;
+ float p = v * (1 - s);
+ float q = v * (1 - s * f);
+ float t = v * (1 - s * (1 - f));
+ if (hi == 0)
+ r = color(v, t, p);
+ else if (hi == 1)
+ r = color(q, v, p);
+ else if (hi == 2)
+ r = color(p, v, t);
+ else if (hi == 3)
+ r = color(p, q, v);
+ else if (hi == 4)
+ r = color(t, p, v);
+ else
+ r = color(v, p, q);
}
+ return r;
+ }
+ color hsl_to_rgb(color c)
+ {
+ float h = c[0], s = c[1], l = c[2];
+ // Easiest to convert hsl -> hsv, then hsv -> RGB (per Foley & van Dam)
+ float v = (l <= 0.5) ? (l * (1 + s)) : (l * (1 - s) + s);
color r;
- if (from == "rgb" || from == "RGB")
- r = x;
- else if (from == "hsv")
- r = hsv_to_rgb (x);
- else if (from == "hsl")
- r = hsl_to_rgb (x);
- else if (from == "YIQ")
- r = color (dot (vector(1, 0.9557, 0.6199), (vector)x),
- dot (vector(1, -0.2716, -0.6469), (vector)x),
- dot (vector(1, -1.1082, 1.7051), (vector)x));
- else if (from == "XYZ")
- r = color (dot (vector( 3.240479, -1.537150, -0.498535), (vector)x),
- dot (vector(-0.969256, 1.875991, 0.041556), (vector)x),
- dot (vector( 0.055648, -0.204043, 1.057311), (vector)x));
+ if (v <= 0) {
+ r = 0;
+ }
else {
- error ("Unknown color space \"%s\"", to);
- r = x;
+ float min = 2 * l - v;
+ s = (v - min) / v;
+ r = hsv_to_rgb(color(h, s, v));
}
- return transformc (to, r);
+ return r;
+ }
+
+ color r;
+ if (from == "rgb" || from == "RGB")
+ r = x;
+ else if (from == "hsv")
+ r = hsv_to_rgb(x);
+ else if (from == "hsl")
+ r = hsl_to_rgb(x);
+ else if (from == "YIQ")
+ r = color(dot(vector(1, 0.9557, 0.6199), (vector)x),
+ dot(vector(1, -0.2716, -0.6469), (vector)x),
+ dot(vector(1, -1.1082, 1.7051), (vector)x));
+ else if (from == "XYZ")
+ r = color(dot(vector(3.240479, -1.537150, -0.498535), (vector)x),
+ dot(vector(-0.969256, 1.875991, 0.041556), (vector)x),
+ dot(vector(0.055648, -0.204043, 1.057311), (vector)x));
+ else {
+ error("Unknown color space \"%s\"", to);
+ r = x;
+ }
+ return transformc(to, r);
}
-
-
// Matrix functions
-float determinant (matrix m) BUILTIN;
-matrix transpose (matrix m) BUILTIN;
+float determinant(matrix m) BUILTIN;
+matrix transpose(matrix m) BUILTIN;
+// Pattern generation
+color step(color edge, color x) BUILTIN;
+point step(point edge, point x) BUILTIN;
+vector step(vector edge, vector x) BUILTIN;
+normal step(normal edge, normal x) BUILTIN;
+float step(float edge, float x) BUILTIN;
+float smoothstep(float edge0, float edge1, float x) BUILTIN;
-// Pattern generation
+float linearstep(float edge0, float edge1, float x)
+{
+ float result;
+ if (edge0 != edge1) {
+ float xclamped = clamp(x, edge0, edge1);
+ result = (xclamped - edge0) / (edge1 - edge0);
+ }
+ else { // special case: edges coincide
+ result = step(edge0, x);
+ }
+ return result;
+}
-color step (color edge, color x) BUILTIN;
-point step (point edge, point x) BUILTIN;
-vector step (vector edge, vector x) BUILTIN;
-normal step (normal edge, normal x) BUILTIN;
-float step (float edge, float x) BUILTIN;
-float smoothstep (float edge0, float edge1, float x) BUILTIN;
-
-float linearstep (float edge0, float edge1, float x) {
- float result;
- if (edge0 != edge1) {
- float xclamped = clamp (x, edge0, edge1);
- result = (xclamped - edge0) / (edge1 - edge0);
- } else { // special case: edges coincide
- result = step (edge0, x);
- }
- return result;
-}
-
-float smooth_linearstep (float edge0, float edge1, float x_, float eps_) {
- float result;
- if (edge0 != edge1) {
- float rampup (float x, float r) { return 0.5/r * x*x; }
- float width_inv = 1.0 / (edge1 - edge0);
- float eps = eps_ * width_inv;
- float x = (x_ - edge0) * width_inv;
- if (x <= -eps) result = 0;
- else if (x >= eps && x <= 1.0-eps) result = x;
- else if (x >= 1.0+eps) result = 1;
- else if (x < eps) result = rampup (x+eps, 2.0*eps);
- else /* if (x < 1.0+eps) */ result = 1.0 - rampup (1.0+eps - x, 2.0*eps);
- } else {
- result = step (edge0, x_);
+float smooth_linearstep(float edge0, float edge1, float x_, float eps_)
+{
+ float result;
+ if (edge0 != edge1) {
+ float rampup(float x, float r)
+ {
+ return 0.5 / r * x * x;
}
- return result;
+ float width_inv = 1.0 / (edge1 - edge0);
+ float eps = eps_ * width_inv;
+ float x = (x_ - edge0) * width_inv;
+ if (x <= -eps)
+ result = 0;
+ else if (x >= eps && x <= 1.0 - eps)
+ result = x;
+ else if (x >= 1.0 + eps)
+ result = 1;
+ else if (x < eps)
+ result = rampup(x + eps, 2.0 * eps);
+ else /* if (x < 1.0+eps) */
+ result = 1.0 - rampup(1.0 + eps - x, 2.0 * eps);
+ }
+ else {
+ result = step(edge0, x_);
+ }
+ return result;
}
-float aastep (float edge, float s, float dedge, float ds) {
- // Box filtered AA step
- float width = fabs(dedge) + fabs(ds);
- float halfwidth = 0.5*width;
- float e1 = edge-halfwidth;
- return (s <= e1) ? 0.0 : ((s >= (edge+halfwidth)) ? 1.0 : (s-e1)/width);
+float aastep(float edge, float s, float dedge, float ds)
+{
+ // Box filtered AA step
+ float width = fabs(dedge) + fabs(ds);
+ float halfwidth = 0.5 * width;
+ float e1 = edge - halfwidth;
+ return (s <= e1) ? 0.0 : ((s >= (edge + halfwidth)) ? 1.0 : (s - e1) / width);
}
-float aastep (float edge, float s, float ds) {
- return aastep (edge, s, filterwidth(edge), ds);
+float aastep(float edge, float s, float ds)
+{
+ return aastep(edge, s, filterwidth(edge), ds);
}
-float aastep (float edge, float s) {
- return aastep (edge, s, filterwidth(edge), filterwidth(s));
+float aastep(float edge, float s)
+{
+ return aastep(edge, s, filterwidth(edge), filterwidth(s));
}
-
// Derivatives and area operators
-
// Displacement functions
-
// String functions
-int strlen (string s) BUILTIN;
-int hash (string s) BUILTIN;
-int getchar (string s, int index) BUILTIN;
-int startswith (string s, string prefix) BUILTIN;
-int endswith (string s, string suffix) BUILTIN;
-string substr (string s, int start, int len) BUILTIN;
-string substr (string s, int start) { return substr (s, start, strlen(s)); }
-float stof (string str) BUILTIN;
-int stoi (string str) BUILTIN;
+int strlen(string s) BUILTIN;
+int hash(string s) BUILTIN;
+int getchar(string s, int index) BUILTIN;
+int startswith(string s, string prefix) BUILTIN;
+int endswith(string s, string suffix) BUILTIN;
+string substr(string s, int start, int len) BUILTIN;
+string substr(string s, int start)
+{
+ return substr(s, start, strlen(s));
+}
+float stof(string str) BUILTIN;
+int stoi(string str) BUILTIN;
// Define concat in terms of shorter concat
-string concat (string a, string b, string c) {
- return concat(concat(a,b), c);
+string concat(string a, string b, string c)
+{
+ return concat(concat(a, b), c);
}
-string concat (string a, string b, string c, string d) {
- return concat(concat(a,b,c), d);
+string concat(string a, string b, string c, string d)
+{
+ return concat(concat(a, b, c), d);
}
-string concat (string a, string b, string c, string d, string e) {
- return concat(concat(a,b,c,d), e);
+string concat(string a, string b, string c, string d, string e)
+{
+ return concat(concat(a, b, c, d), e);
}
-string concat (string a, string b, string c, string d, string e, string f) {
- return concat(concat(a,b,c,d,e), f);
+string concat(string a, string b, string c, string d, string e, string f)
+{
+ return concat(concat(a, b, c, d, e), f);
}
-
// Texture
-
// Closures
closure color diffuse(normal N) BUILTIN;
@@ -591,14 +732,18 @@ closure color microfacet_multi_ggx(normal N, float ag, color C) BUILTIN;
closure color microfacet_multi_ggx_aniso(normal N, vector T, float ax, float ay, color C) BUILTIN;
closure color microfacet_multi_ggx_glass(normal N, float ag, float eta, color C) BUILTIN;
closure color microfacet_ggx_fresnel(normal N, float ag, float eta, color C, color Cspec0) BUILTIN;
-closure color microfacet_ggx_aniso_fresnel(normal N, vector T, float ax, float ay, float eta, color C, color Cspec0) BUILTIN;
-closure color microfacet_multi_ggx_fresnel(normal N, float ag, float eta, color C, color Cspec0) BUILTIN;
-closure color microfacet_multi_ggx_aniso_fresnel(normal N, vector T, float ax, float ay, float eta, color C, color Cspec0) BUILTIN;
-closure color microfacet_multi_ggx_glass_fresnel(normal N, float ag, float eta, color C, color Cspec0) BUILTIN;
+closure color microfacet_ggx_aniso_fresnel(
+ normal N, vector T, float ax, float ay, float eta, color C, color Cspec0) BUILTIN;
+closure color
+microfacet_multi_ggx_fresnel(normal N, float ag, float eta, color C, color Cspec0) BUILTIN;
+closure color microfacet_multi_ggx_aniso_fresnel(
+ normal N, vector T, float ax, float ay, float eta, color C, color Cspec0) BUILTIN;
+closure color
+microfacet_multi_ggx_glass_fresnel(normal N, float ag, float eta, color C, color Cspec0) BUILTIN;
closure color microfacet_beckmann(normal N, float ab) BUILTIN;
closure color microfacet_beckmann_aniso(normal N, vector T, float ax, float ay) BUILTIN;
closure color microfacet_beckmann_refraction(normal N, float ab, float eta) BUILTIN;
-closure color ashikhmin_shirley(normal N, vector T,float ax, float ay) BUILTIN;
+closure color ashikhmin_shirley(normal N, vector T, float ax, float ay) BUILTIN;
closure color ashikhmin_velvet(normal N, float sigma) BUILTIN;
closure color emission() BUILTIN;
closure color background() BUILTIN;
@@ -612,78 +757,97 @@ closure color principled_clearcoat(normal N, float clearcoat, float clearcoat_ro
closure color bssrdf(string method, normal N, vector radius, color albedo) BUILTIN;
// Hair
-closure color hair_reflection(normal N, float roughnessu, float roughnessv, vector T, float offset) BUILTIN;
-closure color hair_transmission(normal N, float roughnessu, float roughnessv, vector T, float offset) BUILTIN;
-closure color principled_hair(normal N, color sigma, float roughnessu, float roughnessv, float coat, float alpha, float eta) BUILTIN;
+closure color
+hair_reflection(normal N, float roughnessu, float roughnessv, vector T, float offset) BUILTIN;
+closure color
+hair_transmission(normal N, float roughnessu, float roughnessv, vector T, float offset) BUILTIN;
+closure color principled_hair(normal N,
+ color sigma,
+ float roughnessu,
+ float roughnessv,
+ float coat,
+ float alpha,
+ float eta) BUILTIN;
// Volume
closure color henyey_greenstein(float g) BUILTIN;
closure color absorption() BUILTIN;
// OSL 1.5 Microfacet functions
-closure color microfacet(string distribution, normal N, vector U, float xalpha, float yalpha, float eta, int refract) {
- /* GGX */
- if (distribution == "ggx" || distribution == "default") {
- if (!refract) {
- if (xalpha == yalpha) {
- /* Isotropic */
- return microfacet_ggx(N, xalpha);
- }
- else {
- /* Anisotropic */
- return microfacet_ggx_aniso(N, U, xalpha, yalpha);
- }
- }
- else {
- return microfacet_ggx_refraction(N, xalpha, eta);
- }
- }
- /* Beckmann */
- else {
- if (!refract) {
- if (xalpha == yalpha) {
- /* Isotropic */
- return microfacet_beckmann(N, xalpha);
- }
- else {
- /* Anisotropic */
- return microfacet_beckmann_aniso(N, U, xalpha, yalpha);
- }
- }
- else {
- return microfacet_beckmann_refraction(N, xalpha, eta);
- }
- }
-}
-
-closure color microfacet (string distribution, normal N, float alpha, float eta, int refract) {
- return microfacet(distribution, N, vector(0), alpha, alpha, eta, refract);
+closure color microfacet(
+ string distribution, normal N, vector U, float xalpha, float yalpha, float eta, int refract)
+{
+ /* GGX */
+ if (distribution == "ggx" || distribution == "default") {
+ if (!refract) {
+ if (xalpha == yalpha) {
+ /* Isotropic */
+ return microfacet_ggx(N, xalpha);
+ }
+ else {
+ /* Anisotropic */
+ return microfacet_ggx_aniso(N, U, xalpha, yalpha);
+ }
+ }
+ else {
+ return microfacet_ggx_refraction(N, xalpha, eta);
+ }
+ }
+ /* Beckmann */
+ else {
+ if (!refract) {
+ if (xalpha == yalpha) {
+ /* Isotropic */
+ return microfacet_beckmann(N, xalpha);
+ }
+ else {
+ /* Anisotropic */
+ return microfacet_beckmann_aniso(N, U, xalpha, yalpha);
+ }
+ }
+ else {
+ return microfacet_beckmann_refraction(N, xalpha, eta);
+ }
+ }
}
+closure color microfacet(string distribution, normal N, float alpha, float eta, int refract)
+{
+ return microfacet(distribution, N, vector(0), alpha, alpha, eta, refract);
+}
// Renderer state
-int backfacing () BUILTIN;
-int raytype (string typename) BUILTIN;
+int backfacing() BUILTIN;
+int raytype(string typename) BUILTIN;
// the individual 'isFOOray' functions are deprecated
-int iscameraray () { return raytype("camera"); }
-int isdiffuseray () { return raytype("diffuse"); }
-int isglossyray () { return raytype("glossy"); }
-int isshadowray () { return raytype("shadow"); }
-int getmatrix (string fromspace, string tospace, output matrix M) BUILTIN;
-int getmatrix (string fromspace, output matrix M) {
- return getmatrix (fromspace, "common", M);
+int iscameraray()
+{
+ return raytype("camera");
+}
+int isdiffuseray()
+{
+ return raytype("diffuse");
+}
+int isglossyray()
+{
+ return raytype("glossy");
+}
+int isshadowray()
+{
+ return raytype("shadow");
+}
+int getmatrix(string fromspace, string tospace, output matrix M) BUILTIN;
+int getmatrix(string fromspace, output matrix M)
+{
+ return getmatrix(fromspace, "common", M);
}
-
// Miscellaneous
-
-
-
#undef BUILTIN
#undef BUILTIN_DERIV
#undef PERCOMP1
#undef PERCOMP2
#undef PERCOMP2F
-#endif /* CCL_STDOSL_H */
+#endif /* CCL_STDOSL_H */