glsl shader texture atlas

shader

glsl 复制代码
#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);
	
}

参考

相关推荐
还下着雨ZG2 天前
2 VTK的基本概念
图形渲染
魏无忌2 天前
BIM+GIS尝试
图形渲染·webgpu·bim引擎·bim+gis
Renderbus瑞云渲染农场3 天前
跨平台渲染不再难_瑞云渲染跨平台转移+克隆双功能上线,效率升级
3d·图形渲染
水星梦月6 天前
跨平台开发中的图形渲染:Canvas与View+CSS的性能分析与决策路径
前端·css·图形渲染·canvas
郝学胜-神的一滴7 天前
Cesium绘制线:从基础到高级技巧
前端·javascript·程序人生·线性代数·算法·矩阵·图形渲染
WaWaJie_Ngen8 天前
【OpenGL】模板测试(StencilTest)
c++·算法·游戏·游戏引擎·游戏程序·图形渲染
郝学胜-神的一滴10 天前
矩阵的奇异值分解(SVD)及其在计算机图形学中的应用
程序人生·线性代数·算法·矩阵·图形渲染
jiuzhouhi12 天前
Multiple Cameras Camera Blending and Rendering Layers
图形渲染
郝学胜-神的一滴13 天前
计算机图形学中的光照模型:从基础到现代技术
开发语言·c++·程序人生·图形渲染
玖釉-17 天前
三维模型数据结构与存储方式解析
数据结构·算法·图形渲染