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

Freeman_ReignsFreeman_Reigns Posts: 24Member

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?

Thanks

Comments

  • MegalomaniakMegalomaniak Posts: 2,649Admin

    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: 24Member

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

  • MegalomaniakMegalomaniak Posts: 2,649Admin

    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: 24Member

    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,649Admin

    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,649Admin

    Ok, think this is along the lines of what you wanted:
    https://drive.google.com/file/d/1NXBAMqFeSdZnWw2709VsmTleHRwRHlM0/view?usp=sharing

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

  • Freeman_ReignsFreeman_Reigns Posts: 24Member

    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,649Admin

    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

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file