source: trunk/packages/vizservers/nanovis/shaders/update_pos.cg @ 1018

Last change on this file since 1018 was 851, checked in by vrinside, 16 years ago

Got particle system and LIC (Line integral convolution) run.

File size: 1.4 KB
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
17float4 main(in float2 uv : TEXCOORD0,
18            uniform samplerRECT pos_tex,
19            uniform sampler3D vel_tex,
20            uniform float timestep,
21            uniform float max,
22            uniform float3 scale
23            ) : COLOR
24{
25    // get previous position and velocity
26    float4 pos = texRECT(pos_tex, uv);
27    float4 ret;
28    float time = pos.w;
29
30    //reconstruct negative value
31    float4 vel = float4(tex3D(vel_tex, pos.xyz).xyz, 0) - float4(0.5, 0.5, 0.5, 0.0f);
32    vel = vel * (2 * max);
33    //vel.x *= scale.x;
34    //vel.y *= scale.y;
35    //vel.z *= scale.z;
36    ret = pos;
37    ret.x += vel.x * 0.0005;
38    ret.y += vel.y * 0.0005;
39    ret.z += vel.z * 0.0005;
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.