/[libvob]/libvob/vob/demo/vpmultifil.py
ViewVC logotype

Diff of /libvob/vob/demo/vpmultifil.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by tjl, Thu May 22 13:53:31 2003 UTC revision 1.3 by tjl, Fri May 23 08:52:34 2003 UTC
# Line 30  void main( Line 30  void main(
30      out float4 opos: POSITION,      out float4 opos: POSITION,
31      out float4 col: COLOR      out float4 col: COLOR
32  ) {  ) {
33        float thickness = 5 + 1000 / (dists.y * dists.y);
34    
35      float pi = 3.141592;      float pi = 3.14159;
36    
37      float ang = pos.x / 2.01;      float2 targetvector = float2(sin(angles.y), cos(angles.y));
38        float2 dtargetvector = angles.x * r90(targetvector);
39    
40      float curang = lerp(angles.y, angles.z, ang);      float rangle = angles.y + angles.x * pi / 4;
41      float curdist = lerp(dists.y, dists.z, ang);      float2 touchvector = float2(sin(rangle), cos(rangle));
42    
43        float sinangle = abs(dot(r90(targetvector), touchvector));
44        float cosangle = dot(targetvector, touchvector);
45    
46        float2 tangentinters =
47          dists.x * targetvector / cosangle;
48        
49    
50        float4 p0 = float4(0,0,0,1);
51        p0.xy = targetvector * dists.y +
52                    dtargetvector * thickness;
53    
54        float4 p2 = float4(0,0,0,1);
55        p2.xy = touchvector * dists.x;
56    
57        float4 p1 = float4(0,0,0,1);
58        p1.xy = lerp(p2.xy, tangentinters,
59                        1-(thickness / dists.x) / sinangle);
60    
61        // weights - multiply all homog coords
62        p0 *= .1;
63        p1 *= 1;
64        p2 *= 5;
65    
66        float4 coeff = float4(
67            pos.x * pos.x,
68            2 * pos.x * (1-pos.x),
69            (1-pos.x) * (1-pos.x),
70            0
71        );
72    
73        // coeff = float4(.5,.3,.2,0);
74    
75        float4 bez = coeff.x * p0 + coeff.y * p1 + coeff.z * p2;
76        bez /= bez.w;
77    
78        float2 foopos = lerp(p0.xy, // targetvector * dists.y,
79                            p1.xy, // touchvector * dists.x,
80                            pos.x) ;
81    
82        // bez.xy = lerp(foopos.xy, bez.xy, pos.y);
83    
84        float4 rpos4 = float4(0,0,0,1);
85        rpos4.xy = center + bez.xy + 5 * pos.y * float2(1,1);
86    
87        opos = mul(glstate.matrix.mvp, rpos4);
88    
89        col.xyz = coeff.xyz;
90        col.w = .8;
91    }
92    
93    """, "arbvp1")),
94    ]
95    
96    foo = [
97    # GL.createProgram(cg.compile("""
98    (("""
99    
100    float2 r90(float2 v) {
101        return float2(v.y, -v.x);
102    }
103    
104    float2 rn90(float2 v) {
105        return float2(-v.y, v.x);
106    }
107    
108    void main(
109        float4 pos: POSITION,
110        uniform float2 center: C0,
111        uniform float3 zooms: C1,
112        uniform float3 zs: C2,
113        uniform float3 angles: C3,
114        uniform float3 dists: C4,
115        uniform float4 params: C5,
116        out float4 opos: POSITION,
117        out float4 col: COLOR
118    ) {
119        float angle = abs(angles.z - angles.y);
120        float thickness = 5 + 50 / dists.y;
121        float erad = (1 + .5 * (1-smoothstep(0, 1, angle))) * dists.x;
122    
123        float xcoord = lerp(.1 / angle, 1, pos.x * pos.x);
124        float ycoord = (1-pos.x)*(1-pos.x);
125    
126        float realy = lerp(erad, dists.y, ycoord);
127    
128    
129        xcoord /= realy / erad;
130    
131        float2 targetvector = float2(sin(angles.y), cos(angles.y));
132        float2 dtargetvector = angles.x * r90(targetvector);
133    
134    
135        float curang = lerp(angles.y, angles.z, xcoord / 2);
136    
137    
138      float2 v = float2(sin(curang), cos(curang));      float2 v = float2(sin(curang), cos(curang));
139      float2 dv = angles.x * r90(v);      float2 dv = angles.x * r90(v);
140    
     float sfact = (1-sqrt(sqrt(1-(1-pos.x)*(1-pos.x)*(1-pos.x)*(1-pos.x))));  
   
141      float2 rpos = center +      float2 rpos = center +
142          (dists.x + sfact * (curdist-dists.x)) * v +          (realy) * v +
         (1-pos.x) * (10 - sfact * ang * pi * curdist ) * dv +  
143          // rand offset          // rand offset
144          pos.y * 2 * v + pos.y * 2 * dv;          pos.y * 2 * v + pos.y * 2 * dv;
145    
# Line 59  void main( Line 152  void main(
152      col.w = .8;      col.w = .8;
153  }  }
154    
155  """, "arbvp1"))]  """, "arbvp1"))
156    ]
157    
158  class Scene:  class Scene:
159      def __init__(self):      def __init__(self):

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26