Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/FlexYourBrain/sample_2d_water_reflection
Water effect sample project for the defold game engine.
https://github.com/FlexYourBrain/sample_2d_water_reflection
Last synced: 4 months ago
JSON representation
Water effect sample project for the defold game engine.
- Host: GitHub
- URL: https://github.com/FlexYourBrain/sample_2d_water_reflection
- Owner: FlexYourBrain
- Created: 2024-02-04T23:23:13.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-03-04T19:43:06.000Z (11 months ago)
- Last Synced: 2024-03-05T16:00:11.288Z (11 months ago)
- Language: Lua
- Size: 183 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-defold - Water reflection effect
README
# Water reflection effect
[Play the Demo](https://flexyourbrain.itch.io/water-effect)
This project showcases a 2d reflective water effect in the defold game engine.
what's needed to create this effect?
- Capture the active play area and display it mirrored in another part of the screen.
- create a water like shader effect that will be applied to the reflection.
- make the shader effect scroll.How is that done?
- A render target and render predicate is created in the renderscript for the effect.
- A view of the play area is set when drawing to the render target then reset.
- Custom material with vertex and fragment programs are created and rendertarget texture is bound to it.
- A custom quad is created that has its UV's rotated 180 degrees and is flipped in the U axis to give it the mirrored effect by default so no extra work need's to be done in the shader or the engine.
- Distortion textures red and green channel is used to offset the texels that will be drawn creating the water effect.
- a material constant is created and used in the shader to scroll uv's. go.animate is used to animate the value between 0.0 and 1.0That's all.
Check out [the documentation pages](https://defold.com/learn) for examples, tutorials, manuals and API docs.
Need help? ask questions in [The forum](https://forum.defold.com) and/or join the defold discord server.
---
Art Credit : Agustin R.