Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MIME type for shader code

Is there any kind of established MIME type for OpenGL shader program source code? I know that the official IANA table doesn't seem to mention one such, so it would have to be some experimental (x-…) or some vendor-specific (vnd.…) subtype, probably of the text/… main type. According to What is the correct file extension for GLSL shaders? there doesn't even seem to be an established file name extension for these, but that's a quite separate problem to me.

Background:
I sometimes want to include shader code in a <script> tag for some WebGL application, and I want to write the type= attribute of that tag in a way which is semantically as reasonable as possible, even though at the moment I can't think of any actuall difference such a choice would make (unless I call it text/javascript or something similarly stupid). But nevertheless, it would be nice to be already conforming to any tools which might develop over time, building on currently established standards that I don't know about yet.

like image 839
MvG Avatar asked Mar 09 '15 16:03

MvG


2 Answers

The draft glTF standard written by Khronos states to use text/plain for GLSL files.

like image 62
Jephir Avatar answered Sep 21 '22 16:09

Jephir


The following site explains in greater detail how to add a custom MIME type: https://www.xsofthost.com/help/add-and-delete-mime-type-within-cpanel/

At this link, Krhonos docs state:

File Extension and MIME Type

External shader files may have any extension. The preferred MIME type is text/plain.

(However, I still see errors in Chrome and Edge with shader files - specifically, "Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec." vertex.glsl:1 )

like image 42
phil1008 Avatar answered Sep 20 '22 16:09

phil1008