Line | |
---|
1 | /*
|
---|
2 | * ======================================================================
|
---|
3 | * AUTHOR: Wei Qiao <qiaow@purdue.edu>
|
---|
4 | * Purdue Rendering and Perceptualization Lab (PURPL)
|
---|
5 | *
|
---|
6 | * Copyright (c) 2004-2006 Purdue Research Foundation
|
---|
7 | *
|
---|
8 | * See the file "license.terms" for information on usage and
|
---|
9 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
---|
10 | * ======================================================================
|
---|
11 | */
|
---|
12 |
|
---|
13 | // update positions based on velocity
|
---|
14 |
|
---|
15 | #include "common.cg"
|
---|
16 |
|
---|
17 | float4 main(in float2 uv : TEXCOORD0,
|
---|
18 | uniform samplerRECT pos_tex,
|
---|
19 | uniform sampler3D vel_tex,
|
---|
20 | uniform float timestep,
|
---|
21 | uniform float3 scale
|
---|
22 | ) : COLOR
|
---|
23 | {
|
---|
24 |
|
---|
25 | // get previous position and velocity
|
---|
26 | float4 pos = texRECT(pos_tex, uv);
|
---|
27 | float4 ret;
|
---|
28 | float time = pos.w;
|
---|
29 |
|
---|
30 | float4 vel = float4(tex3D(vel_tex, pos.xyz).xyz, 0);
|
---|
31 |
|
---|
32 | //reconstruct negative value
|
---|
33 | vel = (vel - float4(0.5,0.5,0.5,0.))*2.;
|
---|
34 | vel.x *= scale.x;
|
---|
35 | vel.y *= scale.y;
|
---|
36 | vel.z *= scale.z;
|
---|
37 | ret = pos + vel*timestep;
|
---|
38 | //ret = pos;
|
---|
39 |
|
---|
40 |
|
---|
41 | //not drawing if the particle is out of bound
|
---|
42 | if(ret.x<0 || ret.x>1 || ret.y<0 || ret.y>1 || ret.z<0 || ret.z>1 || time==0)
|
---|
43 | ret = float4(1,0,0,0);
|
---|
44 | else
|
---|
45 | ret.w = 1;
|
---|
46 |
|
---|
47 |
|
---|
48 | // ret.w = 1.;
|
---|
49 | return ret;
|
---|
50 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.