Git Product home page Git Product logo

shadowmapping's Introduction

Shadow

使用阴影贴图(shadow mapping)以及扩展的高级算法Omnidirectional Shadow Maps实现实时动态阴影

依赖

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

思路

渲染一个点P处的片元,需要决定它是否在阴影中。先得使用T把P变换到光源的坐标空间里。既然点P是从光的透视图中看到的,它的z坐标就对应于它的深度。使用点P在光源的坐标空间的坐标,可以索引深度贴图,来获得从光的视角中最近的可见深度。这样即可判断一个点是否在阴影中。

步骤

  1. 首先,以光源视角渲染深度贴图,普通阴影算法只用将深度贴图设置为2D纹理就行了,而适合于OSM算法的点光源则需要一个立方体贴图的深度贴图

  2. 像往常一样渲染场景,使用生成的深度贴图来计算片元是否在阴影之中

改进

  1. 使用阴影偏移(shadow bias)技巧来解决阴影失真(Shadow Acne),即明显的线条样式。
  2. 使用一个简单的PCF,从纹理像素四周对深度贴图采样,然后把结果平均起来,使其产生柔和阴影,使它们出现更少的锯齿块和硬边。

效果

  • 阴影映射

阴影映射

  • 万向阴影贴图技术

OSM

shadowmapping's People

Contributors

sweeneychoi avatar

Watchers

 avatar

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.