source: nanovis/trunk/shaders/velocityslicevp.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: 1.8 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#include "particle_common.cg"
10
11void main(in float4 posin : POSITION,
12          in float4 colin : COLOR0,
13          out float4 posout : POSITION,
14          out float4 colout : COLOR0,
15          out float2 center : TEXCOORD2,
16          out float4 rotation : TEXCOORD3,
17          out float4 pointSize : PSIZE,
18          uniform sampler3D vfield : TEXUNIT1,
19          uniform float tanHalfFOV,
20          uniform float4x4 modelview,
21          uniform float4x4 mvp)
22{
23    float4 vec;
24    vec.xyz = posin.xyz;
25    vec.w = 1.0;
26
27    // length
28    // the scale of from bottom to top
29    float3 velocity = tex3D(vfield, vec.xyz).yzw * 2 - float3(1, 1, 1);
30
31    // bottom to top
32    // scale
33    center.y = ((((int) (length(velocity.xyz) * 511)) / SUBIMAGE_SIZE_Y) * SUBIMAGE_SIZE_Y) / 512.0;
34
35    velocity = mul(modelview, float4(velocity.x, velocity.y, velocity.z, 0.0)).xyz;
36    if (length(velocity) != 0.0)
37        velocity = normalize(velocity);
38
39    float a = (asin(velocity.z) / 3.141592 + 1) * 0.5;
40    center.x = ((((int) (a * 511)) / SUBIMAGE_SIZE_X) * SUBIMAGE_SIZE_X) / 512.0;
41
42    if ((abs(velocity.x) == 0.0) && (abs(velocity.y) == 0.0)) {
43        rotation.x = 1;
44        rotation.y = 0;
45        rotation.z = 0;
46        rotation.w = 1;
47    } else {
48        float2 xy = normalize(velocity.xy);
49        rotation.x = xy.x * 0.8;
50        rotation.y = -xy.y * 0.8;
51        rotation.z = xy.y * 0.8;
52        rotation.w = xy.x * 0.8;
53    }
54
55    float4 posEye =  mul(modelview, posin);
56    //pointSize = tanHalfFOV / -posEye.z / 5;
57    //pointSize = tanHalfFOV / -posEye.z / 10; //j-wire
58    pointSize = 20; //0 / -posEye.z;
59
60    posout = mul(mvp, vec);
61
62    colout = colin;
63}
Note: See TracBrowser for help on using the repository browser.