Created
June 7, 2022 13:59
-
-
Save MateSteinforth/fcd1ae776720f730f0a7c3276cef8a7b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //============================================================================== | |
| // Simple Displacement Shader | |
| // make sure to add 'Vertex Texture Fetch' to Capabilities | |
| //============================================================================== | |
| void main(optional<std::Texture2d> displace, optional<std::Texture2d> tex, float depth, out vec4 Color, out vec4 Position) { | |
| vec2 uv = std::getVertexTexCoord(); | |
| vec4 texturePos = displace.sampleLod(uv, 0.0).valueOr(vec4(1.0)); | |
| vec4 outPosition = std::getVertexPosition() + vec4(std::getVertexNormal()*texturePos.rgb*depth, 0.0); | |
| Color = tex.sampleLod(fragment(uv), 0.0).valueOr(vec4(1.0)); | |
| Position = std::getModelViewProjectionMatrix() * outPosition; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment