Cycles / OSL:
* Layer Weight is now available in OSL.
This commit is contained in:
parent
0c2a1500f2
commit
17c82a7e57
@ -29,6 +29,7 @@ set(SRC_OSL
|
||||
node_hsv.osl
|
||||
node_image_texture.osl
|
||||
node_invert.osl
|
||||
node_layer_weight.osl
|
||||
node_light_path.osl
|
||||
node_light_falloff.osl
|
||||
node_magic_texture.osl
|
||||
|
@ -19,22 +19,27 @@
|
||||
#include "stdosl.h"
|
||||
#include "node_fresnel.h"
|
||||
|
||||
shader node_blend_weight(
|
||||
float Blend = 0.3,
|
||||
shader node_layer_weight(
|
||||
float Blend = 0.5,
|
||||
normal Normal = N,
|
||||
output float Fresnel = 0.0,
|
||||
output float Facing = 0.0)
|
||||
{
|
||||
float f = max(1.0 - Blend, 1e-5);
|
||||
Fresnel = fresnel_dielectric(I, Normal, backfacing()? f: 1.0 / f);
|
||||
float blend = Blend;
|
||||
|
||||
/* Fresnel */
|
||||
float eta = max(1.0 - Blend, 1e-5);
|
||||
eta = backfacing()? eta: 1.0 / eta;
|
||||
Fresnel = fresnel_dielectric(I, Normal, eta);
|
||||
|
||||
/* Facing */
|
||||
Facing = abs(dot(I, Normal));
|
||||
|
||||
if (Blend != 0.5) {
|
||||
Blend = clamp(Blend, 0.0, 1.0);
|
||||
Blend = (Blend < 0.5)? 2.0 * Blend: 0.5 / (1.0 - Blend);
|
||||
if (blend != 0.5) {
|
||||
blend = clamp(blend, 0.0, 1.0);
|
||||
blend = (blend < 0.5)? 2.0 * blend: 0.5 / (1.0 - blend);
|
||||
|
||||
Facing = powf(Facing, Blend);
|
||||
Facing = pow(Facing, blend);
|
||||
}
|
||||
|
||||
Facing = 1.0 - Facing;
|
@ -2579,7 +2579,7 @@ void LayerWeightNode::compile(SVMCompiler& compiler)
|
||||
|
||||
void LayerWeightNode::compile(OSLCompiler& compiler)
|
||||
{
|
||||
compiler.add(this, "node_blend_weight");
|
||||
compiler.add(this, "node_layer_weight");
|
||||
}
|
||||
|
||||
/* Output */
|
||||
|
Loading…
Reference in New Issue
Block a user