Blender  V3.3
point_intersect.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #pragma once
5 
7 
8 /* Point primitive intersection functions. */
9 
10 #ifdef __POINTCLOUD__
11 
12 ccl_device_forceinline bool point_intersect_test(const float4 point,
13  const float3 ray_P,
14  const float3 ray_D,
15  const float ray_tmin,
16  const float ray_tmax,
17  ccl_private float *t)
18 {
20  const float radius = point.w;
21 
22  const float rd2 = 1.0f / dot(ray_D, ray_D);
23 
24  const float3 c0 = center - ray_P;
25  const float projC0 = dot(c0, ray_D) * rd2;
26  const float3 perp = c0 - projC0 * ray_D;
27  const float l2 = dot(perp, perp);
28  const float r2 = radius * radius;
29  if (!(l2 <= r2)) {
30  return false;
31  }
32 
33  const float td = sqrt((r2 - l2) * rd2);
34  const float t_front = projC0 - td;
35  const bool valid_front = (ray_tmin <= t_front) & (t_front <= ray_tmax);
36 
37  /* Always back-face culling for now. */
38 # if 0
39  const float t_back = projC0 + td;
40  const bool valid_back = (ray_tmin <= t_back) & (t_back <= ray_tmax);
41 
42  /* check if there is a first hit */
43  const bool valid_first = valid_front | valid_back;
44  if (!valid_first) {
45  return false;
46  }
47 
48  *t = (valid_front) ? t_front : t_back;
49  return true;
50 # else
51  if (!valid_front) {
52  return false;
53  }
54  *t = t_front;
55  return true;
56 # endif
57 }
58 
59 ccl_device_forceinline bool point_intersect(KernelGlobals kg,
61  const float3 ray_P,
62  const float3 ray_D,
63  const float ray_tmin,
64  const float ray_tmax,
65  const int object,
66  const int prim,
67  const float time,
68  const int type)
69 {
70  const float4 point = (type & PRIMITIVE_MOTION) ? motion_point(kg, object, prim, time) :
71  kernel_data_fetch(points, prim);
72 
73  if (!point_intersect_test(point, ray_P, ray_D, ray_tmin, ray_tmax, &isect->t)) {
74  return false;
75  }
76 
77  isect->prim = prim;
78  isect->object = object;
79  isect->type = type;
80  isect->u = 0.0f;
81  isect->v = 0.0f;
82  return true;
83 }
84 
85 ccl_device_inline void point_shader_setup(KernelGlobals kg,
87  ccl_private const Intersection *isect,
88  ccl_private const Ray *ray)
89 {
90  sd->shader = kernel_data_fetch(points_shader, isect->prim);
91  sd->P = ray->P + ray->D * isect->t;
92 
93  /* Texture coordinates, zero for now. */
94 # ifdef __UV__
95  sd->u = isect->u;
96  sd->v = isect->v;
97 # endif
98 
99  /* Compute point center for normal. */
100  float3 center = float4_to_float3((isect->type & PRIMITIVE_MOTION) ?
101  motion_point(kg, sd->object, sd->prim, sd->time) :
102  kernel_data_fetch(points, sd->prim));
103  if (!(sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
105  }
106 
107  /* Normal */
108  sd->Ng = normalize(sd->P - center);
109  sd->N = sd->Ng;
110 
111 # ifdef __DPDU__
112  /* dPdu/dPdv */
113  sd->dPdu = make_float3(0.0f, 0.0f, 0.0f);
114  sd->dPdv = make_float3(0.0f, 0.0f, 0.0f);
115 # endif
116 }
117 
118 #endif
119 
sqrt(x)+1/max(0
NSNotificationCenter * center
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
float float4[4]
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 point
#define ccl_device_forceinline
Definition: cuda/compat.h:35
#define ccl_private
Definition: cuda/compat.h:48
#define ccl_device_inline
Definition: cuda/compat.h:34
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
double time
const KernelGlobalsCPU *ccl_restrict KernelGlobals
#define kernel_data_fetch(name, index)
#define object_position_transform_auto
@ PRIMITIVE_MOTION
Definition: kernel/types.h:558
ShaderData
Definition: kernel/types.h:925
@ SD_OBJECT_TRANSFORM_APPLIED
Definition: kernel/types.h:808
#define make_float3(x, y, z)
Definition: metal/compat.h:204
T dot(const vec_base< T, Size > &a, const vec_base< T, Size > &b)
vec_base< T, Size > normalize(const vec_base< T, Size > &v)
ccl_device_inline float3 float4_to_float3(const float4 a)
Definition: util/math.h:500