Opengl超级宝典 第七章CubeMapped着色器部分编译错误
来源:互联网 发布:网络语不二臣 什么意思 编辑:程序博客网 时间:2024/06/05 15:44
SkyBox 的着色器
// Skybox Shader
// Vertex Shader
// Richard S. Wright Jr.
// OpenGL SuperBible
#version 120
// Incoming per vertex... just the position
attribute vec4 vVertex;
uniform mat4 mvpMatrix; // Transformation matrix
// Texture Coordinate to fragment program
varying vec3 vVaryingTexCoord;
void main(void)
{
// Pass on the texture coordinates
vVaryingTexCoord = normalize(vVertex.xyz);
// Don't forget to transform the geometry!
gl_Position = mvpMatrix * vVertex;
}
// Skybox Shader
// Fragment Shader
// Richard S. Wright Jr.
// OpenGL SuperBible
#version 120
uniform samplerCube cubeMap;
varying vec3 vVaryingTexCoord;
void main(void)
{
gl_FragColor = textureCube(cubeMap, vVaryingTexCoord);
}
Reflection的着色器
// Reflection Shader
// Vertex Shader
// Richard S. Wright Jr.
// OpenGL SuperBible
#version 120
// Incoming per vertex... position and normal
attribute vec4 vVertex;
attribute vec3 vNormal;
uniform mat4 mvpMatrix;
uniform mat4 mvMatrix;
uniform mat3 normalMatrix;
uniform mat4 mInverseCamera;
// Texture coordinate to fragment program
varying vec3 vVaryingTexCoord;
void main(void)
{
// Normal in Eye Space
vec3 vEyeNormal = normalMatrix * vNormal;
// Vertex position in Eye Space
vec4 vVert4 = mvMatrix * vVertex;
vec3 vEyeVertex = normalize(vVert4.xyz / vVert4.w);
// Get reflected vector
vec4 vCoords = vec4(reflect(vEyeVertex, vEyeNormal), 1.0);
// Rotate by flipped camera
vCoords = mInverseCamera * vCoords;
vVaryingTexCoord.xyz = normalize(vCoords.xyz);
// Don't forget to transform the geometry!
gl_Position = mvpMatrix * vVertex;
}
// Reflection Shader
// Fragment Shader
// Richard S. Wright Jr.
// OpenGL SuperBible
#version 120
uniform samplerCube cubeMap;
varying vec3 vVaryingTexCoord;
void main(void)
{
gl_FragColor = textureCube(cubeMap, vVaryingTexCoord.stp);
}
- Opengl超级宝典 第七章CubeMapped着色器部分编译错误
- Opengl超级宝典 第六章ShadedTriangle 着色器部分在xcode 编译报错问题
- 《OpenGL超级宝典》第五版第六章着色器的程序运行结果都是白色的问题?
- 《OpenGL超级宝典4》学习笔记——第七章(一)
- 《OpenGL超级宝典4》学习笔记——第七章(二)
- 《OpenGL超级宝典》中第七章TextureRect示例程序,RenderScene()函数解析
- OpenGL编译着色器程序
- 遮挡查询 OpenGL超级宝典 第十七章
- OpenGL超级宝典 - 第一章
- OPENGL超级宝典-6.6
- OpenGL超级宝典学习笔记第一部分:OpenGL API基础 第1章 3D图形学的基本原理
- OPENGL编程宝典Phong着色
- 《OpenGL超级宝典》笔记(一)
- OpenGL超级宝典笔记(三)
- OpenGL超级宝典笔记4
- OpenGL超级宝典笔记5
- OpenGL超级宝典笔记6
- OpenGL超级宝典笔记7
- Java对象与类——面向对象程序设计概述
- Swift KVO触发问题(runtime支持不友好)
- 练手项目
- 进程管理-网研14
- c++异常处理/命名空间
- Opengl超级宝典 第七章CubeMapped着色器部分编译错误
- [.NET MVC4 入门系列02]MVC Movie 为项目添加Model
- 前端 JS Docume
- leetcode-Regular expression match
- 菜鸟的Linux学习史——第四章 几个简单的命令
- 任务延时函数,OSTimeDly()
- JavaScript作用域原理——作用域根据函数划分
- Android中AlertDialog以及自定义对话框的使用
- 【抽奖系统】-IrisSkin4.dll 加载窗体皮肤