Opengl超级宝典 第七章CubeMapped着色器部分编译错误
2017-03-15 15:23
281 查看
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;
}
<
9996
br />
// 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);
}
// 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;
}
<
9996
br />
// 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超级宝典 关于gltDrawTorus的错误解决
- 问题解决——OpenGL超级宝典 关于gltDrawTorus的错误解决
- 问题解决——OpenGL超级宝典 关于gltDrawTorus的错误解决
- OpenGL超级宝典-第4版 chapter4-transformgl.cpp运行方法
- 抗锯齿 多重采样 opengl超级宝典
- 读书笔记——OpenGL超级宝典
- 抗锯齿 多重采样 opengl超级宝典 P177
- openGL 超级宝典第五版学习 第一个程序
- opengl super bible(超级宝典)第五版阅读笔记
- 在linux下将OpenGL超级宝典里的例子用eclipse打开
- OpenGL超级宝典笔记6
- OpenGL 3D 超级宝典学习笔记
- OPENGL超级宝典-6.6
- 使用OpenGL的glMultiDrawElements()编译错误的解决方案!!(搜了好多资料终于弄出来了)
- 读书笔记——OpenGL超级宝典
- 关于OpenGL超级宝典 无法打开文件“libc.lib”
- 关于OpenGL的编译错误
- OpenGL编译错误的解决
- [OpenGL学习] openGL超级宝典 无法打开文件“freeglut_static.lib”
- 问题解决——OpenGL超级宝典 第四章 4.5.2 关于freeglut.lib问题的解决过程