File t.c changed (mode: 100644) (index 5c158c6..29ae14a) |
... |
... |
const GLchar *vert_src = R"( |
15 |
15 |
#version 330 |
#version 330 |
16 |
16 |
#extension GL_ARB_explicit_uniform_location : enable |
#extension GL_ARB_explicit_uniform_location : enable |
17 |
17 |
out vec2 kn; |
out vec2 kn; |
|
18 |
|
out vec4 knn; |
18 |
19 |
|
|
19 |
|
out vec4 knn; |
|
20 |
20 |
layout(location = 1) in vec2 in_p; |
layout(location = 1) in vec2 in_p; |
21 |
21 |
layout(location = 0) in vec4 in_position; |
layout(location = 0) in vec4 in_position; |
22 |
|
layout(location =10)uniform mat4 projection; |
|
|
22 |
|
layout(location =10)uniform mat4 projection; |
|
23 |
|
layout(location =2)in vec3 n; |
|
24 |
|
out vec3 cb; |
|
25 |
|
out mat4 p; |
23 |
26 |
void main() |
void main() |
24 |
|
{ |
|
|
27 |
|
{ |
|
28 |
|
|
|
29 |
|
|
|
30 |
|
//mat3 m3 = mat3( projection[0].xyz,projection[1].xyz,projection[2].xyz); |
|
31 |
|
p= projection; |
|
32 |
|
cb=n; |
25 |
33 |
gl_Position = projection*in_position; |
gl_Position = projection*in_position; |
26 |
|
knn=in_position ; |
|
27 |
|
kn=in_p ; |
|
|
34 |
|
kn=in_p ; |
|
35 |
|
knn=in_position; |
28 |
36 |
// gl_Position = in_position; |
// gl_Position = in_position; |
29 |
37 |
} |
} |
30 |
38 |
)"; |
)"; |
|
... |
... |
const GLchar *frag_src =R"( |
33 |
41 |
#version 330 |
#version 330 |
34 |
42 |
#extension GL_ARB_explicit_uniform_location : enable |
#extension GL_ARB_explicit_uniform_location : enable |
35 |
43 |
layout(location =11)uniform sampler2D t; |
layout(location =11)uniform sampler2D t; |
36 |
|
vec4 b; |
|
37 |
|
in vec4 knn; |
|
38 |
|
in vec2 kn; |
|
39 |
|
void main (void) |
|
40 |
|
{ |
|
|
44 |
|
float intensity; |
|
45 |
|
in vec2 kn; |
|
46 |
|
in vec4 knn; |
|
47 |
|
in mat4 p; |
|
48 |
|
in vec3 cb; |
|
49 |
|
|
|
50 |
|
void main() |
|
51 |
|
{ |
|
52 |
|
vec3 b=vec3(.5,-.4,-.42); |
|
53 |
|
//vec3 tb=vec3(p*b); |
|
54 |
|
mat3 tw = transpose(inverse(mat3(p))); |
|
55 |
|
vec3 h = normalize(tw*cb); |
|
56 |
|
vec3 s = vec3(p * knn ); |
|
57 |
|
vec3 hk=normalize(b - s); |
|
58 |
|
intensity = max(dot(h,b), 0.0); |
41 |
59 |
if(gl_FrontFacing) |
if(gl_FrontFacing) |
42 |
|
gl_FragColor = texture( t, kn); |
|
|
60 |
|
gl_FragColor = vec4( intensity*texture( t, kn).xyz, 1.); |
43 |
61 |
else discard; |
else discard; |
44 |
62 |
} |
} |
45 |
63 |
)"; |
)"; |
|
... |
... |
while (1); |
162 |
180 |
bba=(bbh)/3; |
bba=(bbh)/3; |
163 |
181 |
|
|
164 |
182 |
|
|
165 |
|
b=glm::lookAt(glm::vec3(-1.2484,0.483,1.84384), glm::vec3(-0.3801, -0.4183,-3.15),glm::vec3( 0.,0.2,-00.)); |
|
|
183 |
|
b=glm::lookAt(glm::vec3(-1.2484,0.483,1.84384), glm::vec3(-0.3801, -0.4183,-3.15),glm::vec3( 0., 0.2,-00.)); |
166 |
184 |
yt=glm::perspective(45., 1., 1.2, 300.); |
yt=glm::perspective(45., 1., 1.2, 300.); |
167 |
185 |
b=yt*b*glm::mat4(1.); |
b=yt*b*glm::mat4(1.); |
168 |
186 |
|
|
|
... |
... |
c.nchannels=4; |
177 |
195 |
c.x=0; |
c.x=0; |
178 |
196 |
c.y=0; |
c.y=0; |
179 |
197 |
c.format=TypeDesc::UINT8; |
c.format=TypeDesc::UINT8; |
180 |
|
GLfloat ok[] ={0.4,0.4,0.8}; |
|
181 |
|
ImageBuf k(c,trr); |
|
182 |
|
ImageBuf h("161208ap5410_fpx.jpg"); |
|
183 |
|
h.read(); |
|
|
198 |
|
ImageBuf k(c,trr);; |
|
199 |
|
ImageBuf h(" 161208ap5410_fpx.jpg "); |
|
200 |
|
ImageBufAlgo::flip(h,h); |
184 |
201 |
k.copy_pixels(h); |
k.copy_pixels(h); |
185 |
|
h.clear (); |
|
186 |
|
|
|
187 |
|
|
|
188 |
|
//ImageBufAlgo::render_text(k,34,157,"7.5 10.7 15 7",179,"/usr/share/fonts/truetype/freefont/FreeSerifBold.ttf",ok); |
|
189 |
|
//ImageBufAlgo::render_text(k,274,757,"9.5 +9.7",179,"/usr/share/fonts/truetype/freefont/FreeSerifBold.ttf",ok); |
|
190 |
|
//ImageBufAlgo::render_text(k,34,357,"4.5 7.7",179,"/usr/share/fonts/truetype/freefont/FreeSerifBold.ttf",ok); |
|
191 |
|
|
|
192 |
|
|
|
193 |
202 |
|
|
194 |
203 |
|
|
195 |
204 |
GLuint frag_shader, vert_shader; |
GLuint frag_shader, vert_shader; |
|
... |
... |
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*bbp, t, GL_STATIC_DRAW); |
229 |
238 |
glEnableVertexAttribArray(1); |
glEnableVertexAttribArray(1); |
230 |
239 |
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, (void*)0); |
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, (void*)0); |
231 |
240 |
|
|
|
241 |
|
glGenBuffers(1, &tpra); |
|
242 |
|
glBindBuffer(GL_ARRAY_BUFFER, tpra); |
|
243 |
|
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*bbh, ttk , GL_STATIC_DRAW); |
|
244 |
|
|
|
245 |
|
glEnableVertexAttribArray(2); |
|
246 |
|
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); |
|
247 |
|
|
232 |
248 |
glBindVertexArray(0); |
glBindVertexArray(0); |
233 |
249 |
|
|
234 |
250 |
//glGenTextures(1, &vertexT); |
//glGenTextures(1, &vertexT); |