Blender  V3.3
node_fresnel.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Adapted from Open Shading Language
4  * Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
5  * All Rights Reserved.
6  *
7  * Modifications Copyright 2011-2022 Blender Foundation. */
8 
9 float fresnel_dielectric_cos(float cosi, float eta)
10 {
11  /* compute fresnel reflectance without explicitly computing
12  * the refracted direction */
13  float c = fabs(cosi);
14  float g = eta * eta - 1 + c * c;
15  float result;
16 
17  if (g > 0) {
18  g = sqrt(g);
19  float A = (g - c) / (g + c);
20  float B = (c * (g + c) - 1) / (c * (g - c) + 1);
21  result = 0.5 * A * A * (1 + B * B);
22  }
23  else
24  result = 1.0; /* TIR (no refracted component) */
25 
26  return result;
27 }
28 
29 color fresnel_conductor(float cosi, color eta, color k)
30 {
31  color cosi2 = color(cosi * cosi);
32  color one = color(1, 1, 1);
33  color tmp_f = eta * eta + k * k;
34  color tmp = tmp_f * cosi2;
35  color Rparl2 = (tmp - (2.0 * eta * cosi) + one) / (tmp + (2.0 * eta * cosi) + one);
36  color Rperp2 = (tmp_f - (2.0 * eta * cosi) + cosi2) / (tmp_f + (2.0 * eta * cosi) + cosi2);
37  return (Rparl2 + Rperp2) * 0.5;
38 }
sqrt(x)+1/max(0
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
#define A
ccl_device_inline float2 fabs(const float2 &a)
Definition: math_float2.h:222
#define B
static unsigned c
Definition: RandGen.cpp:83
static const pxr::TfToken g("g", pxr::TfToken::Immortal)
color fresnel_conductor(float cosi, color eta, color k)
Definition: node_fresnel.h:29
float fresnel_dielectric_cos(float cosi, float eta)
Definition: node_fresnel.h:9