aboutsummaryrefslogtreecommitdiff
path: root/docs/api_docs/files/pageextshaders.html
blob: c8ab36de4fedb52d6f77686e2c022b41571f0a50 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<html>
	<head>
		<title>NVIDIA(R) Blast(R) SDK 1.1 API Reference: Damage Shaders (NvBlastExtShaders)</title>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<LINK HREF="NVIDIA.css" REL="stylesheet" TYPE="text/css">
	</head>

	<body bgcolor="#FFFFFF">
		<div id="header">
			<hr class="first">
			<img alt="" src="blast_logo.png">
			<br>
			<center>
				<a class="qindex" href="main.html">Main Page</a> &nbsp; 
				<!-- <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; //-->
				<a class="qindex" href="annotated.html">Class List</a> &nbsp; 
				<a class="qindex" href="functions.html">Class Members</a> &nbsp;  
			</center>
			<hr class="second">
		</div>
<!-- Generated by Doxygen 1.5.8 -->
<div class="contents">
<h1><a class="anchor" name="pageextshaders">Damage Shaders (NvBlastExtShaders) </a></h1>The Blast&trade; damage shader extension provides basic implementations of programs generating fracture commands, the first step in breaking a Blast&trade; Actor, see <a class="el" href="pagellapi.html#splitting">Damage and Fracturing</a>. These programs come as two shader functions (callbacks): one for Actors with a support graph, and one for Actors with just one chunk, respectively. The <a class="el" href="struct_nv_blast_damage_program.html">NvBlastDamageProgram</a> containing both shaders can be used for low-level directly (NvBlastActorGenerateFracture) or for TkActor's damage and fracture functions.<p>
For example, one may construct a damage program using the "shear" damage shaders declared in <a class="el" href="_nv_blast_ext_damage_shaders_8h.html">NvBlastExtDamageShaders.h</a>:<p>
<div class="fragment"><pre class="fragment">    <a class="code" href="struct_nv_blast_damage_program.html">NvBlastDamageProgram</a> damageProgram = { <a class="code" href="_nv_blast_ext_damage_shaders_8h.html#a49711a370498c4da36bd9dac4d1bbd9">NvBlastExtShearGraphShader</a>, <a class="code" href="_nv_blast_ext_damage_shaders_8h.html#3103465d5c665418138ea5e93a62ac73">NvBlastExtShearSubgraphShader</a> };
</pre></div><p>
The appropriate shader ("graph" or "subgraph") will be called for an Actor being processed, along with the Actor's necessary geometry and program parameters. The parameters (NvBlastProgramParams) are set to contain<p>
1. Material, something that describes an Actor properties (e.g. mass, stiffness, fragility) which are not expected to be changed often.<p>
2. Damage description, something that describes a particular damage event (e.g. position, radius and force of explosion).<p>
For example:<p>
<div class="fragment"><pre class="fragment">    <a class="code" href="struct_nv_blast_ext_material.html">NvBlastExtMaterial</a> material = { health, minDamageThreshold, maxDamageThreshold };
    <a class="code" href="struct_nv_blast_ext_radial_damage_desc.html">NvBlastExtRadialDamageDesc</a> damageDesc = { compressive, posX, posY, posZ, minR, maxR };
</pre></div><p>
When used with TkActor::damage() functions, TkActor will cache the necessary data for deferred processing through TkGroup. This includes accumulating damage requests for the same material and program parameter combination. A default material can be set for a TkFamily that all its Actors uses.<p>
A Tk layer example follows.<p>
<div class="fragment"><pre class="fragment">    tkGroup-&gt;addActor(*tkActor);
    tkActor-&gt;damage(damageProgram, damageDesc0, <span class="keyword">sizeof</span>(<a class="code" href="struct_nv_blast_ext_radial_damage_desc.html">NvBlastExtRadialDamageDesc</a>), &amp;material);
    tkActor-&gt;damage(damageProgram, damageDesc1, <span class="keyword">sizeof</span>(<a class="code" href="struct_nv_blast_ext_radial_damage_desc.html">NvBlastExtRadialDamageDesc</a>), &amp;material);
    tkGroup-&gt;process();
</pre></div><p>
In contrast, the user is responsible for providing all the damage descriptions persisting through the low-level NvBlastActorGenerateFracture call when not using the Tk layer:<p>
<div class="fragment"><pre class="fragment">    NvBlastProgramParams programParams = { damageDescs, 2, &amp;material };
    <a class="code" href="_nv_blast_8h.html#7bf6cbcc95e377f61dbd1ab87bf6facc">NvBlastActorGenerateFracture</a>(commandBuffers, actor, damageProgram, &amp;programParams, <span class="keyword">nullptr</span>, <span class="keyword">nullptr</span>);
</pre></div> </div>
<!-- start footer part -->
<div class="footer">
Copyright &copy; 2015-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. <a href="http://www.nvidia.com ">www.nvidia.com</a>
</div>
</body>
</html>