This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

Shader for pixel art that doesn't warp the pixels?

Freeman_ReignsFreeman_Reigns Posts: 20Member

Hi everyone.

Is it possible to make a shader that doesn't warp my sprites, in the sense that the pixels remain the same size and shape?

Basically, I'm looking to create a water reflection effect that looks like it was animated with frames, with the pixels moving position slightly, at different speeds, and then back again, to give a ripple effect. Can I do this with shaders or will I need to animate this?



  • MegalomaniakMegalomaniak Posts: 2,580Admin

    I think floor/ceil/rounding the pixel positions might give you what you want, if I understood what you want correct.

  • Freeman_ReignsFreeman_Reigns Posts: 20Member

    I guess I'll give it a try. Do you have an example of some basic code I could use?

  • MegalomaniakMegalomaniak Posts: 2,580Admin

    Not at hand, no. If you better explained what exactly you wanted I might be able to whip something up perhaps, but I'm not psychic.

  • Freeman_ReignsFreeman_Reigns Posts: 20Member

    Sorry if my explanation was strange. My idea is something that will move the pixels slightly from side to side, but not all at once, more like in horizontal layers/lines going across the sprite. Like splitting it, you could say.

  • MegalomaniakMegalomaniak Posts: 2,580Admin

    So like using a waveform to displace the texture coordinates? Shouldn't be too hard. I'll mull it over and will try and see if I can't build a simple example sometime tomorrow.

  • MegalomaniakMegalomaniak Posts: 2,580Admin

    Ok, think this is along the lines of what you wanted:

    Posted earlier but then realized I missed a thing, hopefully that's it though.

  • Freeman_ReignsFreeman_Reigns Posts: 20Member

    Thank you very much. I'm likely doing something wrong, but I can't figure out how to implement it in my game. I suppose it isn't as simple as copying the code to my sprite's shader and adding those water textures? Sorry for the newbie questions.

  • MegalomaniakMegalomaniak Posts: 2,580Admin

    No, it isn't. And this was just an example. I am creating a gradient basically from scratch there that acts as a mask for one of the textures over the other. Some variables are currently hard-coded in there. Otherwise you'd have to add some uniforms and then override those uniform variables and control them from script external to the shader.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.