sdk/extensions/shaders/include/NvBlastExtDamageShaders.h

Go to the documentation of this file.
00001 // This code contains NVIDIA Confidential Information and is disclosed to you
00002 // under a form of NVIDIA software license agreement provided separately to you.
00003 //
00004 // Notice
00005 // NVIDIA Corporation and its licensors retain all intellectual property and
00006 // proprietary rights in and to this software and related documentation and
00007 // any modifications thereto. Any use, reproduction, disclosure, or
00008 // distribution of this software and related documentation without an express
00009 // license agreement from NVIDIA Corporation is strictly prohibited.
00010 //
00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
00015 //
00016 // Information and code furnished is believed to be accurate and reliable.
00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
00018 // information or for any infringement of patents or other rights of third parties that may
00019 // result from its use. No license is granted by implication or otherwise under any patent
00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
00021 // This code supersedes and replaces all information previously supplied.
00022 // NVIDIA Corporation products are not authorized for use as critical
00023 // components in life support devices or systems without express written approval of
00024 // NVIDIA Corporation.
00025 //
00026 // Copyright (c) 2016-2020 NVIDIA Corporation. All rights reserved.
00027 
00028 
00029 #ifndef NVBLASTEXTDAMAGESHADERS_H
00030 #define NVBLASTEXTDAMAGESHADERS_H
00031 
00032 #include "NvBlastTypes.h"
00033 #include "NvBlastDebugRender.h"
00034 
00035 
00041 
00042 //  Damage Accelerator 
00044 
00045 class NvBlastExtDamageAccelerator
00046 {
00047 public:
00048     virtual void release() = 0;
00049 
00050     virtual Nv::Blast::DebugBuffer fillDebugRender(int depth = -1, bool segments = false) = 0;
00051 };
00052 
00053 NVBLAST_API NvBlastExtDamageAccelerator* NvBlastExtDamageAcceleratorCreate(const NvBlastAsset* asset, int type);
00054 
00055 
00057 //  Damage Program
00059 
00073 struct NvBlastExtProgramParams
00074 {
00075     NvBlastExtProgramParams(const void* desc, const void* material_ = nullptr, NvBlastExtDamageAccelerator* accelerator_ = nullptr)
00076         : damageDesc(desc), material(material_), accelerator(accelerator_) {}
00077 
00078     const void* damageDesc;         
00079     const void* material;           
00080     NvBlastExtDamageAccelerator*    accelerator;
00081 };
00082 
00083 
00085 //  Common Material 
00087 
00094 struct NvBlastExtMaterial
00095 {
00096     NvBlastExtMaterial() : health(100.f), minDamageThreshold(0.0f), maxDamageThreshold(1.0f) {}
00097 
00098     float   health;                 
00099     float   minDamageThreshold;     
00100     float   maxDamageThreshold;     
00101 
00112     float getNormalizedDamage(float damageInHealth) const
00113     {
00114         const float damage = health > 0.f ? damageInHealth / health : 1.0f;
00115         return damage > minDamageThreshold ? (damage < maxDamageThreshold ? damage : maxDamageThreshold) : 0.f;
00116     }
00117 };
00118 
00119 
00121 //  Point Radial Damage
00123 
00127 struct NvBlastExtRadialDamageDesc
00128 {
00129     float   damage;         
00130     float   position[3];    
00131     float   minRadius;      
00132     float   maxRadius;      
00133 };
00134 
00142 NVBLAST_API void NvBlastExtFalloffGraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastGraphShaderActor* actor, const void* params);
00143 NVBLAST_API void NvBlastExtFalloffSubgraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastSubgraphShaderActor* actor, const void* params);
00144 NVBLAST_API void NvBlastExtCutterGraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastGraphShaderActor* actor, const void* params);
00145 NVBLAST_API void NvBlastExtCutterSubgraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastSubgraphShaderActor* actor, const void* params);
00146 
00147 
00149 //  Capsule Radial Damage
00151 
00155 struct NvBlastExtCapsuleRadialDamageDesc
00156 {
00157     float   damage;         
00158     float   position0[3];   
00159     float   position1[3];   
00160     float   minRadius;      
00161     float   maxRadius;      
00162 };
00163 
00174 NVBLAST_API void NvBlastExtCapsuleFalloffGraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastGraphShaderActor* actor, const void* params);
00175 NVBLAST_API void NvBlastExtCapsuleFalloffSubgraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastSubgraphShaderActor* actor, const void* params);
00176 
00177 
00179 //  Shear Damage
00181 
00185 struct NvBlastExtShearDamageDesc
00186 {
00187     float   damage;         
00188 
00189     float   normal[3];      
00190     float   position[3];    
00191 
00192     float   minRadius;      
00193     float   maxRadius;      
00194 };
00195 
00203 NVBLAST_API void NvBlastExtShearGraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastGraphShaderActor* actor, const void* params);
00204 NVBLAST_API void NvBlastExtShearSubgraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastSubgraphShaderActor* actor, const void* params);
00205 
00206 
00208 //  Triangle Intersection Damage
00210 
00214 struct NvBlastExtTriangleIntersectionDamageDesc
00215 {
00216     float   damage;         
00217     NvcVec3 position0;      
00218     NvcVec3 position1;      
00219     NvcVec3 position2;      
00220 };
00221 
00236 NVBLAST_API void NvBlastExtTriangleIntersectionGraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastGraphShaderActor* actor, const void* params);
00237 NVBLAST_API void NvBlastExtTriangleIntersectionSubgraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastSubgraphShaderActor* actor, const void* params);
00238 
00239 
00241 //  Impact Spread
00243 
00247 struct NvBlastExtImpactSpreadDamageDesc
00248 {
00249     float   damage;         
00250     float   position[3];    
00251 
00252     float   minRadius;      
00253     float   maxRadius;      
00254 };
00255 
00273 NVBLAST_API void NvBlastExtImpactSpreadGraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastGraphShaderActor* actor, const void* params);
00274 NVBLAST_API void NvBlastExtImpactSpreadSubgraphShader(NvBlastFractureBuffers* commandBuffers, const NvBlastSubgraphShaderActor* actor, const void* params);
00275 
00276 
00277 #endif // NVBLASTEXTDAMAGESHADERS_H