Blender  V3.3
dice.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #ifndef __SUBD_DICE_H__
5 #define __SUBD_DICE_H__
6 
7 /* DX11 like EdgeDice implementation, with different tessellation factors for
8  * each edge for watertight tessellation, with subpatch remapping to work with
9  * DiagSplit. For more algorithm details, see the DiagSplit paper or the
10  * ARB_tessellation_shader OpenGL extension, Section 2.X.2. */
11 
12 #include "util/types.h"
13 #include "util/vector.h"
14 
15 #include "subd/subpatch.h"
16 
18 
19 class Camera;
20 class Mesh;
21 class Patch;
22 
23 struct SubdParams {
25  bool ptex;
26 
29  float dicing_rate;
30  int max_level;
33 
34  SubdParams(Mesh *mesh_, bool ptex_ = false)
35  {
36  mesh = mesh_;
37  ptex = ptex_;
38 
39  test_steps = 3;
40  split_threshold = 1;
41  dicing_rate = 1.0f;
42  max_level = 12;
43  camera = NULL;
44  }
45 };
46 
47 /* EdgeDice Base */
48 
49 class EdgeDice {
50  public:
54  size_t vert_offset;
55  size_t tri_offset;
56 
57  explicit EdgeDice(const SubdParams &params);
58 
59  void reserve(int num_verts, int num_triangles);
60 
61  void set_vert(Patch *patch, int index, float2 uv);
62  void add_triangle(Patch *patch, int v0, int v1, int v2);
63 
64  void stitch_triangles(Subpatch &sub, int edge);
65 };
66 
67 /* Quad EdgeDice */
68 
69 class QuadDice : public EdgeDice {
70  public:
71  explicit QuadDice(const SubdParams &params);
72 
73  float3 eval_projected(Subpatch &sub, float u, float v);
74 
75  float2 map_uv(Subpatch &sub, float u, float v);
76  void set_vert(Subpatch &sub, int index, float u, float v);
77 
78  void add_grid(Subpatch &sub, int Mu, int Mv, int offset);
79 
80  void set_side(Subpatch &sub, int edge);
81 
82  float quad_area(const float3 &a, const float3 &b, const float3 &c, const float3 &d);
83  float scale_factor(Subpatch &sub, int Mu, int Mv);
84 
85  void dice(Subpatch &sub);
86 };
87 
89 
90 #endif /* __SUBD_DICE_H__ */
_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 v1
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
Definition: dice.h:49
void reserve(int num_verts, int num_triangles)
Definition: dice.cpp:28
void add_triangle(Patch *patch, int v0, int v1, int v2)
Definition: dice.cpp:59
float3 * mesh_N
Definition: dice.h:53
size_t vert_offset
Definition: dice.h:54
void stitch_triangles(Subpatch &sub, int edge)
Definition: dice.cpp:69
size_t tri_offset
Definition: dice.h:55
float3 * mesh_P
Definition: dice.h:52
SubdParams params
Definition: dice.h:51
void set_vert(Patch *patch, int index, float2 uv)
Definition: dice.cpp:46
EdgeDice(const SubdParams &params)
Definition: dice.cpp:14
Definition: dice.h:69
QuadDice(const SubdParams &params)
Definition: dice.cpp:118
float scale_factor(Subpatch &sub, int Mu, int Mv)
Definition: dice.cpp:185
float2 map_uv(Subpatch &sub, float u, float v)
Definition: dice.cpp:122
void add_grid(Subpatch &sub, int Mu, int Mv, int offset)
Definition: dice.cpp:214
float3 eval_projected(Subpatch &sub, float u, float v)
Definition: dice.cpp:130
void set_vert(Subpatch &sub, int index, float u, float v)
Definition: dice.cpp:142
void dice(Subpatch &sub)
Definition: dice.cpp:240
float quad_area(const float3 &a, const float3 &b, const float3 &c, const float3 &d)
Definition: dice.cpp:180
void set_side(Subpatch &sub, int edge)
Definition: dice.cpp:147
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
static unsigned c
Definition: RandGen.cpp:83
static unsigned a[3]
Definition: RandGen.cpp:78
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
bool ptex
Definition: dice.h:25
int max_level
Definition: dice.h:30
SubdParams(Mesh *mesh_, bool ptex_=false)
Definition: dice.h:34
Mesh * mesh
Definition: dice.h:24
Camera * camera
Definition: dice.h:31
Transform objecttoworld
Definition: dice.h:32
int split_threshold
Definition: dice.h:28
float dicing_rate
Definition: dice.h:29
int test_steps
Definition: dice.h:27