ios - Transparent objects with visible textures(set alpha channel) -


I need to show transparent objects with alpha channel set texture using OpenGL ES 2.0 and mtl2opengl.pl I can show the object with texture on the iPhone but the alpha channel does not work.

It is almost similar to the mtl2opengl.pl sample. How do I change the code?

In ViewController.m:

  - (zero) glkView: (GLKView *) Draw to see: (CGRect) rect {// Clear buffers GlClearColor ( 1.0, 1.0, 1.0, 1.0); Gluclease (GL_Collo_B_BFFER_BIT | GL_DEPTH_BUFFER_BIT); // Set Visual Matrix [Self Update Visual Matrix]; GlUniformMatrix4fv (_uniforms.u projection matrix, 1, 0, _projectionmatrix.m); GlUniformMatrix4fv (_uniforms.uModelViewMatrix, 1, 0, _modelViewMatrix.m); GlUniformMatrix3fv (_uniforms.u general matrix, 1, 0, _normalMatrix.m); // Make Texture glUniform1i (_uniforms.u fixtures, 0); // set mode mode glUniform1i (_uniforms.uMode, self.viewMode.selectedSegmentIndex); // Enable glEnableVertexAttribArray (_attributes.aVertex); GlEnableVertexAttribArray (_attributes.aNormal); GlEnableVertexAttribArray (_attributes.aTexture); // Loaded OBJE data glVertexAttribPointer (_attributes.aVertex, 3, GL_FLOAT, GL_FALSE, 0, buildOBJVerts); GlVertexAttribPointer (_attributes.aNormal, 3, GL_FLOAT, GL_FALSE, 0, buildOBJNormals); GlVertexAttribPointer (_attributes.aTtexture, 2, GL_FLOAT, GL_FALSE, 0, buildOBJTexCoords); // Load MTL Data for (INT = 0; I & lt; buildMTLNumMaterials; i ++) {glUniform3f (_uniforms.uAmbient, buildMTLAmbient [i] [0], buildMTLAmbient [i] [1], buildMTLAmbient [i] [2]); Gluninform 3F (_uniforms.udiffuse, buildMTLDiffuse [i] [0], buildmatidfus [i] [1], buildmatidfus [i] [2]); Gluninform 3F (_uniforms.uSpecular, Build MTLSPCPular [I] [0], Build MTL Speculator [I] [1], Build MTL SPCPular [I] [2]); GlUniform1f (_uniforms.uExponent, buildMTLExponent [i]); // Group Group glDrawArrays (GL_TRIANGLES, buildMTLFirst [i], build the view by buildMTLCount [i] // disable properties glDisableVertexAttribArray (_attributes.aVertex); glDisableVertexAttribArray (_attributes.aNormal); glDisableVertexAttribArray (_attributes.aTexture);} < / Code> 

Shader.fsh:

  // fragment shader static const char * ShaderF = STRINGIFY (// variation of input medium with vertex shader vc3; vec3 vnormal; varying vTexture Vec2 mediump; uAmbient vec3 // MTL data uniform lowp; uDiffuse vec3 uniform lowp; uSpecular vec3 uniform lowp; uniform lowp integer uMode; uColor vec3 uniform lowp; uniform uExponent boat highp uniform sampler2D uTexture; lowp vec3 materialDefault (highp boat df, highp sfLowp vec3 diffusion = vec3 (0.0,1.0,0.0); highp boat exponent = 1.0; sf = pove (sf, exponent); return (df * diffusion);} lowp vec3 materialMTL (highp name df, highp name Sf} {sf = Pove (sf, uExponent); return (df * uDiffuse);} lowp vec3 modelColor (zero) {highp vec3n = normal (vNormal); Highp vec3 l = vec3 (1.0, 1.0, 0.5); Hype VC3E = VC3 (0.0, 0.0, 1.0); Hype VC3H = normalized (L + E); Hype Float DF = Max (0.0, Dot (N, L)); Hype Float SF = Max (0.0, dot N, H)); //D fault if (UMOD == 0) return content default (DF, SF); // Texture second if (Yumod == 1) Returns (Matte Default (DF, SF) * VC3 (Texture 2D (Utation, Vectature)); // content other if (urode == 2) return material MTL (DF, SF); } Zero main (zero) {low curve 3 color = model color (); Gl_FragColor = vec4 (Color, 1.0); });  

It is clear, learn languages ​​from a book, use vec4 everywhere ( Content default, physical MTL, model collar) and alpha mix.

Example:

  Less Wax 4 MetalMLL (Hype Float DF, Hype Float SF) {SF = Pow (SF, UXAptent); Return VC4 (DF * uDiffuse, 1.0); } Color (void):  
  Return (content default (DF, SF) * Texture 2D );  

Activate the alpha mixture:

  globally (gL_blend); Globefenk (GLICCR_ALPHA, GL_ONMIMINUSURSCALAPHA);  

What is the real problem?


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -