source: trunk/packages/vizservers/nanovis/shaders/moveparticles.cg @ 2852

Last change on this file since 2852 was 2852, checked in by ldelgass, 8 years ago

Fix up line endings and formatting in shader code, also add emacs magic line
to get C++ mode highlighting

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