黎明的剔透里伸出了你沁清的暧昧
Graphics|EngineDev|GameDev|2D&3D Art
C++博客
::
首页
::
新随笔
::
联系
::
聚合
::
管理
::
60 随笔 :: 1 文章 :: 18 评论 :: 0 Trackbacks
公告
Please feel free to reach me through email: crazyinit(at)gmail(dot)com, this is the preferred way.
常用链接
我的随笔
我的评论
我参与的随笔
留言簿
(3)
给我留言
查看公开留言
查看私人留言
随笔分类
(83)
Coding(25)
(rss)
Documents(8)
(rss)
Graphics(44)
(rss)
Projects(5)
(rss)
SoftwareEngine(1)
(rss)
文章档案
(1)
2013年11月 (1)
相册
图片
Link
atyuwen
benjamin
ccanan
cnblogs
courses
cwyman
defrostgames
devmaster
encelo
gamasutra
GD
gdconf
gdcvault
glslDevil
gongminmin
GPUTutrial
lousodrome
mindhacks
mynameismjp
OSG
P-B A
popy007
rastergrid
selfshadow
simonstechblog
songho
terathon
WGGPU
搜索
最新评论
1. re: GLSL.Projective Texture Mapping
评论内容较长,点击标题查看
--www.czgo.net
2. re: 数据库数据转换
评论内容较长,点击标题查看
--www.czgo.net
3. re: 数据库数据转换
评论内容较长,点击标题查看
--zhongjing
4. re: GLSL.Projective Texture Mapping
如果方便的话,我的邮箱是lacp7723413@163.com
--Zi_菜
5. re: GLSL.Projective Texture Mapping
您好,我想看看实例的代码,请问可以给我一份么?
--Zi_菜
6. re: Gamma Correction
谢谢你的劳动
--tzzhwj
7. re: GLSL.Cook Torrance Model
评论内容较长,点击标题查看
--情绝格调(fresmaster)
8. re: GLSL.Cook Torrance Model
评论内容较长,点击标题查看
--杯具Graphic
9. re: GLSL.Simplified Uberlight Lighting
@Lynn Zhang
QQ需要验证
--情绝格调(crazyinit)
10. re: GLSL.Simplified Uberlight Lighting
你好,我在做的内容跟你有点像,也想跟你探讨一下~如果方便的话请加我QQ,261673157~谢谢~
--Lynn Zhang
阅读排行榜
1. OpenGL.Vertex Array Object (VAO).(17279)
2. c# Newtonsoft.Json(11788)
3. OpenGL.FrameBuffer Object (11466)
4. GLSL. 语法基础(9168)
5. OpenGL.Stencil Buffer(4941)
评论排行榜
1. 基于OpenGL写的一个小系统_模拟高速公路单车检测仿真(6)
2. GLSL.Projective Texture Mapping(3)
3. GLSL.Simplified Uberlight Lighting(3)
4. GLSL.Cook Torrance Model(2)
5. 数据库数据转换(2)
GLSL.Parallax mapping
The pseudo code to implement parallax mapping is the following :
float parallaxHeight = 0.035f
float height = tex2D ( HeightMap ).r;
float offset = parallaxHeight * ( 2.0f * height - 1.0f);
float2 parallaxTexCoord = texCoord + offset * viewVec.xy;
The
height
is a value between 0 and 1 but the
offset
is a value in the range [-parallaxHeight, +parallaxHeight]. The reason for this mapping is to distribute the distortion of the texture map equally in 2 directions.
1
attribute vec3 rm_Binormal;
2
attribute vec3 rm_Tangent;
3
4
varying vec3 vCameraDir;
5
6
void
main(
void
)
7
{
8
gl_Position
=
ftransform();
9
gl_TexCoord[
0
]
=
gl_MultiTexCoord0;
10
11
vec4 view_position
=
gl_ModelViewMatrix
*
gl_Vertex;
12
vec3 camera_dir
=
normalize(view_position.xyz);
13
14
mat3x3 TangentSpace;
15
TangentSpace[
0
]
=
gl_NormalMatrix
*
rm_Tangent;
16
TangentSpace[
1
]
=
gl_NormalMatrix
*
rm_Binormal;
17
TangentSpace[
2
]
=
gl_NormalMatrix
*
gl_Normal;
18
19
vCameraDir
=
camera_dir
*
TangentSpace;
20
//
equal to
.
21
//
vCameraDir.x = dot(camera_dir, TangentSpace[0]);
22
//
vCameraDir.y = dot(camera_dir, TangentSpace[1]);
23
//
vCameraDir.z = dot(camera_dir, TangentSpace[2]);
24
}
1
varying vec3 vCameraDir;
2
3
uniform sampler2D DiffuseMap;
4
uniform sampler2D HeightMap;
5
6
uniform
float
fHeight;
7
8
void
main(
void
)
9
10
{
11
vCameraDir
=
normalize(vCameraDir);
12
13
vec3 texcoord
=
vec3(gl_TexCoord[
0
].xy, fHeight);
14
15
float
depth
=
(
2.0
*
texture2D(HeightMap, texcoord).r
-
1.0
)
*
fHeight;
16
vec3 texcoord_corrected
=
texcoord
+
vCameraDir.xyz
*
depth;
17
18
gl_FragColor
=
texture2D(DiffuseMap, texcoord_corrected.xy);
19
}
http://knol.google.com/k/shader-fx-parallax-mapping
#
http://www.ownself.org/oswpblog/?p=59
http://blog.csdn.net/soilwork/article/details/1452437
posted on 2012-04-07 17:03
情绝格调(fresmaster)
阅读(1330)
评论(0)
编辑
收藏
引用
所属分类:
Graphics
、
Coding
只有注册用户
登录
后才能发表评论。
【推荐】100%开源!大型工业跨平台软件C++源码提供,建模,组态!
相关文章:
glAlphaFunc in OpenGL ES2.0
Gamma Correction
Hemi-Sphere Lighting
Light Mapping
GLSL.Ambient occlusion
GLSL.High Dynamic Range
GLSL.Depth Of Field
GLSL.Image post-processing
GLSL.Parallax mapping
GLSL.Refract & Reflect & Diffraction
网站导航:
博客园
IT新闻
BlogJava
知识库
博问
管理
Powered by:
C++博客
Copyright © 情绝格调(fresmaster)