source: nanovis/branches/1.1/shaders/particlefp.cg @ 4599

Last change on this file since 4599 was 2877, checked in by ldelgass, 12 years ago

Some minor refactoring, also add some more fine grained config.h defines
(e.g. replace NV40 define with feature defines). Add tests for some required
OpenGL extensions (should always check for extensions or base version before
calling entry points from the extension). Also, clamp diffuse and specular
values on input and warn when they are out of range.

File size: 1.8 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2#include "particle_common.cg"
3
4#ifdef USE_TIME_SERIES
5#define LEVEL1 0.5
6#define LEVEL2 0.4
7#else
8#define LEVEL1 0.7
9#define LEVEL2 0.5
10#endif
11
12float4 fpmain(float2 texCoord : TEXCOORD0,
13              float3 color : COLOR,
14              float2 center : TEXCOORD2,
15              float4 rotation : TEXCOORD3,
16              float skip : TEXCOORD4,
17              float mag : TEXCOORD5,
18              float zValue : TEXCOORD6,
19              uniform sampler2D arrows : register(s0)) : COLOR
20{
21    if (skip > 0.5) {
22        discard;
23    }
24
25    float2 newTexCoord = float2((texCoord.x - 0.5) / NUM_SUBIMAGE_X, (texCoord.y - 0.5) / NUM_SUBIMAGE_Y);
26    float2 rotTexCoord;
27    rotTexCoord.x = rotation.x * newTexCoord.x + rotation.y * newTexCoord.y;
28    rotTexCoord.y = rotation.z * newTexCoord.x + rotation.w * newTexCoord.y;
29    rotTexCoord.x = rotTexCoord.x + 0.5 / NUM_SUBIMAGE_X;
30    rotTexCoord.y = rotTexCoord.y + 0.5 / NUM_SUBIMAGE_Y;
31    rotTexCoord = rotTexCoord + center;
32    float4 refColor;
33#ifdef USE_J_WIRE       
34    if (mag > 0.2)
35        refColor = float4(1, 0, 0, 1.0);
36    else if (mag > 0.1)
37        refColor = float4(1, 1, 0, 0.3);
38    else
39        refColor = float4(1, 1, 1, 0.3);
40#else
41    if (mag > LEVEL1)
42        refColor = float4(1, 0, 0, 1.0);
43    //refColor = float4(1, 0, 0, 1.0 * (3.0 + zValue) / 3);
44    else if (mag > LEVEL2)
45        refColor = float4(1, 1, 0, 0.3);
46    //refColor = float4(1, 1, 0, 1.0);
47    else
48        refColor = float4(0.5, 0.5, 0.5, 0.2);
49    //refColor = float4(0.5, 0.5, 0.5, 1.0);
50#endif
51    float4 arrowc = tex2D(arrows, rotTexCoord.xy);
52    float4 c = float4(arrowc.xyz, ((arrowc.w == 1.0)? 1 : 0));
53    //float4 c = float4(arrowc.xyz, ((arrowc.w != 0.0)? 1 : 0));
54       
55    return c * refColor;
56}
Note: See TracBrowser for help on using the repository browser.