actarian / vscode-glsl-canvas

Live WebGL preview of GLSL shaders
MIT License
335 stars 25 forks source link

issues with loading textures #68

Open bencresty opened 2 years ago

bencresty commented 2 years ago

Hi,

Not sure if this is an issue or something has changed in later versions, but according to an older issue here: https://github.com/actarian/vscode-glsl-canvas/issues/45 we should be able to load textures from within the settings json relatively to the project root by starting with a dot.

However, when doing this it doesn't work and throws a texture error. So this does not work:

"glsl-canvas.textures": {
        "0": "./src/assets/img/texture.png",
}

However, when doing it like this it IS working though:

"glsl-canvas.textures": {
        "0": "src/assets/img/texture.png",
}

[edit] Okay, I was wrong. It turned out even without dot it doesn't work. I found one texture online that for some reason works, but every other texture I use just fails. No matter if it's served from relative file with or without dot notation, or via http locally or remote, or even when served from https.

VS Code directly recognises the images I use by showing the image in the gutter, but this extension just doesn't seem to work with textures as how it should work. No matter what I try.

Also when switching to Kodelife instead of VS Code with this extension all textures tried immediately work without any issue. So there's definitely nothing wrong with the textures I'm using.

I tried both setting the textures from within the settings.json (inside the project) as well as via the inline comment. Nothing seems to work and texture errors keep appearing.

I give up now. This is taking me way too much time now. Textures don't seem to work on this extension unfortunately. At least not as described.

vscode-glsl-canvas: 0.2.14

pabluch commented 2 years ago

@bencresty rolling back to 0.2.11 solved the issue for the moment for me

nzhddemian commented 2 years ago

I was able to load texture only from rawgit link like this
"glsl-canvas.textures": { "0": "https://rawgit.com/actarian/plausible-brdf-shader/master/textures/noise/cloud-1.png", }

Wambosa commented 1 year ago

I was also able to get a texture loaded, but it had to be my user settings.json and not the workspace settings.json. I then had to include the workspace folder in the path with a ../ in order to get it to load.

ex:

    "glsl-canvas.textures": {
        "0": "../steelpinion.com/static/img/def/ms-henri.jpeg"
    },

The error here was from before when I tried using an absolute path or various other relative paths compared to the shader file or workspace. image

source code

#version 300 es
precision mediump float;

uniform sampler2D u_texture_0;
uniform float u_time;
uniform float u_redness;

in vec2 v_texcoord;
out vec4 fragColor;

void main() {
    vec4 spriteColor = texture(u_texture_0, v_texcoord);
    vec4 color = vec4(spriteColor.r + u_redness, spriteColor.g, spriteColor.b, spriteColor.a);
    fragColor = color;
}