/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright (c) 2004-2013 HUBzero Foundation, LLC * * Authors: * Wei Qiao */ // update positions based on velocity #include "common.cg" float4 main(in float2 uv : TEXCOORD0, uniform samplerRECT pos_tex, uniform samplerRECT init_pos_tex, uniform sampler3D vel_tex, uniform float timestep, uniform float max, uniform float3 scale) : COLOR { float4 ret; // get previous position float4 pos = texRECT(pos_tex, uv); float time = pos.w; if (max > 0) { #ifdef EXPIRE time -= timestep; // Lifetime ended? if (time < 0) { return texRECT(init_pos_tex, uv); } #endif //reconstruct negative value float4 vel = float4(tex3D(vel_tex, pos.xyz).yzw, 0.0) * 2.0 - float4(1.0, 1.0, 1.0, 0.0); vel = vel * max; //vel *= float4(scale, 1); ret = pos + (vel * timestep); } else { ret = pos; } //not drawing if the particle is out of bound if (ret.x < 0 || ret.x > 1 || ret.y < 0 || ret.y > 1 || ret.z < 0 || ret.z > 1) { ret = texRECT(init_pos_tex, uv); } else { ret.w = time; } return ret; }