glsl shader texture atlas
shader
#version 320 es
precision highp float;
in vec2 TexCoord;
out vec4 FragColor;
// texture sampler
uniform sampler2D texture_diffuse1;
uniform vec2 textureOffset;
void main()
{
vec2 position = vec2(4.0/8.0, 1.0/8.0);
vec2 size = vec2(1.0/8.0, 1.0/8.0);
// 计算1,显示清晰
vec2 uv = position + size * fract(TexCoord);
FragColor = texture(texture_diffuse1, uv);
// 计算2, 显示模糊
vec2 dx = dFdx(TexCoord);
vec2 dy = dFdy(TexCoord);
vec2 uv = position + size * fract(TexCoord);
FragColor = textureGrad(texture_diffuse1, uv, dx, dy);
}
参考
原文地址:https://blog.csdn.net/qq_16740151/article/details/144317277
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!