admin管理员组文章数量:1396092
Hey I'm using GLSL Shader inside Godot, I "glued" these 2 shaders. One "pixelate" the TEXTURE on its local UV space and one displace thevertex in a sinusoid shape with TIMe (much like a "wind effect")
But the displacement of the vertex()
method apply after the pixelisation of the fragment()
I would like to pixelate after the displacement. Maybe in the screen space ? but I only want this texture to be pixelated not what is underneath (it's a png partly transparent).
How can I achieve this ?
shader_type canvas_item;
uniform float size_x = 16.0; // blocks by x direction
uniform float size_y = 16.0; // blocks by y direction
uniform float wave_speed = 1.0;
uniform float wave_amplitude = 8.0;
void fragment() {
COLOR = texture(TEXTURE, vec2(floor(UV.x * size_x) / (size_x - 1.0), floor(UV.y * size_y) / (size_y - 1.0)));
}
float getWind(vec2 vertex, vec2 uv, float time) {
return sin(time + uv.y) * wave_amplitude;
}
void vertex() {
vec4 pos = WORLD_MATRIX * vec4(0.0, 0.0, 0.0, 1.0);
float time = TIME * wave_speed;
VERTEX.x += getWind(VERTEX.xy, UV, time);
}
本文标签: glslHow to apply fragment transformation after vertex transformationStack Overflow
版权声明:本文标题:glsl - How to apply fragment transformation after vertex transformation - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744104833a2591017.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论