1 | #ifndef __NV_PARTICLE_ADV_SHADER_H__ |
---|
2 | #define __NV_PARTICLE_ADV_SHADER_H__ |
---|
3 | |
---|
4 | #include "Vector3.h" |
---|
5 | #include "NvShader.h" |
---|
6 | |
---|
7 | class NvParticleAdvectionShader : public NvShader { |
---|
8 | CGparameter _posTimestepParam; |
---|
9 | CGparameter _velTexParam; |
---|
10 | CGparameter _posTexParam; |
---|
11 | CGparameter _scaleParam; |
---|
12 | CGparameter _maxParam; |
---|
13 | unsigned int _velocityVolumeID; |
---|
14 | Vector3 _scale; |
---|
15 | float _max; |
---|
16 | float _timeStep; |
---|
17 | |
---|
18 | public : |
---|
19 | NvParticleAdvectionShader(); |
---|
20 | ~NvParticleAdvectionShader(); |
---|
21 | |
---|
22 | private : |
---|
23 | void init(); |
---|
24 | public : |
---|
25 | void bind(unsigned int texID); |
---|
26 | void unbind(); |
---|
27 | void setScale(const Vector3& scale); |
---|
28 | void setVelocityVolume(unsigned int texID, float max); |
---|
29 | void setTimeStep(float timeStep); |
---|
30 | }; |
---|
31 | |
---|
32 | inline void NvParticleAdvectionShader::setTimeStep(float timeStep) |
---|
33 | { |
---|
34 | _timeStep = timeStep; |
---|
35 | } |
---|
36 | |
---|
37 | inline void NvParticleAdvectionShader::bind(unsigned int texID) |
---|
38 | { |
---|
39 | cgGLBindProgram(_cgFP); |
---|
40 | |
---|
41 | cgGLSetParameter1f(_posTimestepParam, _timeStep); |
---|
42 | cgGLSetParameter1f(_maxParam, _max); |
---|
43 | cgGLSetParameter3f(_scaleParam, _scale.x, _scale.y, _scale.z); |
---|
44 | cgGLSetTextureParameter(_velTexParam, _velocityVolumeID); |
---|
45 | cgGLEnableTextureParameter(_velTexParam); |
---|
46 | cgGLSetTextureParameter(_posTexParam, texID); |
---|
47 | cgGLEnableTextureParameter(_posTexParam); |
---|
48 | |
---|
49 | cgGLEnableProfile(CG_PROFILE_FP30); |
---|
50 | } |
---|
51 | |
---|
52 | inline void NvParticleAdvectionShader::unbind() |
---|
53 | { |
---|
54 | cgGLDisableProfile(CG_PROFILE_FP30); |
---|
55 | |
---|
56 | cgGLDisableTextureParameter(_velTexParam); |
---|
57 | cgGLDisableTextureParameter(_posTexParam); |
---|
58 | } |
---|
59 | |
---|
60 | inline void NvParticleAdvectionShader::setScale(const Vector3& scale) |
---|
61 | { |
---|
62 | _scale = scale; |
---|
63 | } |
---|
64 | |
---|
65 | inline void NvParticleAdvectionShader::setVelocityVolume(unsigned int texID, float max) |
---|
66 | { |
---|
67 | _velocityVolumeID = texID; |
---|
68 | _max = max; |
---|
69 | } |
---|
70 | |
---|
71 | #endif //__NV_PARTICLE_ADV_SHADER_H__ |
---|