source: branches/nanovis2/packages/vizservers/nanovis/shaders/update_pos.cg @ 3305

Last change on this file since 3305 was 3305, checked in by ldelgass, 11 years ago

sync with trunk

File size: 1.8 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * ======================================================================
4 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
5 *           Purdue Rendering and Perceptualization Lab (PURPL)
6 *
7 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
8 *
9 *  See the file "license.terms" for information on usage and
10 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 * ======================================================================
12 */
13
14// update positions based on velocity
15
16#include "common.cg"
17
18float4 main(in float2 uv : TEXCOORD0,
19            uniform samplerRECT pos_tex,
20            uniform samplerRECT init_pos_tex,
21            uniform sampler3D vel_tex,
22            // uniform sampler1D tf_tex,
23            uniform float timestep,
24            uniform float max,
25            uniform float mode,
26            uniform float3 scale) : COLOR
27{
28    float4 ret;
29    /*
30      if (mode == 0) {
31          float4 pos = texRECT(pos_tex, uv);
32          float4 vel = tex3D(vel_tex, pos.xyz);
33          ret.xyz = tex1D(tf_tex, vel.x).xyz;
34          ret.w = 1;
35      } else {
36    */
37    // get previous position
38    float4 pos = texRECT(pos_tex, uv);
39    float time = pos.w;
40
41#ifdef EXPIRE
42    time -= timestep;
43
44    // Lifetime ended?
45    if (time < 0) {
46        return texRECT(init_pos_tex, uv);
47    }
48#endif
49
50    //reconstruct negative value
51    float4 vel = float4(tex3D(vel_tex, pos.xyz).yzw, 0.0) * 2.0 - float4(1.0, 1.0, 1.0, 0.0f);
52    vel = vel * max;
53    //vel *= float4(scale, 1);
54    ret = pos + (vel * timestep);
55
56    //not drawing if the particle is out of bound
57    if (ret.x < 0 || ret.x > 1 || ret.y < 0 || ret.y > 1 || ret.z < 0 || ret.z > 1) {
58        ret = texRECT(init_pos_tex, uv);
59    } else {
60        ret.w = time;
61    }
62//    }
63
64    return ret;
65}
Note: See TracBrowser for help on using the repository browser.