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);
	
}

参考

相关推荐
山楂树の2 小时前
ImageBitmap 将图像数据转换为GPU可用的纹理
性能优化·图形渲染·canva可画
BoBoZz193 小时前
MarchingCases marchingcubes算法15种情况的展示
python·vtk·图形渲染·图形处理
BoBoZz194 小时前
SmoothDiscreteMarchingCubes 多边形网格数据的平滑
python·vtk·图形渲染·图形处理
郝学胜-神的一滴7 小时前
Separate Buffer、InterleavedBuffer 策略与 OpenGL VAO 深度解析
开发语言·c++·程序人生·算法·游戏程序·图形渲染
成都渲染101云渲染66661 天前
C4D 云渲染平台哪个好?价格、速度、稳定性全网真实对比(含渲染101)
ue5·图形渲染·blender·maya·houdini
郝学胜-神的一滴1 天前
深入理解OpenGL VBO:原理、封装与性能优化
c++·程序人生·性能优化·图形渲染
BoBoZz191 天前
Hello 隐式建模
python·vtk·图形渲染·图形处理
明洞日记1 天前
【VTK手册024】高效等值面提取:vtkFlyingEdges3D 详解与实战
c++·图像处理·vtk·图形渲染
DeltaTime1 天前
一 图形学概述, 线性代数
c++·图形渲染
成都渲染101云渲染66661 天前
Blender 云渲染平台实测对比:iRender、GarageFarm、渲染101 哪家更适合动画云渲染?
ue5·图形渲染·blender·maya·houdini