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

Launch with file that doesn't have .frag extension #352

Open
danielchasehooper opened this issue Nov 24, 2023 · 2 comments
Open

Launch with file that doesn't have .frag extension #352

danielchasehooper opened this issue Nov 24, 2023 · 2 comments

Comments

@danielchasehooper
Copy link

we have some existing shaders in our repo that don't have the .frag extension that we would like to view in glslviewer, is there a way to launch it from the command line without cping to a tmp file with the .frag extension? When you do this you don't get hot reloading for the original file

@patriciogonzalezvivo
Copy link
Owner

patriciogonzalezvivo commented Nov 26, 2023

hi @danielchasehooper! For context we use .frag or .fs to distinguish fragment shaders from vertex shader (.vert or .vs). Files with .glsl extensions are a bit ambiguous, that's why usually you see them when they are part of libraries like on https://lygia.xyz.

Solution, you could create file pairs that include the .glsl counter part. For example:

shader.glsl

uniform vec2 u_resolution;
uniform float u_time;
void main() {
   vec4 color = vec4(0.0,0.0,0.0,1.0);
   vec2 uv = gl_FragCoord.xy/u_resolution;
   ...
   gl_FragColor = color;
}

shader.frag

#include "shader.glsl"

This way:

  1. you don't have duplicate files
  2. glslViewer can track the changes of the original .glsl file
  3. the .frag pairs can be easily generated programatically

@danielchasehooper
Copy link
Author

danielchasehooper commented Nov 26, 2023

we don't use the glsl extension, #include doesn't seem to work if the file doesn't have a glsl extension

It'd be useful if glslviewer had something like a --frag param so that you can launch it like so:
glslviewer --frag shaderFileName and it works with any extension.

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