Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using GLSL 3 ES with three.js

Has anyone been successful in using GLSL 3 ES shaders with three.js library? From what I know it is impossible for latest revision (r68) beacuse one can't even set a directive (which is required, and has to be before anything else in shader code):

#version 300 es 

beacause of prefix that is added to each shader by three.js.

Does anyone knows any solution to that problem? Would it be enough to change the three.js code to append the directive on the begining of the threejs shader prefix?

like image 594
Xyz Avatar asked Aug 23 '14 13:08

Xyz


People also ask

Does Three Js use OpenGL?

Three. js uses the WebGL engine in the browser for rendering scenes. The API is based on OpenGL (GL stands for graphics library), a desktop graphics API.

Does WebGL use GLSL?

WebGL require a shader program for the vertex and fragment manipulation sections of the graphics pipeline. A shader program are written in GLSL (Graphics Library Shader Language).

What is a shader in three Js?

A material rendered with custom shaders. A shader is a small program written in GLSL that runs on the GPU.

How do I run 3 JS locally?

Just point it at the folder where you unzipped the files, click "Start", then go to in your browser http://localhost:8080/ or if you'd like to browse the samples go to http://localhost:8080/threejs .


1 Answers

Three.js uses WebGL, which is available in web browsers, not GLES, which is a variant of OpenGL for mobile devices. While it is true that WebGL is itself closely related to GLES2, it is still a different thing. And currently, there only exists WebGL 1.0. Maybe future version will be more related to GLES3, but currently, no WebGL implementation will support ES 3 shaders.

like image 191
derhass Avatar answered Sep 20 '22 01:09

derhass