I am a beginner in OpenGL, trying to run some tests. There are plenty of fragment shaders available at GLSL Sandbox Gallexy, and I would like to try them in GLES, reusing the code. But, for most of the shaders, it does not seem to work.
Among the shaders I tried to run, the only one that worked in GLES is this one, for some reason. And I had to eliminate the time dependence of the shader, in order to accomplish that.
It seems that some variable names are different in WebGL and GLES. If that's the case, which ones, exactly? If not, what exactly is the procedure of translation from the former to the later?
One example of simple fragment shader that gives a black screen only. In my particular case, I am running it along this minimal vertex shader:
precision mediump float;
uniform mat4 uMVPMatrix;
attribute vec4 aPosition;
attribute vec2 aTextureCoord;
varying vec2 vTextureCoord;
void main() {
vTextureCoord = aTextureCoord;
gl_Position = uMVPMatrix * aPosition;
}
#version 100
, it is generally just a stricter version of ESSL. The one exception would be shaders that usewebgl_
constructs, but this is just a reserved namespace with no actual use at the moment. The compiler has stricter requirements, and in fact most browsers use the ANGLE project's GLSL validator to produce consistent results across multiple platforms. However, there should be no need to translate shaders; this assumes you are discussing OpenGL ES 2.0 (it is not clear by your tags if you mean 2.0 or 3.0). – Andon M. Coleman#version 100
plus some additional WebGL-only restrictions. Porting from ES 2.0 to WebGL may require additional work, but because ES 2.0 is less restrictive the other way around should not be a problem. I might be able to offer some more insight if you pointed out some actual shaders that do not work and what you tried. – Andon M. Coleman