Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use glsl version 3.00 #65

Open
smkplus opened this issue Mar 19, 2020 · 1 comment
Open

How to use glsl version 3.00 #65

smkplus opened this issue Mar 19, 2020 · 1 comment

Comments

@smkplus
Copy link

smkplus commented Mar 19, 2020

image

I tried #version 300 es this but didn't work
http://www.shaderific.com/blog/2014/3/13/tutorial-how-to-update-a-shader-for-opengl-es-30

#ifdef GL_ES
precision mediump float;


#endif

uniform vec2 u_resolution;
uniform float u_time;

void main(){
    vec2 st = gl_FragCoord.xy/u_resolution.xy;
    gl_FragColor = vec4( 1 & 2);
}

@smkplus smkplus changed the title How to use glsl version 3.0 How to use glsl version 3.00 Mar 19, 2020
@Larphoid
Copy link

Larphoid commented May 10, 2021

You can include #version 300 es at the top of your shader. This means that you'll have to rewrite your shaders accordingly.
Moreover, if you don't provide your own vertex shader, then you would also need to edit dist/GlslCanvas.js.
Find this.vertexString = contextOptions.vertexString || and the string at the end should be replaced with something like:
'#version 300 es\n#ifdef GL_ES\nprecision mediump float;\n#endif\n\nin vec2 a_position;\nin vec2 a_texcoord;\n\nout vec2 v_texcoord;\n\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n v_texcoord = a_texcoord;\n}\n'.
In your fragment shader you can still access gl_FragCoord as usual, but gl_FragColor should now be fragColor if you put out vec4 fragColor; after your # defines. This works for me !

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants