Open blackears opened 6 months ago
This happens in other contexts too when I try to load glsl shaders as @tool
and use them in the editor. Sometimes they're imported as TextFile and break the logic. This error does not happen when I run the same code as a program.
In the MRP this works
Same for me, can't reproduce it. Maybe there are other conditions affect it as well.
Do you by chance have the .GLSL file open in the script editor in your main project, but not in your MRP?
I think you're right. The error seems to occur when the glsl shader is open in the text editor.
@blackears you can try add ResourceLoader.CACHE_MODE_IGNORE
to your ResourceLoader.load
and see if it fixes the problem.
After some quich check I think maybe it's because the default flag CACHE_MODE_REUSE
, when the glsl file is loaded by script editor it's recognized as a text file and get cached, so if you load again it uses the cache one, which is a textFile.
Tested versions
4.2 stable
System information
Windows 10 Mobile
Issue description
For some reason, RDShaderFile .glsl file resources are sometimes being loaded as TextFile. The Import window lists them as GLSL Shader Files and .import files list them as being RDShaderFile. And everything is working fine in the test project I assembled too. However, in my main project I keep getting the error
Steps to reproduce
Unfortunately I cannot consistently reproduce this and my MRP doesn't reproduce it at all, but I'm doing exactly the same things as my main project. I'm selecting my "my_glsl_program.tres" resource, clicking on the Shader Source parameter in the Inspector, browsing to one of my GLSL resource files and pressing Enter. In the MRP this works, but in my main program half the time this returns a RDShaderFile and half the time it returns a TextFile with the same file sometimes loading as one and sometimes as the other.
Minimal reproduction project (MRP)
load_shader_bug.zip