Main Page Class List Class Members

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
45 class NvBlastExtDamageAccelerator
46 {
47 public:
48 virtual void release() = 0;
49
50 virtual Nv::Blast::DebugBuffer fillDebugRender(int depth = -1, bool segments = false) = 0;
51 };
52
53 NVBLAST_API NvBlastExtDamageAccelerator* NvBlastExtDamageAcceleratorCreate(const NvBlastAsset* asset, int type);
54
55
57 // Damage Program
59
73 struct NvBlastExtProgramParams
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;
80 NvBlastExtDamageAccelerator* accelerator;
81 };
82
83
85 // Common Material
87
94 struct NvBlastExtMaterial
95 {
96 NvBlastExtMaterial() : health(100.f), minDamageThreshold(0.0f), maxDamageThreshold(1.0f) {}
97
98 float health;
99 float minDamageThreshold;
100 float maxDamageThreshold;
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
127 struct NvBlastExtRadialDamageDesc
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
155 struct NvBlastExtCapsuleRadialDamageDesc
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
185 struct NvBlastExtShearDamageDesc
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
214 struct NvBlastExtTriangleIntersectionDamageDesc
215 {
216 float damage;
217 NvcVec3 position0;
218 NvcVec3 position1;
219 NvcVec3 position2;
220 };
221
236 NVBLAST_API void NvBlastExtTriangleIntersectionGraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastGraphShaderActor* actor, const void* params);
237 NVBLAST_API void NvBlastExtTriangleIntersectionSubgraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastSubgraphShaderActor* actor, const void* params);
238
239
241 // Impact Spread
243
247 struct NvBlastExtImpactSpreadDamageDesc
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
NvBlastExtImpactSpreadSubgraphShader
void NvBlastExtImpactSpreadSubgraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastSubgraphShaderActor *actor, const void *params)
NvBlastExtProgramParams::NvBlastExtProgramParams
NvBlastExtProgramParams(const void *desc, const void *material_=nullptr, NvBlastExtDamageAccelerator *accelerator_=nullptr)
Definition: NvBlastExtDamageShaders.h:75
NvBlastExtCapsuleFalloffSubgraphShader
void NvBlastExtCapsuleFalloffSubgraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastSubgraphShaderActor *actor, const void *params)
NvBlastGraphShaderActor
Definition: NvBlastTypes.h:491
NvBlastExtMaterial::minDamageThreshold
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
NvBlastExtTriangleIntersectionDamageDesc::damage
float damage
normalized damage amount, range: [0, 1] (maximum health value to be reduced)
Definition: NvBlastExtDamageShaders.h:216
NvBlastExtShearDamageDesc
Definition: NvBlastExtDamageShaders.h:185
NvBlastExtCapsuleRadialDamageDesc
Definition: NvBlastExtDamageShaders.h:155
NvBlastExtShearGraphShader
void NvBlastExtShearGraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastGraphShaderActor *actor, const void *params)
NvBlastTypes.h
NvBlastExtFalloffSubgraphShader
void NvBlastExtFalloffSubgraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastSubgraphShaderActor *actor, const void *params)
Nv::Blast::DebugBuffer
Definition: NvBlastDebugRender.h:56
NvBlastExtProgramParams
Definition: NvBlastExtDamageShaders.h:73
NvBlastExtRadialDamageDesc::maxRadius
float maxRadius
outer radius of damage action
Definition: NvBlastExtDamageShaders.h:132
NvBlastExtProgramParams::material
const void * material
pointer to material
Definition: NvBlastExtDamageShaders.h:79
NvBlastExtCapsuleFalloffGraphShader
void NvBlastExtCapsuleFalloffGraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastGraphShaderActor *actor, const void *params)
NvBlastExtDamageAcceleratorCreate
NvBlastExtDamageAccelerator * NvBlastExtDamageAcceleratorCreate(const NvBlastAsset *asset, int type)
NvBlastExtTriangleIntersectionDamageDesc::position1
NvcVec3 position1
triangle point B position
Definition: NvBlastExtDamageShaders.h:218
NvBlastExtFalloffGraphShader
void NvBlastExtFalloffGraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastGraphShaderActor *actor, const void *params)
NvBlastExtRadialDamageDesc::minRadius
float minRadius
inner radius of damage action
Definition: NvBlastExtDamageShaders.h:131
NvBlastExtImpactSpreadDamageDesc
Definition: NvBlastExtDamageShaders.h:247
NvBlastDebugRender.h
NvBlastExtShearDamageDesc::minRadius
float minRadius
inner radius of damage action
Definition: NvBlastExtDamageShaders.h:192
NvBlastExtTriangleIntersectionSubgraphShader
void NvBlastExtTriangleIntersectionSubgraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastSubgraphShaderActor *actor, const void *params)
NvBlastExtMaterial::maxDamageThreshold
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
NvBlastExtMaterial::getNormalizedDamage
float getNormalizedDamage(float damageInHealth) const
Definition: NvBlastExtDamageShaders.h:112
NvBlastExtDamageAccelerator
Definition: NvBlastExtDamageShaders.h:45
NvBlastExtRadialDamageDesc
Definition: NvBlastExtDamageShaders.h:127
NvBlastExtShearSubgraphShader
void NvBlastExtShearSubgraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastSubgraphShaderActor *actor, const void *params)
NvBlastExtImpactSpreadDamageDesc::maxRadius
float maxRadius
outer radius of damage action
Definition: NvBlastExtDamageShaders.h:253
NvBlastExtTriangleIntersectionDamageDesc
Definition: NvBlastExtDamageShaders.h:214
NvBlastExtProgramParams::accelerator
NvBlastExtDamageAccelerator * accelerator
Definition: NvBlastExtDamageShaders.h:80
NVBLAST_API
#define NVBLAST_API
Definition: NvBlastPreprocessor.h:37
NvBlastExtImpactSpreadGraphShader
void NvBlastExtImpactSpreadGraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastGraphShaderActor *actor, const void *params)
NvBlastExtShearDamageDesc::damage
float damage
normalized damage amount, range: [0, 1] (maximum health value to be reduced)
Definition: NvBlastExtDamageShaders.h:187
NvBlastExtCapsuleRadialDamageDesc::minRadius
float minRadius
inner radius of damage action
Definition: NvBlastExtDamageShaders.h:160
NvBlastExtRadialDamageDesc::damage
float damage
normalized damage amount, range: [0, 1] (maximum health value to be reduced)
Definition: NvBlastExtDamageShaders.h:129
NvBlastExtTriangleIntersectionDamageDesc::position0
NvcVec3 position0
triangle point A position
Definition: NvBlastExtDamageShaders.h:217
NvBlastExtShearDamageDesc::maxRadius
float maxRadius
outer radius of damage action
Definition: NvBlastExtDamageShaders.h:193
NvBlastExtImpactSpreadDamageDesc::damage
float damage
normalized damage amount, range: [0, 1] (maximum health value to be reduced)
Definition: NvBlastExtDamageShaders.h:249
NvBlastExtProgramParams::damageDesc
const void * damageDesc
array of damage descriptions
Definition: NvBlastExtDamageShaders.h:78
NvBlastExtImpactSpreadDamageDesc::minRadius
float minRadius
inner radius of damage action
Definition: NvBlastExtDamageShaders.h:252
NvBlastExtTriangleIntersectionDamageDesc::position2
NvcVec3 position2
triangle point C position
Definition: NvBlastExtDamageShaders.h:219
NvBlastExtCutterGraphShader
void NvBlastExtCutterGraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastGraphShaderActor *actor, const void *params)
NvBlastAsset
Definition: NvBlastTypes.h:286
NvBlastFractureBuffers
Definition: NvBlastTypes.h:468
NvBlastExtCapsuleRadialDamageDesc::maxRadius
float maxRadius
outer radius of damage action
Definition: NvBlastExtDamageShaders.h:161
NvBlastSubgraphShaderActor
Definition: NvBlastTypes.h:513
NvBlastExtDamageAccelerator::fillDebugRender
virtual Nv::Blast::DebugBuffer fillDebugRender(int depth=-1, bool segments=false)=0
NvBlastExtMaterial::NvBlastExtMaterial
NvBlastExtMaterial()
Definition: NvBlastExtDamageShaders.h:96
NvBlastExtDamageAccelerator::release
virtual void release()=0
NvBlastExtMaterial::health
float health
health
Definition: NvBlastExtDamageShaders.h:98
NvBlastExtTriangleIntersectionGraphShader
void NvBlastExtTriangleIntersectionGraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastGraphShaderActor *actor, const void *params)
NvBlastExtCapsuleRadialDamageDesc::damage
float damage
normalized damage amount, range: [0, 1] (maximum health value to be reduced)
Definition: NvBlastExtDamageShaders.h:157
NvcVec3
Definition: NvCTypes.h:49
NvBlastExtCutterSubgraphShader
void NvBlastExtCutterSubgraphShader(NvBlastFractureBuffers *commandBuffers, const NvBlastSubgraphShaderActor *actor, const void *params)
NvBlastExtMaterial
Definition: NvBlastExtDamageShaders.h:94