+1 vote


I have a 256x256 Texture created in gdscript filled red.

dynImage.create(256,256,false,Image.FORMAT_RGBAF)  // I tried different formats

I now set one pixel to black


for i in range(1): //I tested with bigger ranges, it gets darker
    for i2 in range(1):

make a ImageTexture and "send" it to the shader


in the shader I try to access this pixel.

shader_type canvas_item;

uniform sampler2D myTexture : hint_black;
void fragment(){

        COLOR = texture(myTexture,vec2(0,0));
        COLOR = texture(myTexture,vec2(0.1,0.1));

To test if it still has the color black I tried this:

    COLOR = vec4(0,1,0,1);

What I receive is this.

If I change the range for i,i2 to 30 it is a black and get's green by the test.

I tried to acess the pixel in the gdscript with getpixel -> still black as expected

Since I am more or less new to this stuff, I guess I missunderstand something.
My guesses would be, that there is some kind of image compression, I don't know how to turn off.

What I want to do is to send raw image data to the shader and read the color pixel by pixel afterwards.

I am using Godot 3.1, if that is of importance.

Maybe someone can point out my mistake.

Thank you in advance

in Engine by (13 points)

I'm glad I found this web site, I couldn't find any knowledge on this matter prior to. Also, operate a site and if you are ever interested in doing some visitor writing for me if possible feel free to let me know, I'm always looking for people to check out my web site.
geometry dash

1 Answer

+1 vote

I have done some shader stuff but I'm not sure about detais with Godot.. what kind of settings there are etc.
Anyway, it looks like shader is doing bilinear sampling with the texture, if you take sample/color from vec2(0.1,0.1) it might sample also little bit neighbor pixel.. usually if you want hard color borders then sampling must be set something like GL_NEAREST (or whatever is used in Godot) Or somehow texture is automaticly mip-mapped and thus blurred..

by (38 points)

Thank you, you are right. It seems to be how I create the ImageTexture.
This works as I expect it.








alone or in combination, returns to the pervious "unwanted" effect, only all three


return to the "unwanted" result.
Maybe something interessting to investigate.

Still thank you, now I can go on to find out, if I can implement my idea.

It is a little offtopic to the original post. But in addition I found out you can access the pixle in the shader with.


opposit to someting like




If someone is likeminded then me, I hope it helps.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.