blender/intern/cycles/kernel/shaders/node_ward_bsdf.osl
Brecht Van Lommel 2ba840652d Cycles: improve Anisotropic BSDF node, changing the Roughness U/V inputs to
Roughness, Anisotropy and Rotation. Also a fix for automatic tangents and
OSL attribute handling.

Meaning of new sockets explained in the documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/Shaders#Anisotropic
2012-11-04 22:31:32 +00:00

52 lines
1.5 KiB
Plaintext

/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "stdosl.h"
shader node_ward_bsdf(
color Color = color(0.8, 0.8, 0.8),
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))
{
/* rotate tangent around normal */
vector T = Tangent;
if(Rotation != 0.0)
T = rotate(T, Rotation*2.0*M_PI, point(0.0, 0.0, 0.0), Normal);
/* compute roughness */
float RoughnessU, RoughnessV;
float aniso = clamp(Anisotropy, -0.99, 0.99);
if(aniso < 0.0) {
RoughnessU = Roughness*(1.0 + aniso);
RoughnessV = Roughness/(1.0 + aniso);
}
else {
RoughnessU = Roughness/(1.0 - aniso);
RoughnessV = Roughness*(1.0 - aniso);
}
BSDF = Color * ward(Normal, T, RoughnessU, RoughnessV);
}