NvBlastExtDamageShaders.h
Go to the documentation of this file.
1 // This code contains NVIDIA Confidential Information and is disclosed to you
2 // under a form of NVIDIA software license agreement provided separately to you.
3 //
4 // Notice
5 // NVIDIA Corporation and its licensors retain all intellectual property and
6 // proprietary rights in and to this software and related documentation and
7 // any modifications thereto. Any use, reproduction, disclosure, or
8 // distribution of this software and related documentation without an express
9 // license agreement from NVIDIA Corporation is strictly prohibited.
10 //
11 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
12 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
13 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
14 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
15 //
16 // Information and code furnished is believed to be accurate and reliable.
17 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
18 // information or for any infringement of patents or other rights of third parties that may
19 // result from its use. No license is granted by implication or otherwise under any patent
20 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
21 // This code supersedes and replaces all information previously supplied.
22 // NVIDIA Corporation products are not authorized for use as critical
23 // components in life support devices or systems without express written approval of
24 // NVIDIA Corporation.
25 //
26 // Copyright (c) 2016-2020 NVIDIA Corporation. All rights reserved.
27 
28 
29 #ifndef NVBLASTEXTDAMAGESHADERS_H
30 #define NVBLASTEXTDAMAGESHADERS_H
31 
32 #include "NvBlastTypes.h"
33 #include "NvBlastDebugRender.h"
34 
35 
41 // Damage Accelerator
44 
46 {
47 public:
48  virtual void release() = 0;
49 
50  virtual Nv::Blast::DebugBuffer fillDebugRender(int depth = -1, bool segments = false) = 0;
51 };
52 
54 
55 
57 // Damage Program
59 
74 {
75  NvBlastExtProgramParams(const void* desc, const void* material_ = nullptr, NvBlastExtDamageAccelerator* accelerator_ = nullptr)
76  : damageDesc(desc), material(material_), accelerator(accelerator_) {}
77 
78  const void* damageDesc;
79  const void* material;
81 };
82 
83 
85 // Common Material
87 
95 {
96  NvBlastExtMaterial() : health(100.f), minDamageThreshold(0.0f), maxDamageThreshold(1.0f) {}
97 
98  float health;
101 
112  float getNormalizedDamage(float damageInHealth) const
113  {
114  const float damage = health > 0.f ? damageInHealth / health : 1.0f;
115  return damage > minDamageThreshold ? (damage < maxDamageThreshold ? damage : maxDamageThreshold) : 0.f;
116  }
117 };
118 
119 
121 // Point Radial Damage
123 
128 {
129  float damage;
130  float position[3];
131  float minRadius;
132  float maxRadius;
133 };
134 
142 NVBLAST_API void NvBlastExtFalloffGraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastGraphShaderActor* actor, const void* params);
143 NVBLAST_API void NvBlastExtFalloffSubgraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastSubgraphShaderActor* actor, const void* params);
144 NVBLAST_API void NvBlastExtCutterGraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastGraphShaderActor* actor, const void* params);
145 NVBLAST_API void NvBlastExtCutterSubgraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastSubgraphShaderActor* actor, const void* params);
146 
147 
149 // Capsule Radial Damage
151 
156 {
157  float damage;
158  float position0[3];
159  float position1[3];
160  float minRadius;
161  float maxRadius;
162 };
163 
174 NVBLAST_API void NvBlastExtCapsuleFalloffGraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastGraphShaderActor* actor, const void* params);
175 NVBLAST_API void NvBlastExtCapsuleFalloffSubgraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastSubgraphShaderActor* actor, const void* params);
176 
177 
179 // Shear Damage
181 
186 {
187  float damage;
188 
189  float normal[3];
190  float position[3];
191 
192  float minRadius;
193  float maxRadius;
194 };
195 
203 NVBLAST_API void NvBlastExtShearGraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastGraphShaderActor* actor, const void* params);
204 NVBLAST_API void NvBlastExtShearSubgraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastSubgraphShaderActor* actor, const void* params);
205 
206 
208 // Triangle Intersection Damage
210 
215 {
216  float damage;
220 };
221 
236 NVBLAST_API void NvBlastExtTriangleIntersectionGraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastGraphShaderActor* actor, const void* params);
238 
239 
241 // Impact Spread
243 
248 {
249  float damage;
250  float position[3];
251 
252  float minRadius;
253  float maxRadius;
254 };
255 
273 NVBLAST_API void NvBlastExtImpactSpreadGraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastGraphShaderActor* actor, const void* params);
274 NVBLAST_API void NvBlastExtImpactSpreadSubgraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastSubgraphShaderActor* actor, const void* params);
275 
276 
277 #endif // NVBLASTEXTDAMAGESHADERS_H
NVBLAST_API void NvBlastExtFalloffGraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastGraphShaderActor *actor, const void *params)
NvBlastExtProgramParams(const void *desc, const void *material_=nullptr, NvBlastExtDamageAccelerator *accelerator_=nullptr)
Definition: NvBlastExtDamageShaders.h:75
NVBLAST_API void NvBlastExtImpactSpreadGraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastGraphShaderActor *actor, const void *params)
Definition: NvBlastTypes.h:491
NVBLAST_API void NvBlastExtCutterGraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastGraphShaderActor *actor, const void *params)
float minDamageThreshold
min damage fraction threshold to be applied. Range [0, 1]. For example 0.1 filters all damage below 1...
Definition: NvBlastExtDamageShaders.h:99
NVBLAST_API void NvBlastExtCutterSubgraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastSubgraphShaderActor *actor, const void *params)
float damage
normalized damage amount, range: [0, 1] (maximum health value to be reduced)
Definition: NvBlastExtDamageShaders.h:216
NV_INLINE float normal(const float a[3], float r[3])
Definition: NvBlastMath.h:93
Definition: NvBlastExtDamageShaders.h:185
Definition: NvBlastExtDamageShaders.h:155
NVBLAST_API void NvBlastExtImpactSpreadSubgraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastSubgraphShaderActor *actor, const void *params)
Definition: NvBlastDebugRender.h:56
Definition: NvBlastExtDamageShaders.h:73
float maxRadius
outer radius of damage action
Definition: NvBlastExtDamageShaders.h:132
const void * material
pointer to material
Definition: NvBlastExtDamageShaders.h:79
NvcVec3 position1
triangle point B position
Definition: NvBlastExtDamageShaders.h:218
float minRadius
inner radius of damage action
Definition: NvBlastExtDamageShaders.h:131
Definition: NvBlastExtDamageShaders.h:247
float minRadius
inner radius of damage action
Definition: NvBlastExtDamageShaders.h:192
float maxDamageThreshold
max damage fraction threshold to be applied. Range [0, 1]. For example 0.8 won&#39;t allow more then 80% ...
Definition: NvBlastExtDamageShaders.h:100
float getNormalizedDamage(float damageInHealth) const
Definition: NvBlastExtDamageShaders.h:112
Definition: NvBlastExtDamageShaders.h:45
Definition: NvBlastExtDamageShaders.h:127
NVBLAST_API void NvBlastExtCapsuleFalloffGraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastGraphShaderActor *actor, const void *params)
float maxRadius
outer radius of damage action
Definition: NvBlastExtDamageShaders.h:253
Definition: NvBlastExtDamageShaders.h:214
NVBLAST_API void NvBlastExtTriangleIntersectionGraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastGraphShaderActor *actor, const void *params)
NvBlastExtDamageAccelerator * accelerator
Definition: NvBlastExtDamageShaders.h:80
#define NVBLAST_API
Definition: NvBlastPreprocessor.h:37
float damage
normalized damage amount, range: [0, 1] (maximum health value to be reduced)
Definition: NvBlastExtDamageShaders.h:187
float minRadius
inner radius of damage action
Definition: NvBlastExtDamageShaders.h:160
NVBLAST_API NvBlastExtDamageAccelerator * NvBlastExtDamageAcceleratorCreate(const NvBlastAsset *asset, int type)
float damage
normalized damage amount, range: [0, 1] (maximum health value to be reduced)
Definition: NvBlastExtDamageShaders.h:129
NVBLAST_API void NvBlastExtShearSubgraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastSubgraphShaderActor *actor, const void *params)
NvcVec3 position0
triangle point A position
Definition: NvBlastExtDamageShaders.h:217
NVBLAST_API void NvBlastExtShearGraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastGraphShaderActor *actor, const void *params)
float maxRadius
outer radius of damage action
Definition: NvBlastExtDamageShaders.h:193
float damage
normalized damage amount, range: [0, 1] (maximum health value to be reduced)
Definition: NvBlastExtDamageShaders.h:249
const void * damageDesc
array of damage descriptions
Definition: NvBlastExtDamageShaders.h:78
float minRadius
inner radius of damage action
Definition: NvBlastExtDamageShaders.h:252
NvcVec3 position2
triangle point C position
Definition: NvBlastExtDamageShaders.h:219
Definition: NvBlastTypes.h:286
Definition: NvBlastTypes.h:468
float maxRadius
outer radius of damage action
Definition: NvBlastExtDamageShaders.h:161
NVBLAST_API void NvBlastExtCapsuleFalloffSubgraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastSubgraphShaderActor *actor, const void *params)
Definition: NvBlastTypes.h:513
virtual Nv::Blast::DebugBuffer fillDebugRender(int depth=-1, bool segments=false)=0
NvBlastExtMaterial()
Definition: NvBlastExtDamageShaders.h:96
virtual void release()=0
float health
health
Definition: NvBlastExtDamageShaders.h:98
NVBLAST_API void NvBlastExtFalloffSubgraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastSubgraphShaderActor *actor, const void *params)
NVBLAST_API void NvBlastExtTriangleIntersectionSubgraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastSubgraphShaderActor *actor, const void *params)
float damage
normalized damage amount, range: [0, 1] (maximum health value to be reduced)
Definition: NvBlastExtDamageShaders.h:157
Definition: NvCTypes.h:49
Definition: NvBlastExtDamageShaders.h:94