glsles

normal matrix for non uniform scaling

。_饼干妹妹 提交于 2019-12-17 20:28:39
问题 Im trying to calculate the normal matrix for my GLSL shaders on OpenGL 2.0. The theory is : a normal matrix is the top left 3x3 matrix of the ModelView, transposed and inverted. It seems to be correct as I have been rendering my scenes correctly, until I imported a model from maya and found non-uniform scales. Loaded models have a weird lighting, while my procedural ones are correct, so I put my money on the normal matrix calculation. How is it computed with non uniform scale? 回答1: You

Instanced drawing with OpenGL ES 2.0 on iOS

左心房为你撑大大i 提交于 2019-12-13 11:51:03
问题 In short: Can anyone confirm whether it is possible to use the built-in variable gl_InstanceID (or gl_InstanceIDEXT ) in a vertex shader using OpenGL ES 2.0 on iOS with GL_EXT_draw_instanced enabled? Longer: I want to draw multiple instances of an object using glDrawArraysInstanced and gl_InstanceID, and I want my application to run on multiple platforms, including iOS. The specification clearly says that these features require ES 3.0. According to the iOS Device Compatibility Reference ES 3

Writing to gl_FragColor causes glUseProgram to throw GL_INVALID_OPERATION

◇◆丶佛笑我妖孽 提交于 2019-12-13 04:28:47
问题 I'm trying to write a blur filter in GLSL ES 2.0 and I'm getting an Error with the line assigning gl_FragColor. I've not been able to figure out why #extension GL_OES_EGL_image_external : require precision mediump float; varying vec2 textureCoordinate; uniform samplerExternalOES s_texture; void main() { float gaus[25] = float[25](0.01739, 0.03478, 0.04347, 0.03478, 0.01739, 0.03478, 0.07282, 0.10434, 0.07282, 0.03478, 0.04347, 0.10434, 0.13043, 0.10434, 0.04347, 0.03478, 0.07282, 0.10434, 0

In a fragment shader, why can't I use a flat input integer to index a uniform array of sampler2D?

↘锁芯ラ 提交于 2019-12-12 11:01:30
问题 new to shaders here, and a bit puzzled. I want to specify textures to be used when I render an array of sprites. So I put a texture index in their vertex data, and pass it as a flat value from my vertex shader to my fragment shader, but can't use it to index an array of samplers as expected because compiler sees it as "non-constant". Instead I have to resort to the disgusting code below. Can anyone explain what is going on here? const int numTextures = 2; uniform sampler2D textures

OpenGL ES 3.0 matrix array only using first matrix

喜欢而已 提交于 2019-12-12 00:43:51
问题 I am doing GPU skinning in my vertex shader which works fine on PC, and which I'm porting to Android. My vertex shader is below, and the problem is that the creation of the matTransform matrix seems to only use the first matrix in boneMatrices: #version 300 es precision highp float; precision highp int; //Uniform count: projectionMatrix(16) + modelViewMatrix(16) + MVPMatrix(16) + textureMatrix(16) + normalMatrix(9) + lightMVPMatrices(16*5) + nShadowLights(1) + boneMatrices(16*boneMax) = 73 +

iPad Opengl ES program works fine on simulator but not device

随声附和 提交于 2019-12-11 05:32:23
问题 For the device, all of my shaders load fine except one. For this shader program I get "Fragment program failed to compile with current context state" error, followed by a similar error for the vertex shader when I make a call to glGetProgramInfoLog(...); Vertex shader: #version 100 uniform mat4 Projection; uniform mat4 Modelview; uniform mat4 Rotation; uniform vec3 Translation; uniform vec4 LightDirection; uniform vec4 MaterialDiffuse; uniform float MaterialShininess; attribute vec3 position;

glMapBufferRange() returns all zeros in Android OpenGLES 3.0 using TrasnformFeedback

旧时模样 提交于 2019-12-11 03:29:06
问题 UPDATE: This is working and up on gist now! Thanks Reto I am working on an Android implementation of transform feedback following this example. runs pretty well without any errors, but I am getting all zeros out when reading the TransformFeedback buffer with glMapBufferRange() import android.opengl.GLES30; import android.util.Log; import java.nio.ByteBuffer; import java.nio.FloatBuffer; /** * Created by izzy on 6/24/15. */ public class TransformFeedback { private final String TAG =

How to execute 2 passes for a blur effect in openGL ES 2.0

假装没事ソ 提交于 2019-12-11 03:06:14
问题 In order to create a blur effect the theory says to create 2 vertex shaders, one for the horizontal pass, and the second for the vertical pass. And then one fragment shader for actual sampling. My question is, how to actually to execute the 2 vertex shaders? Do I need to render, then get back the pixels via the glReadPixels and then to render again? My environment is Android, OpenGL ES 2.0 Thanks 回答1: You can render the first pass to an FBO, and then use the resulting texture when rendering

Are 1D Textures Supported in WebGL yet?

我的未来我决定 提交于 2019-12-08 15:24:30
问题 I've been trying to find a clear answer, but it seems no one has clearly asked the question. Can I use a 1D sampler and 1D texture in WebGL Chrome, Firefox, Safari, IE, etc? EDIT Understandably 1 is indeed a power of 2 (2^0=1) meaning you could effectively use a 2D sampler and texture using a height of 1 and a width of 256 or 512 etc. to replicate a 1D texture. 1D textures are not moot, they exist because they not only have a purpose, but are intended to translate into optimizations on the

Mapbox Android SDK crash - “java.lang.Error: Vertex shader fill failed to compile”

試著忘記壹切 提交于 2019-12-08 03:47:06
问题 After upgrading my Android Studio version to 2.1.3, my application crashes every time I launch it. More precisely, it crashes when trying to load my Mapbox View (that was perfectly working before that). I did some research, and it seems to be a known issue, but I couldn't find any workaround to pass through it... I think it MAY be a problem with the Emulator only, but for now I couldn't try on a lot of physical devices, so I'm not sure about that. But anyway, I really need to use the emulator