What I want:
<script src="shader.glsl" type="x-shader/x-fragment"></script>
<script src="shader.glsl" type="x-shader/x-vertex"></script>
or:
<script src="shader.frag" type="x-shader/x-fragment"></script>
<script src="shader.vert" type="x-shader/x-vertex"></script>
So I have 2 simple shader types:
type=x-shader/x-fragment
precision mediump float; void main(void) { gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); }
type=x-shader/x-vertex
attribute vec3 aVertexPosition; uniform mat4 uMVMatrix; uniform mat4 uPMatrix; void main(void) { gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0); }
The shaders come from this WebGL tutorial
- Can I add these 2 types in one
.glsl
? If not are their other file formats for the shader types like:
.vert
.frag
Q: For what do I want to use this?
A: Dynamically loading my files from JavaScript and insert it to my HTML file.
Q: Do you want to know how to load dynamically files?
A: No that is irrelevant to the question "load GLSL file (WebGL) in HTML?"
Q: What do you want then?
A: Look at the What I want at the start of the question.
Q: Do you want to share your JavaScript import code?
A: Yes but I think that is irrelevant information to be able to answer the question