1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|

2 | float4 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 | |
---|

33 | float4 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 | |
---|

45 | float4 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 | } |
---|