NeHe OpenGL Lesson37 – Cel-Shading(卡通渲染)

本文详细介绍了如何使用OpenGL实现卡通渲染效果,包括颜色分级和轮廓线效果。通过将顶点亮度作为纹理坐标采样预设的颜色分级1D纹理,以及在背面多边形上应用线框模式来绘制轮廓,实现了逼真的卡通视觉效果。

lesson37_screen_shot-300x256 This sample shows us how to do Cel-Shading with OpenGL. The cel-shading contain two part: one is the color grading on the object surface; the other one is the outline effect.
To get the color grading effect, we usually use the brightness of vertex as the vertex texture coordinates to sample a 1D texture that already color graded. The method that used in this sample is calculating the dot product between the triangle surface normal and light direction, take the result as the texture coordinates value.  A 1d texture that already color graded may like following:

color_grading

As you see, some range will fall into one fix color. This will make the object surface appears to be color grading. The texture coordinates calculating process is on fly, we will do the computation on every frame.  Of course, you could provide paint it with color by command glColor3f, just as the screen shot, I gave it a blue color.

To get the outline effect. At first, we define the outline are the edges between front surfaces and back surfaces. So we just draw the back surfaces with wireframe mode, and less or equal for the depth comparing function. Of source, some options like set the line color, or width also be provided here with OpenGL commands.

 

The full source code could be checked from here.

转载于:https://www.cnblogs.com/open-coder/archive/2012/08/23/2651814.html

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值