Git Product home page Git Product logo

parallaxmapping's Introduction

ParallaxMapping

使用视差贴图,极大提升表面细节,使之具有深度感

依赖

  • glfw3.lib 推荐在官方网站下载源代码,然后自行编译。本项目编译使用的是CMake和Visual Studio 2015.
  • GLAD 打开GLAD的在线服务可轻松配置。本项目使用OpenGL 4.3.
  • stb_image.h 是Sean Barrett的一个非常流行的单头文件图像加载库,可以在这里下载。本项目使用其来加载纹理图片。
  • GLM 一个只有头文件的库,不用链接和编译。可以在它们的网站上下载。本项目使用其作为数学库。
  • Assimp 一个非常流行的模型导入库,可以在下载页面选择相应的版本,自行使用CMake 和 Visual Studio 2015编译。

**

视差贴图属于 位移贴图(Displacement Mapping) 技术的一种,它对根据储存在纹理中的几何信息对顶点进行位移或偏移。比如,每个纹理像素包含了高度值的纹理叫做 高度贴图

视差贴图的**是修改纹理坐标使一个fragment的表面看起来比实际的更高或更低。

法线贴图通常根据高度贴图生成,法线贴图和高度贴图一起用能保证光照能和唯一相匹配。

使用 反色高度贴图 (也叫 深度贴图 )去模拟深度比模拟高度容易。

实现

  1. 使用高度贴图对纹理坐标进行位移,同样是在切线空间中进行计算

  2. 使用这些经位移的纹理坐标进行diffuse和法线贴图的采样。最后fragment的diffuse颜色和法线向量就正确的对应于表面的经位移的位置上了

改进

  • 陡峭视差映射(Steep Parallax Mapping) 是视差映射的扩展,原则是一样的,但不是使用一个样本而是多个样本来采样。

  • 视差遮蔽映射(Parallax Occlusion Mapping) 和陡峭视差映射的原则相同,但不是用触碰的第一个深度层的纹理坐标,而是在触碰之前和之后,在深度层之间进行线性插值。根据表面的高度距离哪个深度层的深度层值的距离来确定线性插值的大小。

效果

效果1

效果2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.