OSL Shader Files:

* Simplify default color values, where each component was the same.
* Initialize closures as Null Closure, rather than assigning an existing closure, gets overwritten anyways.
This commit is contained in:
Thomas Dinges
2012-12-11 16:06:03 +00:00
parent 92ae023a90
commit 188718a3d5
42 changed files with 70 additions and 70 deletions

View File

@@ -19,9 +19,9 @@
#include "stdosl.h"
shader node_add_closure(
closure color Closure1 = background(),
closure color Closure2 = background(),
output closure color Closure = background())
closure color Closure1 = 0,
closure color Closure2 = 0,
output closure color Closure = 0)
{
Closure = Closure1 + Closure2;
}

View File

@@ -20,8 +20,8 @@
shader node_ambient_occlusion(
normal NormalIn = N,
color Color = color(0.8, 0.8, 0.8),
output closure color AO = ambient_occlusion())
color Color = 0.8,
output closure color AO = 0)
{
AO = Color * ambient_occlusion();
}

View File

@@ -22,7 +22,7 @@ shader node_attribute(
string bump_offset = "center",
string name = "",
output point Vector = point(0.0, 0.0, 0.0),
output color Color = color(0.0, 0.0, 0.0),
output color Color = 0.0,
output float Fac = 0.0)
{
getattribute(name, Color);

View File

@@ -19,9 +19,9 @@
#include "stdosl.h"
shader node_background(
color Color = color(0.8, 0.8, 0.8),
color Color = 0.8,
float Strength = 1.0,
output closure color Background = background())
output closure color Background = 0)
{
Background = Color * Strength * background();
}

View File

@@ -65,16 +65,16 @@ shader node_brick_texture(
float Squash = 1.0,
int SquashFrequency = 1,
point Vector = P,
color Color1 = color(0.2, 0.2, 0.2),
color Color2 = color(0.8, 0.8, 0.8),
color Mortar = color(0.0, 0.0, 0.0),
color Color1 = 0.2,
color Color2 = 0.8,
color Mortar = 0.0,
float Scale = 5.0,
float MortarSize = 0.02,
float Bias = 0.0,
float BrickWidth = 0.5,
float RowHeight = 0.25,
output float Fac = 0.0,
output color Color = color(0.2, 0.2, 0.2))
output color Color = 0.2)
{
point p = Vector;

View File

@@ -19,10 +19,10 @@
#include "stdosl.h"
shader node_brightness(
color ColorIn = color(0.8, 0.8, 0.8),
color ColorIn = 0.8,
float Bright = 0.0,
float Contrast = 0.0,
output color ColorOut = color(0.8, 0.8, 0.8))
output color ColorOut = 0.8)
{
float a = 1.0 + Contrast;
float b = Bright - Contrast*0.5;

View File

@@ -44,10 +44,10 @@ shader node_checker_texture(
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 = color(0.8, 0.8, 0.8),
color Color2 = color(0.2, 0.2, 0.2),
color Color1 = 0.8,
color Color2 = 0.2,
output float Fac = 0.0,
output color Color = color(0.0, 0.0, 0.0))
output color Color = 0.0)
{
point p = Vector;

View File

@@ -22,7 +22,7 @@ shader node_combine_rgb(
float R = 0.0,
float G = 0.0,
float B = 0.0,
output color Image = color(0.8, 0.8, 0.8))
output color Image = 0.8)
{
Image = color(R, G, B);
}

View File

