旧版opengl-为什么无法进行phong着色? [英] Legacy opengl - Why is phong shading not possible?

查看:105
本文介绍了旧版opengl-为什么无法进行phong着色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道传统的opengl仅支持平面和gouraud底纹,但我想知道为什么不能进行phong底纹?

I know that legacy opengl only supports flat and gouraud shading but I was wondering why phong shading is not possible?

有人说这是不可能的,因为传统的opengl会丢弃这些法线,但我不知道它们在哪里被丢弃,也不知道为什么会被丢弃.

Someone said that it is not possible because legacy opengl discards the normals, but I have no idea where they are discarded nor why they are discarded.

推荐答案

即使是传统的openGL也不丢弃法线.着色方面的区别在于,为了节省着色时间,传统的opgenGL仅计算每个顶点位置的着色值,在为顶点计算的3种颜色之间混合每个三角形的颜色.

Even legacy openGL doesn't discard normals. The difference when it it comes to shading is, that to save time in shading legacy opgenGL only calculates shading values at every vertex position, blending color for every triangle between the 3 color calculated for the vertexes.

此方法也称为 Gouraud底纹.

Phong阴影将计算屏幕上渲染的每个像素的照明值-不仅是顶点,而且以某种方式猜测"所有其他照明值.

Phong shading on the other hand will calculate lighting values for every pixel rendered on the screen - not just for the vertexes and somehow "guess" all the other lighting values.

最有可能是 Gouraud底纹,因为它涉及的计算量少得多,可以实现相对逼真的外观.

Most probably Gouraud shading was chosen as it involves a lot less computation it achieves a relatively realistic looking approximation.

Phong阴影可能会实现更逼真的外观,但计算差异可能会很大.

Phong shading may achieve an even more realistic looking approximation but the difference in computation can be very big.

屏幕上显示的一个四边形只需要对顶点进行4个或多或少的复杂计算,而就计算时间而言,将它们之间的混合要便宜得多.

A single quad displayed on the screen will just need 4 more or less complex computations for the vertexes, while blending between those will be much cheaper in terms of calculation time.

另一方面,Phong阴影将对构成您的四边形的每个像素执行照明计算,这可以非常快速地进行大量计算.想象一下,例如您的四边形被栅格化到(100 x 100)像素的区域.

Phong shading on the other hand will perform lighting calculations for every pixel that makes up your quad shape, which can get a lot of calculations pretty fast. Imagine your quad gets rasterzed to an area of (100 x 100) pixels for example.

根据int绘制的顺序形状,如果首先绘制了许多模糊的对象,则必须执行的每像素计算的数量可能远远大于屏幕的分辨率,因为它们都将通过深度测试,稍后再覆盖.

Depending int the order shapes get drawn the number of per-pixel calculations that has to be performed can be drastically larger than the resolution of the screen if a lot of obscured objects get drawn first as they will all pass the depth-test just to be overdrawn later on.

要快速执行 Phong着色的旧版opengl中缺少的内容不是丢失或以其他方式丢弃的法线,而是一种相当快地执行上述每像素操作的方法.使用所谓的 Shaders (着色器)可以做到这一点.在图形硬件本身上运行的小程序.

What's missing in legacy opengl to perform fast Phong shading are not any missing or otherwise discarded normals but a way to perform the mentioned per-pixel operations pretty fast. This is possible with so called Shaders. Small programs running on the graphics hardware itself.

旧版opengl不允许以如此精细的级别自定义渲染过程,因为整个渲染过程只能在所谓的固定功能管道中的几个预定义位置进行.

Legacy opengl doesn't allow for customization of the rendering process at such a fine grained level as the whole rendering process can only be tewaked at few pre-defined places in the so called fixed function pipeline.

除了您被告知尝试使用旧版opengl执行 Phong Shading 的主要问题外,它不是没有丢弃任何法线,而是设计为每像素执行 照明,但仅每个顶点照明.

Other than you were told the main problem in trying to perform Phong Shading using legacy opengl is not that any normals are discarded, but that it wasn't designed to perform per-pixel lighting but only per-vertex lighting.

这篇关于旧版opengl-为什么无法进行phong着色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