设为首页 加入收藏

TOP

GLSL变换颜色的三角形(C语言)(三)
2014-11-23 18:02:55 来源: 作者: 【 】 浏览:30
Tags:GLSL 变换 颜色 三角形 语言
uniform float loopDuration; uniform float time; void main() { float timeScale = 3.14159f * 2.0f / loopDuration; float currTime = mod(time, loopDuration); vec4 totalOffset = vec4(cos(currTime * timeScale) * 0.5f, sin(currTime * timeScale) * 0.5f, 0.0f, 0.0f); gl_Position = vec4(vertexPosition,1.0) + totalOffset; }
triangle.frag

#version 400


out vec4 fragColor;

uniform float fragLoopDuration;
uniform float time;

const vec4 firstColor =vec4(1.0f, 0.0f, 0.0f, 1.0f);
const vec4 secondColor =vec4(0.0f, 1.0f, 0.0f, 1.0f);

void main(){
	float currentTime =mod(time, fragLoopDuration);
	float currentLerp =currentTime/fragLoopDuration;


	fragColor =mix(firstColor, secondColor, currentLerp);

 }


首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇object-c基本知识 下一篇C语言函数返回值不能直接写数组

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: