glsles

How to write const array in GLSL ES

寵の児 提交于 2019-12-07 16:06:44
问题 I am trying to write a simple vertex shader for an OpenGL ES app on the iPhone, but my array constructor is causing me trouble. attribute vec4 normal; attribute vec4 position; void main(void){ const vec4 vertices[3] = vec4[](vec4(0.25, -0.25, 0.5, 1.0), vec4(-0.25, -0.25, 0.5, 1.0), vec4(0.25, 0.25, 0.5, 1.0)); gl_Position = vertices[gl_VertexID]; } When using this code the shader is unable to compile, and gives me the eror message: ERROR: 0:13: '(' : syntax error: Array size must appear

WebGL: How to bind values to a mat4 attribute?

大憨熊 提交于 2019-12-06 13:58:21
问题 In some WebGL application, let's assume that we have a GLSL vertex shader which starts like this: attribute vec4 foo1; attribute vec4 foo2; attribute vec4 foo3; attribute vec4 foo4; and some corresponding Javascript code for binding a data structure for those attributes: var buf = gl.createBuffer(), loc; gl.bindBuffer(gl.ARRAY_BUFFER, buf); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([…])); loc = gl.getAttribLocation(program, 'foo1'); gl.enableVertexArray(loc); gl.vertexAttribPointer(loc,

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

谁都会走 提交于 2019-12-06 07:29:10
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 to debug my app. If someone has any information about that it will be really helpful. Thank a lot!

How to write const array in GLSL ES

孤人 提交于 2019-12-06 03:58:20
I am trying to write a simple vertex shader for an OpenGL ES app on the iPhone, but my array constructor is causing me trouble. attribute vec4 normal; attribute vec4 position; void main(void){ const vec4 vertices[3] = vec4[](vec4(0.25, -0.25, 0.5, 1.0), vec4(-0.25, -0.25, 0.5, 1.0), vec4(0.25, 0.25, 0.5, 1.0)); gl_Position = vertices[gl_VertexID]; } When using this code the shader is unable to compile, and gives me the eror message: ERROR: 0:13: '(' : syntax error: Array size must appear after variable name The GLSL version used with ES 2.0 does not support constant arrays. From section "4.3.2

Manual selection lod of mipmaps in a fragment shader using three.js

戏子无情 提交于 2019-12-05 14:29:50
I'm writing a physically based shader using glsl es in three.js. For the addition of specular global illumination I use a cubemap dds texture with mipmap chain inside (precalculate with CubeMapGen as it's explained here ). I need to access this texture in fragment shader and I would like to select manually the index of mipmap. The correct function for doing this is vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod) but it's available only in vertex shader. In my fragment shader I'm using the similar function vec4 textureCube(samplerCube sampler, vec3 coord, float bias) but it

WebGL: How to bind values to a mat4 attribute?

一世执手 提交于 2019-12-04 20:26:56
In some WebGL application, let's assume that we have a GLSL vertex shader which starts like this: attribute vec4 foo1; attribute vec4 foo2; attribute vec4 foo3; attribute vec4 foo4; and some corresponding Javascript code for binding a data structure for those attributes: var buf = gl.createBuffer(), loc; gl.bindBuffer(gl.ARRAY_BUFFER, buf); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([…])); loc = gl.getAttribLocation(program, 'foo1'); gl.enableVertexArray(loc); gl.vertexAttribPointer(loc, 4, gl.FLOAT, false, 16, 0); loc = gl.getAttribLocation(program, 'foo2'); gl.enableVertexArray(loc); gl

OpenGL ES3 Shadow map problems

馋奶兔 提交于 2019-12-04 18:13:51
I work on C++ project for Android with OpenGL ES3, so I try to implement the shadow map with directional light, I understand the theory well but I never get it successfully rendered. first I create the framebuffer which contains the depth map: glGenFramebuffers(1, &depthMapFBO); glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); glGenTextures(1, &depthMap); glBindTexture(GL_TEXTURE_2D, depthMap); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, SHADOW_WIDTH, SHADOW_HEIGHT, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL

Instanced drawing with OpenGL ES 2.0 on iOS

落爺英雄遲暮 提交于 2019-12-03 19:07:24
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.0 is only available on a few devices (those based on the A7 GPU; so iPhone 5s, but not on iPhone 5 or

When switching to GLSL 300, met the following error

流过昼夜 提交于 2019-12-03 16:15:55
when I switch to use OpenGL ES 3 with GLSL 300, I met the following error in my frag shader undeclared identifier gl_FragColor when using GLSL 100, everything is fine. Modern versions of GLSL do fragment shader outputs simply by declaring them as out values, and gl_FragColor is no longer supported, hence your error. Try this: out vec4 fragColor; void main() { fragColor = vec4(1.0, 0.0, 0.0, 1.0); } Note that gl_FragDepth hasn't changed and is still available. For more information see https://www.opengl.org/wiki/Fragment_Shader The predefined variable gl_FragColor does not exist anymore in GLSL

Why is a texture coordinate of 1.0 getting beyond the edge of the texture?

本秂侑毒 提交于 2019-12-01 13:01:27
问题 I'm doing a color lookup using a texture to apply an effect to a picture. My lookup is a gradient map using the luminance of the fragment of the first texture, then looking that up on a second texture. The 2nd texture is 256x256 with gradients going horizontally and several different gradients top to bottom. So 32 horizontal stripes each 8 pixels tall. My lookup on the x is the luminance, on the y it's a gradient and I target the center of the stripe to avoid crossover. My fragment shader