Last change
on this file since 5046 was
4904,
checked in by ldelgass, 9 years ago
|
Merge serveral changes from trunk. Does not include threading, world space
changes, etc.
|
File size:
1.2 KB
|
Line | |
---|
1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* |
---|
3 | * Copyright (c) 2004-2013 HUBzero Foundation, LLC |
---|
4 | * |
---|
5 | * Authors: |
---|
6 | * Wei Qiao <qiaow@purdue.edu> |
---|
7 | */ |
---|
8 | |
---|
9 | // update positions based on velocity |
---|
10 | |
---|
11 | #include "common.cg" |
---|
12 | |
---|
13 | float4 main(in float2 uv : TEXCOORD0, |
---|
14 | uniform samplerRECT pos_tex, |
---|
15 | uniform samplerRECT init_pos_tex, |
---|
16 | uniform sampler3D vel_tex, |
---|
17 | uniform float timestep, |
---|
18 | uniform float max, |
---|
19 | uniform float3 scale) : COLOR |
---|
20 | { |
---|
21 | float4 ret; |
---|
22 | // get previous position |
---|
23 | float4 pos = texRECT(pos_tex, uv); |
---|
24 | float time = pos.w; |
---|
25 | |
---|
26 | #ifdef EXPIRE |
---|
27 | time -= timestep; |
---|
28 | |
---|
29 | // Lifetime ended? |
---|
30 | if (time < 0) { |
---|
31 | return texRECT(init_pos_tex, uv); |
---|
32 | } |
---|
33 | #endif |
---|
34 | |
---|
35 | //reconstruct negative value |
---|
36 | float4 vel = float4(tex3D(vel_tex, pos.xyz).yzw, 0.0) * 2.0 - float4(1.0, 1.0, 1.0, 0.0f); |
---|
37 | vel = vel * max; |
---|
38 | //vel *= float4(scale, 1); |
---|
39 | ret = pos + (vel * timestep); |
---|
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) { |
---|
43 | ret = texRECT(init_pos_tex, uv); |
---|
44 | } else { |
---|
45 | ret.w = time; |
---|
46 | } |
---|
47 | |
---|
48 | return ret; |
---|
49 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.