47 *
R = (2 *
cos) * Nn -
I;
48 #ifdef __RAY_DIFFERENTIALS__
49 *dRdx = (2 *
dot(Nn, dIdx)) * Nn - dIdx;
50 *dRdy = (2 *
dot(Nn, dIdy)) * Nn - dIdy;
53 float arg = 1 - (neta * neta * (1 - (
cos *
cos)));
56 #ifdef __RAY_DIFFERENTIALS__
64 float nK = (neta *
cos) - dnp;
65 *
T = -(neta *
I) + (nK * Nn);
66 #ifdef __RAY_DIFFERENTIALS__
67 *dTdx = -(neta * dIdx) + ((neta - neta * neta *
cos / dnp) *
dot(dIdx, Nn)) * Nn;
68 *dTdy = -(neta * dIdy) + ((neta - neta * neta *
cos / dnp) *
dot(dIdy, Nn)) * Nn;
71 float cosTheta1 =
cos;
72 float cosTheta2 = -
dot(Nn, *
T);
73 float pPara = (cosTheta1 - eta * cosTheta2) / (cosTheta1 + eta * cosTheta2);
74 float pPerp = (eta * cosTheta1 - cosTheta2) / (eta * cosTheta1 + cosTheta2);
75 return 0.5f * (pPara * pPara + pPerp * pPerp);
84 float g = eta * eta - 1 +
c *
c;
87 float A = (
g -
c) / (
g +
c);
88 float B = (
c * (
g +
c) - 1) / (
c * (
g -
c) + 1);
89 return 0.5f *
A *
A * (1 +
B *
B);
98 float3 tmp_f = eta * eta + k * k;
99 float3 tmp = tmp_f * cosi2;
100 float3 Rparl2 = (tmp - (2.0f * eta * cosi) + one) / (tmp + (2.0f * eta * cosi) + one);
101 float3 Rperp2 = (tmp_f - (2.0f * eta * cosi) + cosi2) / (tmp_f + (2.0f * eta * cosi) + cosi2);
102 return (Rparl2 + Rperp2) * 0.5f;
107 float m =
clamp(1.0f - u, 0.0f, 1.0f);
120 float F0_norm = 1.0f / (1.0f - F0);
141 float NdotNg =
dot(
N, Ng);
184 float Ix2 =
sqr(Ix), Iz2 =
sqr(Iz);
194 float fac = 0.5f /
a;
195 float N1_z2 = fac * (
b +
c), N2_z2 = fac * (-
b +
c);
196 bool valid1 = (N1_z2 > 1e-5f) && (N1_z2 <= (1.0f + 1e-5f));
197 bool valid2 = (N2_z2 > 1e-5f) && (N2_z2 <= (1.0f + 1e-5f));
200 if (valid1 && valid2) {
205 float R1 = 2 * (N1.
x * Ix + N1.
y * Iz) * N1.
y - Iz;
206 float R2 = 2 * (N2.
x * Ix + N2.
y * Iz) * N2.
y - Iz;
208 valid1 = (R1 >= 1e-5f);
209 valid2 = (R2 >= 1e-5f);
210 if (valid1 && valid2) {
214 N_new = (R1 < R2) ? N1 : N2;
218 N_new = (R1 > R2) ? N1 : N2;
221 else if (valid1 || valid2) {
223 float Nz2 = valid1 ? N1_z2 : N2_z2;
230 return N_new.
x *
X + N_new.
y * Ng;
MINLINE float safe_sqrtf(float a)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its and value channels Color Retrieve a color or the default fallback if none is specified Separate Split a vector into its X
ccl_device float3 ensure_valid_reflection(float3 Ng, float3 I, float3 N)
ccl_device float fresnel_dielectric_cos(float cosi, float eta)
CCL_NAMESPACE_BEGIN ccl_device float fresnel_dielectric(float eta, const float3 N, const float3 I, ccl_private float3 *R, ccl_private float3 *T, ccl_private bool *is_inside)
ccl_device_forceinline float3 interpolate_fresnel_color(float3 L, float3 H, float ior, float F0, float3 cspec0)
ccl_device float schlick_fresnel(float u)
ccl_device float3 fresnel_conductor(float cosi, const float3 eta, const float3 k)
#define ccl_device_forceinline
#define CCL_NAMESPACE_END
static bool is_inside(int x, int y, int cols, int rows)
ccl_gpu_kernel_postfix ccl_global float int int int int float threshold
#define __RAY_DIFFERENTIALS__
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
T dot(const vec_base< T, Size > &a, const vec_base< T, Size > &b)
T clamp(const T &a, const T &min, const T &max)
vec_base< T, Size > normalize(const vec_base< T, Size > &v)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static const pxr::TfToken ior("ior", pxr::TfToken::Immortal)
static const pxr::TfToken g("g", pxr::TfToken::Immortal)
ccl_device_inline float sqr(float a)