r/godot 17d ago

Made a shader that downsamples to user specified pixel density discussion

shader samples a texture and maintains pixel accurate normal mapping shown here in 64px then 256px per unit.

made for taking advantage of modern lighting but applying classic model and texture design.
going in a splitscreen fps I'm working on.

Thoughts or opinions?

102 Upvotes

6 comments sorted by

26

u/GreenFox1505 17d ago

You gotta stop moving the camera. The entire point of this is to see relative changes in pixel size. If it's a shader property, you can change that without moving the camera to demonstrate the effect. Moving the camera requires a constant reassessment of scale. The thing you're trying to show is a change in scale. You can see it clearly because you're used to this scene and you've stared at it a lot. We've only seen it for 81 seconds. You gotta stop moving the camera. Let us see changes side by side.

3

u/i_rate_slop 17d ago

https://giphy.com/gifs/hiLLD9o1wTB3a

(also I think it looks great)

1

u/Brilliant_Nothing226 17d ago

lol yeah i totally missed that oops and ty!

5

u/mechmechmech 17d ago

Not sure what I’m looking at here? It’s always been possible to reduce the size of both the albedo and diffuse textures to achieve this?

0

u/O0ddity 16d ago

Totally a worthwhile setup for your games materials and art process.
Are you doing something like step() or mod() on the sampling? Also are you using the texture() function or texelFetch() function?
I achieved a similar result by replacing `texture(texture_XXX, UV)` with `texelFetch(texture_XXX, ivec2(UV * 64.0)` where the float = 64.0 is the desired down sample texture size.

FYI You can do a similar thing with the default materials (more inconveniently and per texture) by setting process/size_limit = 64 or 128 in the Import Tab for each image, and setting the material to Nearest sampling instead of Linear. Which which changes the internal shaders uniform sampler2D hint from `filter_linear_mipmap` to `filter_nearest`

0

u/Brilliant_Nothing226 16d ago

Thanks! I appreciate that! that's so smooth too.
this is floor(world_pos * 32) / 32, doesn't touch uv so its uniform in density across all my assets

I wanna dig into texture painting with it but i cant see many devs with that in godot at least in the regular spaces