Skip to content

Instantly share code, notes, and snippets.

@MateSteinforth
Created June 7, 2022 13:59
Show Gist options
  • Select an option

  • Save MateSteinforth/fcd1ae776720f730f0a7c3276cef8a7b to your computer and use it in GitHub Desktop.

Select an option

Save MateSteinforth/fcd1ae776720f730f0a7c3276cef8a7b to your computer and use it in GitHub Desktop.
//==============================================================================
// 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