#Creating screen reading shader with SCREEN_PIXEL_SIZE not working, alternative solution?

1 messages · Page 1 of 1 (latest)

ancient prairie
#

When I'm zoomed into the space the shader is working on, the shader works as intended but when I zoom out it expands and distorts

#

right picture is when I zoom out

#

I'm having the same issue trying to create a drop shadow

wide topaz
#

well, the shader is applied per pixel right?

#

how big are the pixels when you zoom out?

ancient prairie
#

My game is rendered at 1920x1080, in game it looks wrong. I just don't understand how it works really

wide topaz
#

you mean how shaders work?

#

For canvas_item shaders, when you set the COLOR in the fragment function, you are setting it for one pixel

ancient prairie
#

No how I get it to render properly in the right position

wide topaz
#

oh ok

#

Did you use another shader as reference?

ancient prairie
#

I have been looking up how to make a pixel outline shader and I get how it works, but it doesn't work when I'm sampling the texture on the screen instead of having some texture from memory

wide topaz
#

Oh, you're using a screenreading shader?

ancient prairie
#

Yes

#

For the text in my game

wide topaz
#

I'm not sure there would be transparency in the texture from a screen-reading shader

ancient prairie
#

No there isn't, that's why I make the text pink

#

And check to see if the pixel is pink

#

The outline works as shown in the picture the problem is the zooming

#

And rendering properly for the resolution

wide topaz
#

let me try the shader

#

well that's not good

ancient prairie
#

Lmao

wide topaz
#

your text is pink right?

ancient prairie
#

Yeah vec4(0.0,1.0,0.0,1.0)

wide topaz
#

that's green

ancient prairie
#

Oh wait

#

I'm confused

#

Yes the tect is pink hold on

wide topaz
#

I think you mean that it's checking the distance from green

#

pink is the opposite of green

ancient prairie
#

Well that would explain it

wide topaz
#

anyway i will go through the shader code

#

Why do you multiply the pixel size by 8?

#

current_pixel = texture(_texture, uv_coord + DIRECTIONS[i] * pixel_size*8.0);

ancient prairie
#

When people make the shader that is the pixel thickness in their shaders

wide topaz
#

But the pixel thickness is already "pixel_size"

ancient prairie
#

Ok I'll try without it

#

Aaaaah

#

Sick

#

I'm having trouble doing the same thing with a shadow shader but I'll keep this in mind when I'm having the issue

wide topaz
#

okay 👍

ancient prairie
#

Thank you so much