@@ -19,7 +19,7 @@
#include "stdosl.h"
shader node_convert_from_color(
color Color = color(0.0, 0.0, 0.0),
color Color = 0.0,
output string String = "",
output float Val = 0.0,
output int ValInt = 0,

View File

@@ -22,7 +22,7 @@ shader node_convert_from_float(
float Val = 0.0,
output string String = "",
output int ValInt = 0,
output color Color = color(0.0, 0.0, 0.0),
output color Color = 0.0,
output vector Vector = vector(0.0, 0.0, 0.0),
output point Point = point(0.0, 0.0, 0.0),
output normal Normal = normal(0.0, 0.0, 0.0))

View File

@@ -22,7 +22,7 @@ shader node_convert_from_int(
int ValInt = 0,
output string String = "",
output float Val = 0.0,
output color Color = color(0.0, 0.0, 0.0),
output color Color = 0.0,
output vector Vector = vector(0.0, 0.0, 0.0),
output point Point = point(0.0, 0.0, 0.0),
output normal Normal = normal(0.0, 0.0, 0.0))

View File

@@ -24,7 +24,7 @@ shader node_convert_from_normal(
output float Val = 0.0,
output int ValInt = 0,
output vector Vector = vector(0.0, 0.0, 0.0),
output color Color = color(0.0, 0.0, 0.0),
output color Color = 0.0,
output point Point = point(0.0, 0.0, 0.0))
{
Val = (Normal[0] + Normal[1] + Normal[2]) * (1.0 / 3.0);

View File

@@ -24,7 +24,7 @@ shader node_convert_from_point(
output float Val = 0.0,
output int ValInt = 0,
output vector Vector = vector(0.0, 0.0, 0.0),
output color Color = color(0.0, 0.0, 0.0),
output color Color = 0.0,
output normal Normal = normal(0.0, 0.0, 0.0))
{
Val = (Point[0] + Point[1] + Point[2]) * (1.0 / 3.0);

View File

@@ -19,10 +19,10 @@
#include "stdosl.h"
shader node_diffuse_bsdf(
color Color = color(0.8, 0.8, 0.8),
color Color = 0.8,
float Roughness = 0.0,
normal Normal = N,
output closure color BSDF = diffuse(Normal))
output closure color BSDF = 0)
{
if (Roughness == 0.0)
BSDF = Color * diffuse(Normal);

View File

@@ -20,9 +20,9 @@
shader node_emission(
int TotalPower = 0,
color Color = color(0.8, 0.8, 0.8),
color Color = 0.8,
float Strength = 1.0,
output closure color Emission = emission())
output closure color Emission = 0)
{
if (TotalPower)
Emission = ((Strength / surfacearea()) * Color) * emission();

View File

@@ -48,7 +48,7 @@ shader node_environment_texture(
string filename = "",
string projection = "Equirectangular",
string color_space = "sRGB",
output color Color = color(0.0, 0.0, 0.0),
output color Color = 0.0,
output float Alpha = 1.0)
{
vector p = Vector;

View File

@@ -19,9 +19,9 @@
#include "stdosl.h"
shader node_gamma(
color ColorIn = color(0.8, 0.8, 0.8),
color ColorIn = 0.8,
float Gamma = 1.0,
output color ColorOut = color(0.0, 0.0, 0.0))
output color ColorOut = 0.0)
{
ColorOut = pow(ColorIn, Gamma);
}

View File

@@ -20,12 +20,12 @@
#include "node_fresnel.h"
shader node_glass_bsdf(
color Color = color(0.8, 0.8, 0.8),
color Color = 0.8,
string distribution = "Sharp",
float Roughness = 0.2,
float IOR = 1.45,
normal Normal = N,
output closure color BSDF = diffuse(Normal))
output closure color BSDF = 0)
{
float f = max(IOR, 1.0 + 1e-5);
float eta = backfacing() ? 1.0 / f: f;

View File

@@ -20,11 +20,11 @@
#include "node_fresnel.h"
shader node_glossy_bsdf(
color Color = color(0.8, 0.8, 0.8),
color Color = 0.8,
string distribution = "Beckmann",
float Roughness = 0.2,
normal Normal = N,
output closure color BSDF = diffuse(Normal))
output closure color BSDF = 0)
{
if (distribution == "Sharp")
BSDF = Color * reflection(Normal);

View File

@@ -68,7 +68,7 @@ shader node_gradient_texture(
string Type = "Linear",
point Vector = P,
output float Fac = 0.0,
output color Color = color(0.0, 0.0, 0.0))
output color Color = 0.0)
{
point p = Vector;

View File

@@ -24,8 +24,8 @@ shader node_hsv(
float Saturation = 1.0,
float Value = 1.0,
float Fac = 0.5,
color ColorIn = color(0.0, 0.0, 0.0),
output color ColorOut = color(0.0, 0.0, 0.0))
color ColorIn = 0.0,
output color ColorOut = 0.0)
{
color Color = rgb_to_hsv(ColorIn);

View File

@@ -37,7 +37,7 @@ shader node_image_texture(
string color_space = "sRGB",
string projection = "Flat",
float projection_blend = 0.0,
output color Color = color(0.0, 0.0, 0.0),
output color Color = 0.0,
output float Alpha = 1.0)
{
point p = Vector;

View File

@@ -20,8 +20,8 @@
shader node_invert(
float Fac = 1.0,
color ColorIn = color(0.8, 0.8, 0.8),
output color ColorOut = color(0.8, 0.8, 0.8))
color ColorIn = 0.8,
output color ColorOut = 0.8)
{
color ColorInv = color(1.0) - ColorIn;
ColorOut = mix(ColorIn, ColorInv, Fac);

View File

@@ -99,7 +99,7 @@ shader node_magic_texture(
float Distortion = 5.0,
float Scale = 5.0,
point Vector = P,
output color Color = color(0.0, 0.0, 0.0))
output color Color = 0.0)
{
point p = Vector;

View File

@@ -282,9 +282,9 @@ shader node_mix(
string type = "Mix",
int Clamp = 0,
float Fac = 0.5,
color Color1 = color(0.0, 0.0, 0.0),
color Color2 = color(0.0, 0.0, 0.0),
output color Color = color(0.0, 0.0, 0.0))
color Color1 = 0.0,
color Color2 = 0.0,
output color Color = 0.0)
{
float t = clamp(Fac, 0.0, 1.0);

View File

@@ -20,9 +20,9 @@
shader node_mix_closure(
float Fac = 0.5,
closure color Closure1 = background(),
closure color Closure2 = background(),
output closure color Closure = background())
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;

View File

@@ -198,7 +198,7 @@ shader node_musgrave_texture(
float Scale = 5.0,
point Vector = P,
output float Fac = 0.0,
output color Color = color(0.0, 0.0, 0.0))
output color Color = 0.0)
{
float dimension = max(Dimension, 1e-5);
float octaves = clamp(Detail, 0.0, 16.0);

View File

@@ -50,7 +50,7 @@ shader node_noise_texture(
float Detail = 2.0,
point Vector = P,
output float Fac = 0.0,
output color Color = color(0.2, 0.2, 0.2))
output color Color = 0.0)
{
point p = Vector;

View File

@@ -18,7 +18,7 @@
#include "stdosl.h"
surface node_output_surface(closure color Surface = background())
surface node_output_surface(closure color Surface = 0)
{
Ci = Surface;
}

View File

@@ -18,7 +18,7 @@
#include "stdosl.h"
volume node_output_volume(closure color Volume = background())
volume node_output_volume(closure color Volume = 0)
{
Ci = Volume;
}

View File

@@ -19,12 +19,12 @@
#include "stdosl.h"
shader node_refraction_bsdf(
color Color = color(0.8, 0.8, 0.8),
color Color = 0.8,
string distribution = "Sharp",
float Roughness = 0.2,
float IOR = 1.45,
normal Normal = N,
output closure color BSDF = diffuse(Normal))
output closure color BSDF = 0)
{
float f = max(IOR, 1.0 + 1e-5);
float eta = backfacing() ? 1.0 / f: f;

View File

@@ -40,9 +40,9 @@ float ramp_lookup(color ramp[RAMP_TABLE_SIZE], float at, int component)
shader node_rgb_curves(
color ramp[RAMP_TABLE_SIZE] = {0.0},
color ColorIn = color(0.0, 0.0, 0.0),
color ColorIn = 0.0,
float Fac = 0.0,
output color ColorOut = color(0.0, 0.0, 0.0))
output color ColorOut = 0.0)
{
ColorOut[0] = ramp_lookup(ramp, ColorIn[0], 0);
ColorOut[1] = ramp_lookup(ramp, ColorIn[1], 1);

View File

@@ -24,7 +24,7 @@ shader node_rgb_ramp(
float ramp_alpha[RAMP_TABLE_SIZE] = {0.0},
float Fac = 0.0,
output color Color = color(0.0, 0.0, 0.0),
output color Color = 0.0,
output float Alpha = 1.0)
{
float f = clamp(Fac, 0.0, 1.0) * (RAMP_TABLE_SIZE - 1);

View File

@@ -19,7 +19,7 @@
#include "stdosl.h"
shader node_separate_rgb(
color Image = color(0.8, 0.8, 0.8),
color Image = 0.8,
output float R = 0.0,
output float G = 0.0,
output float B = 0.0)

View File

@@ -154,7 +154,7 @@ shader node_sky_texture(
vector Vector = P,
vector sun_direction = vector(0, 0, 1),
float turbidity = 2.2,
output color Color = color(0.0, 0.0, 0.0))
output color Color = 0.0)
{
vector p = Vector;

View File

@@ -19,9 +19,9 @@
#include "stdosl.h"
shader node_translucent_bsdf(
color Color = color(0.8, 0.8, 0.8),
color Color = 0.8,
normal Normal = N,
output closure color BSDF = diffuse(Normal))
output closure color BSDF = 0)
{
BSDF = Color * translucent(Normal);
}

View File

@@ -19,9 +19,9 @@
#include "stdosl.h"
shader node_transparent_bsdf(
color Color = color(0.8, 0.8, 0.8),
color Color = 0.8,
normal Normal = N,
output closure color BSDF = diffuse(Normal))
output closure color BSDF = 0)
{
BSDF = Color * transparent();
}

View File

@@ -21,10 +21,10 @@
shader node_value(
float value_value = 0.0,
vector vector_value = vector(0.0, 0.0, 0.0),
color color_value = color(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 = color(0.0, 0.0, 0.0))
output color Color = 0.0)
{
Value = value_value;
Vector = vector_value;

View File

@@ -20,10 +20,10 @@
#include "node_fresnel.h"
shader node_velvet_bsdf(
color Color = color(0.8, 0.8, 0.8),
color Color = 0.8,
float Sigma = 0.0,
normal Normal = N,
output closure color BSDF = diffuse(Normal))
output closure color BSDF = 0)
{
float sigma = clamp(Sigma, 0.0, 1.0);

View File

@@ -28,7 +28,7 @@ shader node_voronoi_texture(
float Scale = 5.0,
point Vector = P,
output float Fac = 0.0,
output color Color = color(0.0, 0.0, 0.0))
output color Color = 0.0)
{
point p = Vector;

View File

@@ -19,13 +19,13 @@
#include "stdosl.h"
shader node_ward_bsdf(
color Color = color(0.8, 0.8, 0.8),
color Color = 0.0,
float Roughness = 0.0,
float Anisotropy = 0.0,
float Rotation = 0.0,
normal Normal = N,
normal Tangent = normalize(dPdu),
output closure color BSDF = diffuse(Normal))
output closure color BSDF = 0)
{
/* rotate tangent around normal */
vector T = Tangent;

View File

@@ -55,7 +55,7 @@ shader node_wave_texture(
float DetailScale = 1.0,
point Vector = P,
output float Fac = 0.0,
output color Color = color (0.0, 0.0, 0.0))
output color Color = 0.0)
{
point p = Vector;