26 |
fn2 = jarray.zeros(10*10, 'h') |
fn2 = jarray.zeros(10*10, 'h') |
27 |
|
|
28 |
fn[15] = 1 |
fn[15] = 1 |
29 |
|
fn[14] = 1 |
30 |
|
fn[13] = 1 |
31 |
|
fn[12] = 1 |
32 |
|
fn[25] = 1 |
33 |
|
fn[24] = 1 |
34 |
|
fn[23] = 1 |
35 |
|
fn[22] = 1 |
36 |
|
fn[35] = 1 |
37 |
|
fn[34] = 1 |
38 |
|
fn[33] = 1 |
39 |
|
fn[32] = 1 |
40 |
for i in range(0,20): # exercise JVM |
for i in range(0,20): # exercise JVM |
41 |
print "Exercise ",i |
print "Exercise ",i |
42 |
vob.util.TexManip.minDist(fn, fn2, 10, 10, 10) |
vob.util.TexManip.minDist(fn, fn2, 10, 10, 10) |
55 |
|
|
56 |
fn = jarray.zeros(2*w*h, 'b') |
fn = jarray.zeros(2*w*h, 'b') |
57 |
fn2 = jarray.zeros(w*h, 'h') |
fn2 = jarray.zeros(w*h, 'h') |
58 |
|
fn3 = jarray.zeros(4*w*h, 'b') |
59 |
|
|
60 |
t.getTexImage(0, "ALPHA", "UNSIGNED_BYTE", fn) |
t.getTexImage(0, "ALPHA", "UNSIGNED_BYTE", fn) |
61 |
# for i in range(0, w*h, 5): |
# for i in range(0, w*h, 5): |
68 |
# Distance * 16 |
# Distance * 16 |
69 |
vob.util.TexManip.minDist(fn, fn2, w, h, 16) |
vob.util.TexManip.minDist(fn, fn2, w, h, 16) |
70 |
print "Maniped1" |
print "Maniped1" |
71 |
vob.util.TexManip.b2s(fn2, fn) |
vob.util.TexManip.b2s(fn2, fn3, 4) |
72 |
|
|
73 |
print "Maniped" |
print "Maniped" |
74 |
|
|
78 |
|
|
79 |
t.setTexParameter("TEXTURE_2D", "GENERATE_MIPMAP_SGIS", "TRUE"); |
t.setTexParameter("TEXTURE_2D", "GENERATE_MIPMAP_SGIS", "TRUE"); |
80 |
|
|
81 |
t.texImage2D(0, "LUMINANCE_ALPHA", w, h, 0, "LUMINANCE_ALPHA", "UNSIGNED_BYTE", fn) |
for y in range(0,50): |
82 |
|
print " ".join([str(fn3[1000*y + i]) for i in range(0,30)]) |
83 |
|
t.texImage2D(0, "SIGNED_HILO16_NV", w, h, 0, "HILO_NV", "SHORT", fn3) |
84 |
|
|
85 |
fonttexs.append(t) |
fonttexs.append(t) |
86 |
|
|
109 |
|
|
110 |
from vob.putil import cg |
from vob.putil import cg |
111 |
|
|
112 |
fp = [GL.createProgram(cg.compile(""" |
fp = [ |
113 |
|
GL.createProgram(cg.compile(""" |
114 |
void main( |
void main( |
115 |
float2 t : TEXCOORD0, |
float2 t : TEXCOORD0, |
116 |
uniform float2 meas: register(c0), |
uniform float2 meas: register(c0), |
134 |
// * 512 = texture width |
// * 512 = texture width |
135 |
// / 2 = half, for radius |
// / 2 = half, for radius |
136 |
// / 2 = half, for x-sampling pattern |
// / 2 = half, for x-sampling pattern |
137 |
half maxrad = l * 512 / 2 / 2 * meas.y; |
half4 maxrad = l * 512 / 2 / 2 * meas.y; |
138 |
|
|
139 |
half4 c0 = tex2D(t0, t + meas.x*(dx+dy)); |
half4 c0 = tex2D(t0, t + meas.x*(dx+dy)); |
140 |
|
|
143 |
half4 c2 = tex2D(t0, t + meas.x*(-dx+dy)); |
half4 c2 = tex2D(t0, t + meas.x*(-dx+dy)); |
144 |
half4 c3 = tex2D(t0, t + meas.x*(-dx-dy)); |
half4 c3 = tex2D(t0, t + meas.x*(-dx-dy)); |
145 |
|
|
146 |
half4 dists = half4( |
half4 dists = 256 * 16 * half4( |
147 |
// c0.x + c0.w * 256, |
c0.x, |
148 |
c0.w + c0.x * 256, |
c1.x, |
149 |
c1.x + c1.w * 256, |
c2.x, |
150 |
c2.x + c2.w * 256, |
c3.x); |
|
c3.x + c3.w * 256); |
|
151 |
|
|
152 |
|
|
|
dists *= 16; |
|
153 |
|
|
154 |
|
|
155 |
fixed c = dot(1-smoothstep(float4(0,0,0,0), maxrad, dists), fixed4(1,1,1,1)) / 4; |
fixed c = dot(1-smoothstep(-maxrad, maxrad, dists), fixed4(1,1,1,1)) / 4; |
156 |
|
|
157 |
fixed rgb = (1 - c); |
fixed rgb = (1 - c); |
158 |
|
|
165 |
|
|
166 |
|
|
167 |
""", "fp30")), |
""", "fp30")), |
168 |
|
GL.createProgram(cg.compile(""" |
169 |
|
void main( |
170 |
|
float2 t : TEXCOORD0, |
171 |
|
uniform float2 meas: register(c0), |
172 |
|
uniform sampler2D t0: TEXUNIT0, |
173 |
|
out half4 color: COLOR) { |
174 |
|
float4 tx = tex2D(t0,t); |
175 |
|
float x = tx.x * 256 * 16; |
176 |
|
float tex = 5; |
177 |
|
if(x > tex) |
178 |
|
color = float4(1,0,1,0); |
179 |
|
else if(x > 0) |
180 |
|
color = float4(0,1,0,1); |
181 |
|
else if(x > -tex) |
182 |
|
color = float4(0,0,1,1); |
183 |
|
else |
184 |
|
color = float4(1,0,0,1); |
185 |
|
} |
186 |
|
|
187 |
|
|
188 |
|
""", "fp30")), |
189 |
GL.createProgram("""!!FP1.0 |
GL.createProgram("""!!FP1.0 |
190 |
DECLARE meas; |
DECLARE meas; |
191 |
MOV R10, f[TEX0].xyzw; |
MOV R10, f[TEX0].xyzw; |
547 |
|
|
548 |
cs = vs.rotateCS(cs, "b", self.a) |
cs = vs.rotateCS(cs, "b", self.a) |
549 |
|
|
550 |
if self.prognum == 0: |
if self.prognum < 2: |
551 |
f = font |
f = font |
552 |
else: |
else: |
553 |
f = font2 |
f = font2 |