stevensona/shader-toy

Relative path resolution when including files

Closed this issue · 4 comments

tosyu commented

Hello,

I have encountered an issue with path resolution. The problem is as follows

I have my main.glsl fragment shader in the root folder and all my dependancies in deps folder

project/
   ├ deps/
   |   ├ dep1.glsl
   |   └ dep2.glsl
   └ main.glsl

my main.glsl has a line

#include "./deps/dep1.glsl"

and my dep1.glsl has a line

#include "./dep2.glsl"

and I get an error that dep2.glsl cannot be found, but when I prepend "./deps" to the path so the line in dep1.glsl looks like

#include "./deps/dep2.glsl"

everything works fine.

It's a minor issue but gets in the way of having some shared resources in multiple projects without copying them each time (as the paths will be different)

Thanks for reporting the issue and sorry for the slow reply. I blame the holidays 👅
I'm currently in the process of completely rewriting the parsing of glsl files and have noticed the issue as well. My plan was to continue supporting current behaviour, i.e. looking for files in open directories, but prioritising files found relative to the current file. I'll also remove the necessity of including the './' in the beginning so we're more standard in how we treat file paths. I hope to be done with my work sometime next week. Let me know if you see any other issues regarding file paths and I'll do my best to include that in my work.

tosyu commented

Well, the other issue I noticed is that changing the code in the dependencies does not refresh the preview, but again, for me it's a minor inconvenience :)

It's still a relevant problem, so should be fixed imho. I'll create a separate issue for it :)

tosyu commented

Thank you :)