source: nanovis/trunk/shaders/moveparticles.cg @ 4880

Last change on this file since 4880 was 3630, checked in by ldelgass, 7 years ago

Nanovis refactoring to fix problems with scaling and multiple results.
Do rendering in world space to properly place and scale multiple data sets.
Also fix flows to reduce resets of animations. More work toward removing
Cg dependency. Fix panning to convert viewport coords to world coords.

File size: 2.1 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
9float4 main (float2 texCoord : TEXCOORD0,
10             uniform samplerRECT posTexture : register(s0),
11             uniform samplerRECT initTexture : register(s1),
12             uniform sampler3D vfield,
13             uniform float3 scale,
14             uniform float maxScale,
15             uniform float useInitPos,
16             uniform float timeStep,
17             uniform float currentTime) : COLOR
18{
19    if (maxScale > 100) maxScale = 100;
20
21    float3 oldPosition = f3texRECT(posTexture, texCoord);
22    float3 velocity = tex3D(vfield, oldPosition).yzw - float3(0.5, 0.5, 0.5);
23    velocity = velocity * (2 * maxScale);
24    velocity = velocity * scale;
25       
26    float3 position = oldPosition + velocity * timeStep * 0.01;
27    //float3 position = oldPosition;
28
29    //if (useInitPos) {
30        if ((position.x < 0) || (position.x > 1) ||
31            (position.y < 0) || (position.y > 1) ||
32            (position.z < 0) || (position.z > 1)) {
33            position = f3texRECT(initTexture, texCoord);
34        }
35    //}
36
37    return float4(position, 1);
38}
39
40float4 initParticlePosMain(float3 initPos : TEXCOORD0,
41                           float2 texCoord : TEXCOORD1,
42                           float timeStep : TEXCOORD2,
43                           uniform sampler3D vfield) : COLOR
44{
45    float3 oldPosition = initPos;
46    //float3 velocity = tex3D(vfield, oldPosition).yzw * 2 - float3(1, 1, 1);
47    //float3 position = oldPosition + timeStep * velocity;
48    //return float4(position, 1);
49    return float4(initPos, 1);
50}
51
52float4 mainlines(float2 texCoord : TEXCOORD0,
53                 uniform samplerRECT posTexture : register(s0),
54                 uniform sampler3D vfield,
55                 uniform float2 offset,
56                 uniform float timeStep) : COLOR
57{
58    float3 oldPosition = f3texRECT(posTexture, texCoord);
59    float3 velocity = tex3D(vfield, oldPosition).yzw * 2 - float3(1, 1, 1);
60       
61    float3 position = oldPosition + velocity * timeStep;
62
63    return float4(position, 1);
64}
Note: See TracBrowser for help on using the repository browser.