Created
October 5, 2023 11:11
-
-
Save michaliskambi/2e36aa749f7d3ec7bd86c374d6bb23f3 to your computer and use it in GitHub Desktop.
Shader adding a mask over another texture, modifed Kagamma example
This file contains 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
#X3D V4.0 utf8 | |
PROFILE Interchange | |
Shape { | |
appearance Appearance { | |
material UnlitMaterial { | |
} | |
texture ImageTexture { | |
url "texture.png" | |
textureProperties TextureProperties { | |
magnificationFilter "NEAREST_PIXEL" | |
minificationFilter "NEAREST_PIXEL" | |
} | |
} | |
effects Effect { | |
language "GLSL" | |
initializeOnly SFNode mask_texture ImageTexture { | |
url "mask.png" | |
textureProperties TextureProperties { | |
magnificationFilter "NEAREST_PIXEL" | |
minificationFilter "NEAREST_PIXEL" | |
} | |
} | |
parts EffectPart { | |
type "FRAGMENT" | |
url "data:text/plain, | |
uniform sampler2D mask_texture; | |
void PLUG_texture_color(inout vec4 texture_color, const in sampler2D texture_in, const in vec4 tex_coord) { | |
float alpha = texture2D(mask_texture, tex_coord.st).r; // r=g=b so pick one... | |
texture_color = vec4(texture_color.xyz, alpha); | |
}" | |
} | |
} | |
} | |
geometry IndexedFaceSet { | |
solid FALSE | |
coord Coordinate { point [ -0.5 -0.5 0, 0.5 -0.5 0, 0.5 0.5 0, -0.5 0.5 0 ] } | |
texCoord TextureCoordinate { point [ 0 0, 1 0, 1 1, 0 1 ] } | |
coordIndex [ 0 1 2 3 ] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment