HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GR_PolySurfaceVK.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GR_PolySurfaceVK ( GR Library, C++)
7  *
8  * COMMENTS:
9  * Line and ribbon primitive.
10  */
11 #ifndef GR_PolySurfaceVK_h
12 #define GR_PolySurfaceVK_h
13 
14 #include "GR_API.h"
15 #include "GR_GeoRenderVK.h"
16 #include <GT/GT_PrimPolygonMesh.h>
17 #include <RV/RV_Geometry.h>
18 #include <RE/RE_ShaderHandle.h>
19 #include <UT/UT_Map.h>
20 
21 class RV_Geometry;
22 class RV_Render;
23 class RV_ShaderProgram;
24 class GR_Material;
25 
27 {
28 public:
30  ~GR_PolySurfaceVK() override;
31 
32  const char *className() const override { return "GR_PolySurfaceVK"; }
33 
34  void getPickConnectGroup(unsigned int pick_mode,
35  GR_PickGeometry pick_geo,
36  int &out_connect_start,
37  int &out_connect_num) override;
38 
39  RV_Geometry *getVkPickGeometry(unsigned int pick_mode) override;
40 
42  PrimitiveType prim_type,
43  RV_PrimType render_prim,
44  RV_Geometry &geo,
45  int &out_connect_start,
46  int &out_connect_num) override;
47 
48  void update(RE_RenderContext rc,
49  const GT_PrimitiveHandle &primh,
50  const GR_UpdateParms &parms,
51  const char *cache_name) override;
52 
53  void draw(RE_RenderContext rc,
56  GR_DrawParms dp) override;
57 
58  exint getNumGLPrimitives() const override;
59  bool hasTransparency() const override
60  { return myHasAlpha || myHasBlendedMaterial; }
61 
62  static bool initShaders(RV_Instance* inst);
63  static void cleanupShaders();
64 
65  const GT_PrimitiveHandle &getMesh() const { return myFlattenedMesh; }
66  const GT_PrimitiveHandle &getConvexedMesh() const {return myConvexedMesh;}
67 
68  bool supportsRayTrace() const override { return true; }
69 
71  int tag,
72  int light_id,
73  const UT_Matrix4F &obj_mat) override;
75 
76 private:
77 
78  void updateSurface(RV_Render *r,
79  GT_PrimPolygonMesh *pmesh,
80  const GR_UpdateParms &p,
81  bool needs_tangents,
82  GR_Material *material,
83  const char *cache_name);
84 
85  void convexAndFlattenMesh(GT_PrimPolygonMesh *pmesh,
86  const GR_UpdateParms &parms,
87  bool needs_tangents,
88  GT_PrimPolygonMesh* &out_cmesh,
89  bool &out_flattened);
90 
91  void buildNormals(GT_PrimPolygonMesh *pmesh,
92  const GR_UpdateParms &parms,
93  bool needs_tangents,
94  GT_PrimPolygonMesh* &out_nmesh);
95 
96  void buildSurfaceConnectivity(const GT_PrimPolygonMesh *pmesh,
97  const GR_UpdateParms &parms,
98  UT_Int32Array &connect_indices);
99 
100  void buildVertexNumbers(const GT_PrimPolygonMesh *pmesh,
101  const GR_UpdateParms &parms,
102  GT_Int8Array &vert_num);
103 
104  void buildWireframeConnectivity(
105  const GT_PrimPolygonMesh *pmesh,
106  const GR_UpdateParms &parms,
107  UT_Int32Array &connect_indices,
108  UT_Int32Array &faces,
109  bool target_vert = false);
110 
111  void buildRTSurfaceConnectivity(const GT_PrimPolygonMesh *pmesh,
112  const GR_UpdateParms &parms,
113  UT_Int32Array &connect_indices);
114 
115  void buildUVBoundaryConnectivity(
116  const GT_PrimPolygonMesh *pmesh,
117  const GR_UpdateParms &p,
118  UT_Int32Array &connect,
119  UT_Int32Array &face_list);
120 
121  void buildInstanceTransform(RV_Render *r,
122  GT_PrimitiveHandle primh,
123  const GR_UpdateParms &p,
124  RV_Geometry *geo);
125 
126  RV_ShaderProgram * fetchShader(RV_Render *r,
129  const GR_Material *mat,
130  const GR_DisplayOption *opts,
131  bool &uses_mat);
132 
133  bool updateBoneTransforms(RV_Render *r,
134  const GT_DataArrayHandle &a);
135 
136  void updateBlendShapes(RV_Render *r,
137  const GT_DataArrayHandle &a);
138 
139  bool needsSkinningOrBlendshapes(GR_RenderFlags flags) const;
140  bool applyDisplacementMap(RE_RenderContext rc,
141  const GR_UpdateParms &p,
142  GR_Material *mat);
143  void generateNormalsGPU(RV_Render *r,
144  const GR_DisplayOption &opts);
145 
146 
147  GT_PrimitiveHandle myNormalMesh; // with generated normals
148  GT_PrimitiveHandle myTangentMesh; // with generated tangents
149  GT_PrimitiveHandle myFlattenedMesh; // with only Point/Detail attribs
150 
151  GT_PrimitiveHandle myBaseMesh; // original
152  GT_PrimitiveHandle myConvexedMesh; // convexed
153 
154  GT_DataArrayHandle myGeneratedNormals;
155  GT_Owner myNormalsOwner;
156  GT_DataArrayHandle myGeneratedTangents;
157  GT_Owner myTangentsOwner;
158  GT_DataArrayHandle myGeneratedBitangents;
159  GT_Owner myBitangentsOwner;
160 
161  GT_DataArrayHandle myConvexUniformIndirect;
162  GT_DataArrayHandle myConvexVertexIndirect;
163  GT_DataArrayHandle myConvexVertexList;
164  GT_DataArrayHandle myConvexPrimInfo;
165  GT_DataArrayHandle myConvexVertInfo;
166 
167  UT_StringHolder myUVAttrib;
168  int64 myUVver;
169 
170  int myMaterialID = 0;
171  bool myHasTangents = false;
172  bool myWindingOrder = false;
173  bool myAutoGenNormal = false;
174  bool myIsFlattened = false;
175  bool myHasCd = false;
176  bool myHasAlpha = false;
177  bool myHasBlendedMaterial = false;
178  bool myHasNormalOffsets = false;
179  bool myRanDisplacement = false;
180  int myNumBlendShapes = 0;
181  int myNumBoneTransforms = 0;
182 
183  int64 myTopVersion = -1;
184  int64 myPointVer = -1;
185  UT_UniquePtr<RV_Geometry> myDisplaceGeometry;
186 
187  gr_SetCache myBoneBlendSet;
188  UT_UniquePtr<RV_ShaderBlock> myBoneTransforms;
189  UT_UniquePtr<RV_ShaderBlock> myBlendShapes;
190  bool myIsMatXMaterial = false;
191  UT_UniquePtr<GT_GEOOffsetList> myVertexOffsets;
192 
193  UT_UniquePtr<RV_VKBuffer> myNormalScratchBuffer;
194  UT_UniquePtr<RV_ShaderVariableSet> myNormalGenSet;
195  UT_UniquePtr<RV_ShaderVariableSet> myNormalMergeSet;
196 
197  UT_UniquePtr<RV_ShaderVariableSet> myTessellateInSet;
198  UT_UniquePtr<RV_ShaderVariableSet> myTessellateOutSet;
199 
200  static UT_Map<exint, RV_ShaderProgram *> theProgramMap;
201 };
202 
203 #endif
GLbitfield flags
Definition: glcorearb.h:1596
const char * className() const override
virtual void draw(RE_RenderContext r, GR_RenderMode mode, GR_RenderFlags flags, GR_DrawParms draw_parms)=0
Normal drawing method. Only issue rendering commands.
const GT_PrimitiveHandle & getMesh() const
A mesh of polygons.
virtual void getVkDecorGeometry(GR_DecorationRender::PrimitiveType prim_type, RV_PrimType render_prim, RV_Geometry &geo, int &out_connect_start, int &out_connect_num)
int64 exint
Definition: SYS_Types.h:125
GT_API const UT_StringHolder cache_name
Object that represents drawable geometry. This object holds vertex, instancing and index buffers for ...
Definition: RV_Geometry.h:165
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
Temporary container for either a RV_Render and an RE_Render.
virtual RV_Geometry * getVkPickGeometry(unsigned int pick_mode)
Definition: GR_GeoRender.h:128
virtual exint getNumGLPrimitives() const =0
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
set of parameters sent to GR_Primitive::update()
GR_RenderMode
Definition: GR_Defines.h:48
RV_API void cleanupShaders()
#define GR_API
Definition: GR_API.h:10
long long int64
Definition: SYS_Types.h:116
virtual void updateAccelerationStructure(RV_Render *r, int tag, int light_id, const UT_Matrix4F &obj_mat)
GR_RenderFlags
Definition: GR_Defines.h:88
Handle to the main interface of Vulkan.
Definition: RV_Instance.h:44
bool supportsRayTrace() const override
const GT_PrimitiveHandle & getConvexedMesh() const
GLenum mode
Definition: glcorearb.h:99
GT_Owner
Definition: GT_Types.h:90
RV_API bool initShaders(RV_Instance *inst)
virtual void getPickConnectGroup(unsigned int pick_mode, GR_PickGeometry pick_geo, int &out_connect_start, int &out_connect_num)
Definition: GR_GeoRender.h:100
GR_PickGeometry
Definition: GR_PickRecord.h:60
RV_PrimType
Definition: RV_Type.h:424
GA_API const UT_StringHolder parms
bool hasTransparency() const override
returns true if this drawable renders some transparent elements
An array of numeric values (int32, int64, fpreal16, fpreal32, fpreal64)
Definition: GT_DANumeric.h:23
virtual void update(RE_RenderContext r, const GT_PrimitiveHandle &primh, const GR_UpdateParms &p, const char *cache_name)=0
GLboolean r
Definition: glcorearb.h:1222
virtual RV_VKAccelerationStructure * getAccelerationStructure()