Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do WebGL and OpenGL use the same shading language?

Is the shader language for WebGL the same as that for OpenGL? In other words, if I write a shader for WebGL will it be fully compatible with OpenGL?

I do not want to purchase a book about OpenGL Shading Language if it is not going to work for WebGL.

like image 646
oabarca Avatar asked Apr 07 '14 17:04

oabarca


People also ask

What shader language does WebGL use?

WebGL 2D/3D Programming and Graphics Rendering For The Web Shaders are written in OpenGL ES Shader Language (known as ES SL).

How similar is WebGL to OpenGL?

WebGL is based on OpenGL ES, which lacks the many features that regular OpenGL is having, like it supports only vertex and fragment shaders. OpenGL has features that are not in WebGL like geometry shaders, tessellation shaders, and compute shaders. WebGL is mainly used for browsers.

Does WebGL use shaders?

As mentioned in how it works WebGL requires 2 shaders every time you draw something. A vertex shader and a fragment shader. Each shader is a function.

Does WebGL use GLSL?

WebGL 1.0 only supports GLSL 1.0. 17. (Remember that WebGL is based on OpenGL ES 2.0, which was designed for computing devices with low power and limited processing.)


1 Answers

WebGL itself is more closely related to GLES2.0 than to desktop GL and thus uses the same shading language as ES2: The OpenGL ES Shading Language 1.0. This is somewhat similiar to the early desktop GLSL versions (like GLSL1.10 or 1.20 which were current at the time of GL2.x), but more limited. So buying a book about desktop GLSL might not be the best choice, you might want to look specifically for GLES ones.

like image 62
derhass Avatar answered Sep 20 '22 19:09

derhass