求助 玩游戏贴图和3dmax阴影贴图闪烁 是怎么回事

Ibex, 积分 1540, 距离下一级还需 460 积分
绘本打印发现背景有好多阴影呀,怎样去除呢,偶是PS菜鸟,请教下~
给个样图看看, 别人才好回答你的问题啊!
Ibex, 积分 1540, 距离下一级还需 460 积分
high5 发表于
给个样图看看, 别人才好回答你的问题啊!
晕了,是PFD文件,不知道怎么上传呀。就是打印出来的图片白色的背景里有阴影。我已经用过技术贴里的修复方法,还是会出现这样的情况~
Lion, 积分 4868, 距离下一级还需 1132 积分
雅儿14岁8个月
无图不明白到底如何,你可以用魔术套-反选-把图复制出来建新图层--然后把原来的图片弄白再合并。
&不客气,能帮到你就好。&
&恩,谢谢了。用这个方法后打印出来就没阴影了。&
PDF 需要先导出图片格式, 然后再处理。 图片能贴一张吗?
&还是不会怎样将图片导出来,我再学习学习去。&
Lion, 积分 4501, 距离下一级还需 1499 积分
Flora11岁1个月
我觉得其本上这个不是很好弄,有时魔术棒不是很精细还不如不弄。
爸妈网( , )您当前的位置: > 游戏辅助 -> 攻略
->三国志13游戏贴图错误怎么办 三国志13游戏贴图错误解决办法
三国志13游戏贴图错误怎么办 三国志13游戏贴图错误解决办法
更新时间:
  来源:斗蟹游戏  编辑:熊小雄
  浏览:203
三国志13游戏贴图错误怎么办
三国志13游戏贴图错误解决办法。《三国志13》是近期很热门的游戏,而很多玩家不知道游戏三国志13游戏贴图错误怎么办?这里带来玩家分享的《三国志13》游戏贴图错误怎么办详解,一起来了解一下吧。问:三国志13游戏贴图错误阴影偏移了,如图。怎么解决?答:更新一下显卡驱动。这种问题是游戏本身的问题,很多人都有这问题~ 如果还未解决的话看看光荣会不会打优化。三国志13游戏贴图错误怎么办 三国志13游戏贴图错误解决办法。今天的攻略就是这样,更多资讯请关注斗蟹游戏网。相关阅读:
【三国志】系列游戏推荐
游戏语言:简体中文
游戏类型:即时战略
游戏大小:4.97 GB
更新时间:
操作系统:w8,w7,wv,wxp
总评:9.6分
共 0 人评分
热门游戏攻略
今日游戏推荐努力加载中,稍等...
暂无新消息
努力加载中,稍等...
已无更多消息...
这些人最近关注了你
努力加载中,稍等...
已无更多消息
努力加载中,稍等...
已无更多消息
& 提升阴影深度贴图的通用技巧
Common Techniques to Improve Shadow Depth Maps
征集热心朋友翻译文章,奖励规则:每100汉字奖励10QB,30天内互动奖励0 - 50QB.
翻译请求:Common Techniques to Improve Shadow Depth Maps
该文章来自用户转载
Shadow maps, first introduced in 1978,are a common technique for adding shadows to games. Three decades later,despite advances in hardware and software, shadowing artifacts—namelyshimmering edges, perspective aliasing, and other precision issues—persist. This technical article provides anoverview of some common shadow depth map algorithms and common artifacts, andexplains several techniques—ranging in difficulty from basic tointermediate—that can be used to increase the quality of standard shadow maps.Adding basic shadow maps to a title typically is straightforward, butunderstanding the nuances of shadow artifacts can be challenging. Thistechnical article is written for the intermediate graphics developer who hasimplemented shadows, but does not fully understand why specific artifactsappear and is not sure how to work around them. Selecting the correct techniques tomitigate specific artifacts is nontrivial. When shadow map shortcomings are addressed,the difference in quality can be impressive (Figure 1). Correctly implementingthese techniques drastically improves standard shadows. The techniquesexplained in this article are implemented in the sample CascadedShadowMaps11 inthe DirectX SDK. Figure 1. Shadows with severe artifacts(left), and shadows after implementing the techniques described in this article(right)Shadow Depth Maps ReviewThe shadow depth map algorithm is a two-pass algorithm. Thefirst pass generates a depth map in light space. In the second pass, this mapis used to compare each pixel's depth in light space against its correspondingdepth in the light space depth map. Figure 2. Key parts of ashadow scenePass 1The scene is shown in Figure 2. In the first pass (Figure3), the geometry is rendered into a depth buffer from the point of view of thelight. More specifically, the vertex shader transforms the geometry intolight-view space. The end result of this first pass is a depth buffercontaining the scene's depth information from the point of view of the light.This now can be used in pass 2 to determine which pixels are occluded from thelight. Figure 3. First pass ofbasic shadow mappingPass 2In the second pass (Figure 4), the vertex shader transformseach vertex twice. Each vertex is transformed into the camera's view space andpassed to the pixel shader as the position. Each vertex is also transformed bythe light's view-projection-texture matrix and passed to the pixel shader as atexture coordinate. The view-projection-texture matrix is the same matrix usedto render the scene in pass 1 with one additional transform. It's atransformation that scales and translates the points from view space (–1 to 1in X and Y) to texture space (0 to 1 in X and 1 to 0 in Y). The pixel shader receives the interpolated position and theinterpolated texture coordinates. Everything needed to perform the depth testis now in this texture coordinate. The depth test can now be performed byindexing the depth buffer from the first pass with the X and Y texturecoordinates and comparing the resulting depth value against the Z-texturecoordinate. Shadow Map ArtifactsThe shadow depth map algorithm is the most widely usedreal-time shadowing algorithm, but still produces several artifacts requiringmitigation. The types of artifacts that can occur are summarized next. Perspective AliasingPerspective aliasing, a common artifact, is shown in Figure5. It occurs when the mapping of pixels in view space to texels in the shadowmap is not a one-to-one ratio. This is because pixels close to the near planeare closer together and require a higher shadow map resolution. Figure 6 shows a shadow map and a view frustum. Near theeye, the pixels are closer together, and many pixels map to the same shadowtexels. The pixels by the far plane are spread out, thereby reducingperspective aliasing. Figure 5. High-perspectivealiasing (left) vs. low-perspective aliasing (right)For the image at left, perspectiv toomany eye-space pixels map to the same shadow-map texels. In the image at right,perspective aliasing is low because there is a 1:1 mapping between theeye-space pixels and shadow-map texels. Figure 6. View frustum withshadow mapLight pixels in the far plane represent low-perspectivealiasing, and dark pixels in the near plane represent high-perspectivealiasing. Shadow map resolution can also be too high. Although ahigher resolution is less noticeable, it nevertheless can result in smallobjects, such as telephone wires, not casting shadows. Also, having too high ofa resolution can cause severe performance issues because of texture access patterns. Perspective shadow maps (PSMs) and light space perspectiveshadow maps (LSPSMs) attempt to address perspective aliasing by skewing thelight's projection matrix in order to place more texels near the eye where theyare needed. Unfortunately, neither technique is able to solve the perspectivealiasing. The parameterization of the transform required to map eye-spacepixels to texels in the shadow map cannot be bound by a linear skew. Alogarithmic parameterization is required. PSMs put too much detail near theeye, causing distant shadows to be of low quality or to even disappear. LSPSMsdo a better job of finding a middle ground between increasing resolution nearthe eye, and leaving enough detail for objects far away. Both techniquesdegenerate to orthographic shadows in some scene configurations. Thisdegeneration can be counteracted by rendering a separate shadow map for eachface of the view frustum, although this is expensive. Logarithmic perspectiveshadow maps (LogPSMs) also render a separate map per face of the view frustum.This technique uses nonlinear rasterization to place more texels near the eye.D3D10 and D3D11-class hardware do not support nonlinear rasterization. For moreinformation about these techniques and algorithms, see the References section. Cascaded shadow maps (CSMs) are the most popular techniquefor dealing with perspective aliasing. Although CSMs can be combined with PSMsand LSPSMs, it's unnecessary. Using CSMs to fix perspective aliasing errors isaddressed in the companion article, . Projective AliasingProjective aliasing is harder to show than perspectivealiasing. The distended shadows highlighted in Figure 7 demonstrate projectivealiasing errors. Projective aliasing occurs when the mapping between texels incamera space to texels in light space is not a one-to- this isbecause of the orientation of the geometry with respect to the light camera.Projective aliasing occurs as the tangent plane of the geometry becomesparallel to the light rays. Figure 7. High-projectivealiasing vs. low-projective aliasingTechniques used to alleviate perspective aliasing errorsalso mitigate projective aliasing. Projective aliasing occurs when the surfacenormal is ort these surfaces should be receiving lesslight based on diffuse lighting equations. Shadow Acne and Erroneous Self-ShadowingShadow acne (Figure 8), a term synonymous with erroneousself-shadowing, occurs when the shadow map quantizes the depth over an entiretexel. When the shader compares an actual depth against this value, it is aslikely to be self-shadowed as it is to be unshadowed. Another reason for shadow acne is that the texel in lightspace is so close to the depth of the corresponding texel in the depth map thatprecision errors cause the depth test to erroneously fail. One reason for thisprecision difference is that the depth map was calculated by the fixed-functionrasterization hardware, while the depth being compared was computed by theshader. Projective aliasing can also cause shadow acne. Figure 8. Shadow acneartifactAs shown in the left image, some of pixels failed the depthtest and created speckled artifacts and moiré patterns. In order to reduceerroneous self-shadowing, the bounds on the near plane and the far plane forthe light space view frustum should be calculated as tightly as possible. Theslope scale-based depth bias and other types of bias are other solutions usedto mitigate shadow acne. Peter PanningThe term Peter Panning derives its name from a children's book character whose shadow became detachedand who could fly. This artifact makes objects with missing shadows appear tobe detached from and to float above the surface (Figure 9). Figure 9. Peter PanningartifactIn the image at left, the shadow is detached from theobject, creating a floating effect. One technique for removing surface acne is to add somevalue to pixel pos this is called adding a depth offset.Peter Panning results when the depth offset used is too large. In this case thedepth offset causes the depth test to erroneously pass. Like shadow acne, PeterPanning is aggravated when there is insufficient precision in the depth buffer.Calculating tight near planes and far planes also helps avoid Peter Panning. Techniques to Improve Shadow MapsAdding shadows to a title is a process. The first step isto get basic shadow maps working. The second is to ensure all basiccalculations are done optimally: frusta fit as tightly as possible, near/farplanes fit tightly, slope-scaled bias is used, and so on. Once basic shadowsare enabled, and look as good as possible, the developer has a better idea ofwhat algorithms are needed to get the shadows to sufficient fidelity. Basictips that may be needed to get basic shadow maps looking at their best are givenin this section. Slope-Scale Depth BiasAs previously mentioned, self-shadowing can lead to shadowacne. Adding too much bias can result in Peter Panning. Additionally, polygonswith steep slopes (relative to the light) suffer more from projective aliasingthan polygons with shallow slopes (relative to the light). Because of this,each depth map value may need a different offset depending on the polygon'sslope relative to the light. Direct3D 10 hardware has the ability to bias a polygonbased on its slope with respect to the view direction. This has the effect ofapplying a large bias to a polygon that is viewed edge-on to the lightdirection, but not applying any bias to a polygon facing the light directly.Figure 10 illustrates how two neighboring pixels can alternate between shadowedand unshadowed when testing against the same unbiased slope. Figure 10. Slope scaleddepth-bias compared to unbiased depthCalculating a Tight ProjectionTightly fitting the light's projection to the view frustum increasesthe shadow map coverage. Figure 11 illustrates that using an arbitraryprojection, or fitting the projection to the scene bounds, results in higherperspective aliasing.Figure 11. Arbitrary shadowfrustum and shadow frustum fit to sceneThe view is from the point of view of the light. Thetrapezoid represents the view camera's frustum. The grid drawn over the imagerepresents the shadow map. The image on the right shows that the sameresolution shadow map creates more texel coverage when it is fit more tightlyto the scene. Figure 12 illustrates frustums that are correctly fit. Tocalculate the projection, the eight points that make up the view frustum aretransformed into light space. Next, the minimum and maximum values in X and Yare found. These values make up the bounds for an orthographic projection. Figure 12. Shadow projectionfit to view frustumIt is also possible to clip the frustum to the scene AABBto get a tighter bound. This is not advised in all cases because this canchange the size of the light camera's projection from frame to frame. Manytechniques, such as those described in the section Moving the Light Texel-SizedIncrements, give better results when the size of the light's projection remainsconstant in every frame. Calculating the Near Plane and Far PlaneThe near plane and far plane are the final pieces requiredto calculate the projection matrix. The more closely together the planes are,the more precise the values in the depth buffer. The depth buffer can be 16-bit, 24-bit, or 32-bit, withvalues between 0 and 1. Generally, depth buffers are fixed point, with thevalues close to the near plane grouped more closely together than the valuesclose to the far plane. The degree of precision available to the depth buffer isdetermined by the ratio of the near plane to the far plane. Using the tightestpossible near/far plane could allow use of a 16-bit depth buffer. A 16-bitdepth buffer could reduce the use of memory while increasing processing speed. AABB-Based Near Plane and Far PlaneAn easy and naive way to calculate the near plane and farplane is to transform the scene's bounding volume into light space. Thesmallest Z-coordinate value is the near plane and the largest Z-coordinatevalue is the far plane. For many configurations of the scene and light, thisapproach is sufficient. The worst case scenario, however, can result in asignificant loss of precision Figure 13 shows such ascenario. Here the range of the near plane to the far plane is four timeslarger than necessary. The view frustum in Figure 13 was purposely chosen to besmall. A small view frustum is shown in a very large scene consisting ofpillars extending out from the view camera. Using the Scene AABB for the nearand far planes is not optimal. The CSM algorithm described in the
technical article must calculate near and far planes for verysmall frustums. Figure 13. Near and farplanes based on Scene AABBFrustum-Based Near Plane and Far PlaneAnother technique for calculating the near and far planesis to transform the frustum into light space and use the minimal and maximalvalues in Z as the near and the far planes, respectively. Figure 14 illustratesthe two issues with this approach. First, the calculation is too conservative,as shown when the frustum extends beyond the scene's geometry. Second, the nearplane could be too tight, causing shadow casters to be cropped. Figure 14. Near and farplanes based solely on view frustumLight Frustum Intersected with Scene to Calculate Near andFar PlanesThe proper way to calculate the near and far planes isshown in Figure 15. Four of the planes of the orthographic light frustum werecalculated using the minimum and maximum of the X and Y coordinates of the viewfrustum in light space. The last two planes of the orthogonal view frustum arethe near and the far planes. To find these planes, the scene's bounds areclipped against the four known light frustum planes. The smallest and largestZ-values from the newly clipped boundary represent the near plane and farplane, respectively. The code that performs this operation is located in theCascadedShadowMaps11 sample. The eight points that make up the world's AABB aretransformed into light space. Transforming the points into light spacesimplifies the clipping tests. The four known planes of the light frustum cannow be represented as lines. The scenes bounding volume in light space can berepresented as six quadrilaterals. These 6 quadrilaterals can then be turnedinto 12 triangles for triangle-based clipping. The triangles are clippedagainst the known planes of the view frustum (these are horizontal and verticallines in X and Y in light space). When an intersection point is found in X andY, the 3D triangle is clipped at that point. The minimum and maximum Z-valuesof all the clipped triangles are the near plane and far plane. TheCascadedShadowMaps11 sample shows how to perform this clipping in the ComputeNearAndFar function. There are two more techniques that could be used tocalculate the tightest possible near and far planes. These techniques are notshown in the CascadedShadowMaps sample. Even tighter near
and far planes could be calculated by intersecting a hierarchy of a scene
or individual objects in a scene against the light frustum. This would be
computationally more complex. While not illustrated in the
CascadedShadowMaps11 sample, this could be a valid technique for some
tiles. ·The far plane could be calculated by taking theminimum of:The largest
depth of the view frustum in light space.The largest
depth of the intersection of the view frustum and the scene AABB.This approach can be problematic when used with cascadedshadow maps where it is possible to index outside of a view frustum. In thiscase, the shadow map might be missing geometry. Figure 15. Near and farplanes based on the intersection of the four calculated planes of the lightfrustum and the scene's bounding geometryMoving the Light in Texel-Sized IncrementsA common artifact in shadow maps is the shimmering edgeeffect. As the camera moves, the pixels along the shadows' edges brighten anddarken. This cannot be seen in still images, but it is very noticeable anddistracting in real time. Figure 16 highlights this problem and Figure 17 showshow the shadow edges should look. The shimmering edge error occurs because the lightprojection matrix is being recalculated every time the camera moves. Thiscreates subtle differences in the generated shadow maps. All of the followingfactors can influence the matrix created to bound the scene. Size of the view
frustumOrientation of
the view frustumLocation of the
lightLocation of the
cameraEvery time this matrix changes, the shadows edges couldchange. Figure 16. Shimmering shadowedgesThe pixels along the border of the shadow come in and outof shadow as the camera moves from left to right. Figure 17. Shadows withoutshimmering edgesThe shadow edges stay constant as the camera moves fromleft to right. For directional lights, the solution to this problem is toround the minimum/maximum value in X and Y (that make up the orthographicprojection bounds) to pixel size increments. This can be done with a divideoperation, a floor operation, and a multiply. C++:vLightCameraOrthographicMin /=vWorldUnitsPerT
vLightCameraOrthographicMin = XMVectorFloor( vLightCameraOrthographicMin );
vLightCameraOrthographicMin *= vWorldUnitsPerT
vLightCameraOrthographicMax /= vWorldUnitsPerT
vLightCameraOrthographicMax = XMVectorFloor( vLightCameraOrthographicMax );
vLightCameraOrthographicMax *= vWorldUnitsPerTThe vWorldUnitsPerTexel value is calculated by taking abound of the view frustum, and dividing by the buffer size. C++
FLOAT fWorldUnitsPerTexel = fCascadeBound /
(float)m_CopyOfCascadeConfig.m_iBufferS
vWorldUnitsPerTexel = XMVectorSet( fWorldUnitsPerTexel, fWorldUnitsPerTexel,
0.0f, 0.0f );
Bounding the maximum size of the view frustum results in alooser fit for the orthographic projection. It is important to note that the texture is 1 pixel largerin width and height when using this technique. This keeps shadow coordinatesfrom indexing outside of the shadow map. Back Face and Front FaceShadow maps should be rendered with standard back-faceculling, a process that skips rasterization of objects that the viewer cannotsee, and speeds up rendering of the scene. Another common option is to rendershadow maps with front-face culling enabled, which means that objects facingthe viewer are eliminated. The argument for this is that it helps withself-shadowing as the geometry making up the back of objects is slightlyoffset. There are two problems with this idea. Any object with
improper front-face or back-face geometry causes artifacts in the shadow
map. However, having incorrect front-face or back-face geometry will cause
other problems, so it may be safe to assume front-face and back-face
geometry is done correctly. It may be impractical to create back faces for
sprite-based geometry such as foliage.Peter Panning and
shadow gaps near the base of objects such as walls are more likely to
occur because the shadow depth disparity is too small. Shadow Map–Friendly GeometryCreating geometry that works well in shadow maps allows formore flexibility when combating artifacts like Peter Panning and shadow acne. Hard edges are problematic for self-shadowing. The depthdisparity near the tip of the edge is very small. Even a small offset can causeobjects to lose their shadows (Figure 18). Figure 18. Sharp edges causeartifacts stemming from low-depth disparity with offsetsNarrow objects such as walls should have backs even if theyare never visible. This will increase the depth disparity. It's also important to make sure that the direction thegeometry
that is, the outside of an object should be backfacing and the inside of an object should be front facing. This is importantfor rendering with back-face culling enabled, as well as for combating theeffects of depth bias. SummaryThe techniques described in this article can be used toincrease the quality of standard shadow maps. The next step is to look attechniques that can work well with standard shadow maps. CSMs are recommendedas a superior technique to combat perspective aliasing. Percentage closerfiltering or variance shadow maps can be used to soften shadow edges. See the
technical article for more information. Donnelly, W., and Lauritzen, A. . Symposium on Interactive 3D Graphics, Proceedings of the 2006 Symposiumon Interactive 3D Graphics and Games. 2006, pp. 161–165. Engel, Woflgang F. Section 4. Cascaded Shadow Maps.ShaderX5, Advanced Rendering Techniques,Wolfgang F. Engel, Ed. Charles River Media, Boston, Massachusetts. 2006. pp.197–206. Stamminger, Marc, and Drettakis, George. .International Conference on Computer Graphics and Interactive Techniques, Proceedings of the 29th Annual Conference on ComputerGraphics and Interactive Techniques. 2002, pp 557–562. Wimmer, M., Scherzer, D., and Purgathofer, W. . Eurographics Symposium on Rendering. 2004.Revised June 10, 2005. .
提升阴影深度贴图的通用技巧
版权所有,禁止匿名转载;禁止商业使用;禁止个人使用。
译者:赵菁菁(轩语轩缘)
审校:李笑达(DDBC4747) 阴影贴图技术是在1978年首次推出的用于向游戏中添加阴影的通用技术。三十年后,尽管硬件和软件不断进步,但阴影伪像—— 即闪烁的边缘,透视锯齿以及精度等其它问题仍然存在。 这篇技术文章概述并解释一些通用的阴影深度贴图算法和常见伪影技术,这几种难易程度从基础到中等的技术可以用于提升标准阴影贴图的质量。通常,就向一个主题添加基本的阴影贴图很简单,但了解阴影伪像的细微差别却很具有挑战性。这篇技术文章针对以下这些读者——已经实现了阴影的中级图形,但并不十分明白特定的伪像出现的缘由,以及搞不清楚如何围绕这些伪像展开工作的开发人员。 选择正确的技术来减轻特定的伪像是很重要的。当阴影贴图的缺点得到改善时,在质量方面产生的差异会令人印象深刻 (图 1)。正确执行这些技术将大大改进标准阴影。这篇文章中介绍的技术是在DirectX SDK 中的示例CascadedShadowMaps11里实现的。 图 1.有严重伪影的阴影(左),实现这篇文章中描述的技术后的阴影(右)
阴影深度贴图回顾
阴影深度贴图算法是一个两步的算法。第一步在光照空间中生成深度Map,在第二步中,在第一步生成的Map用于比较光照空间中每个像素的深度,以及它在光照空间深度Map中对应的深度。
图2.阴影场景的关键部分
场景图如图2所示。在第一步中(图3),几何体从光的角度渲染成深度缓冲区。更具体地说,顶点着色器把几何体变成光视图空间。
第一步的最终结果是一个深度缓冲区,它包含场景中来自光角度的深度信息,现在这些信息可以在第二步中使用,用于确定哪些像素是被光遮挡的。 图3.基本阴影贴图的第一步
在第二步中(图4),顶点着色器两次变换每个顶点。每个顶点转换成摄像头视图空间,并且作为位置传入像素着色器。每个顶点也是由光的视图投影纹理矩阵转换,并作为纹理坐标传递给像素着色器。在第一步中,视图投影纹理矩阵是用来渲染场景的,与另一个的变换是相同的。这种转变应该可以将视图空间(X和Y的值都是-1到1)调整比例并转化至纹理空间 (X和Y的值都是1到0)。
像素着色器接收插值的位置和插值纹理坐标。现在,要执行深度测试所需的一切条件都处于这个纹理坐标中。深度测试现在可以通过从第一步的XY纹理坐标中定位、与Z纹理坐标比较结果深度实现。
阴影贴图伪像
阴影深度贴图算法是最广泛使用的实时阴影算法,但仍然产生几个需要解决的伪像。下一步总结可能产生的伪像类型。 透视锯齿
透视锯齿如图5所示,是一种常见的伪像。当视图空间中的像素与纹素的映射不是一对一时,这种情况会发生。这是因为靠近近平面的像素紧密,需要更高的阴影贴图分辨率。 图5.高度透视锯齿(左),低度透视锯吃(右)
图 6 显示了阴影贴图和视景体。靠近眼球,像素更紧密地聚在一起,很多像素映射到相同的阴影纹素。远平面像素散开,从而削弱透视锯齿。 从下图可以看到:透视锯齿更严重;太多眼空间像素映射到相同的阴影贴图纹理。在下图中,透视锯齿程度较低,眼空间像素和阴影贴图纹理之间是 1:1 映射。 图6.带有阴影贴图的视景体
在远平面的浅像素代表低度透视锯齿,近平面的深像素代表高度透视锯齿。
阴影贴图分辨率也可能过高。虽然较高的分辨率是不那么明显,但是它可以导致如电话线这样的小物体不投射影子。此外,分辨率过高可能会因纹理通道模式导致严重的性能问题。
PSMs和LSPSMs试图解决透视锯齿问题,通过使光投影矩阵偏移,在眼睛附近所需位置放置更多的纹理。不幸的是,两种技术都不能够解决透视锯齿。在阴影贴图中,将眼空间像素映射到纹素所需变换的参数设定不能通过一个线性偏移来限制。对数的参数设定是必需的。Psms 在眼睛附近放了太多细节,导致远处阴影质量很低,甚至消失。
眼睛附近的分辨率逐渐增高,LSPSMs擅长在其间找到一个中间地带,并且让远处的物体也能看得足够清晰。在某些场景配置中,这两种技术退化到正投影的阴影,这种退化可以通过为每个视景体渲染单独阴影图的方式抵消,但是这样的代价很大。LogPSMs也为每个视景体的每个面渲染单独的Map。这种技术通过使用非线性栅格化的方法在眼睛附近放置更多的纹理。D3D10 和 D3D11 类硬件不支持非线性栅格化。有关这些技术和算法的详细信息,请参阅参考部分。
CSMs技术是处理透视锯齿问题的最受欢迎的技术。虽然CSMs可以结合 PSMs和 LSPSMs,但没必要。使用CSMs修复透视锯齿错误的处理方法在此文章——中进行介绍。 射影失真
射影失真比透视锯齿更难显示。在图7中突出显示的扩张阴影表明射影失真的错误。当摄像头空间中的纹素和光空间的纹素的匹配不是一比一比率时,射影失真就会发生,这是因为关于光摄像头几何体的方向。当几何体的切平面与光线平行时会发生射影失真问题。 图7.高射影失真,低射影失真
用来减少射影透视错误的技术也可以用来减轻射影失真。当曲面法线与光正交时,射影失真会发生; 基于光散射的光线方程得出结论:这些表面应该接受较少的光照。 阴影瑕疵和错误的自我阴影
阴影瑕疵(图8),是与错误自我阴影相同意思的术语,当阴影贴图将整个纹素转换深度时,会发生这种情况,当着色器将实际深度与此值进行比较时,很容易产生自我阴影。
阴影瑕疵的另一个原因是纹素在光空间中非常接近阴影贴图中对应纹素的深度,导致精度错误使深度测试错误失败。这种精度差异的原因之一是:深度图通过固定功能栅格化硬件计算,但是深度是由着色器计算。射影失真也会导致阴影瑕疵。 图8. 阴影瑕疵伪像
如左图所示,一些像素深度测试失败,并创造了有斑点的伪像和波纹图案。为了减少错误的自我阴影,应该尽可能精密地计算近平面和远平面的光空间视景体的边界。斜面基于尺寸深度偏移和其他类型的偏移是其他用来减少阴影瑕疵的方法。 PeterPanning
Peter Panning术语源自一本儿童书籍中的人物名字,这个人可以飞,而且人、影分离。这种伪像让物体和影子分离,好像物体漂浮在表面上方一样(图9)。 图9. Peter Panning伪像
在左图,阴影脱离对象,造成一个浮动的效果。
去除表面瑕疵的一个技术就是在光空间中将一些值添加到像素的位置;这就是所谓的添加深度偏移量。当使用的深度偏移量太大时,会出现Peter Panning结果。在这种情况下,深度偏移导致深度测试错误地通过。像影子瑕疵, Peter Panning会加重,当深度缓冲区中精度不够高时。仔细计算近平面和远平面也可以帮助避免Peter Panning的现象出现。 改进阴影贴图的技巧
将阴影添加到主题是这样一个过程,第一步是要让基本阴影贴图起作用。二是要确保所有基本的计算以最佳方式完成︰视景体尽可能紧密适合,近/远平面紧密结合,使用坡度尺偏移等等。一旦基本的阴影被启用,并且看起来尽可能好,开发者会想出获得足够保真度阴影所需的更好的算法。在这一节中,我们给出可能需要的最好的基本阴影贴图的基础技巧。 坡度尺深度偏移
如前文所述,自我阴影可以导致阴影瑕疵。添加太多的偏移会导致Peter Panning。另外,含陡坡的多边形(相对于光) 比含均匀坡度的多边形(相对于光)具有更多的射影失真。正因为如此,每个深度贴图值可能需要根据多边形相对于光的边坡,设定不同的偏移量。
Direct3D10 硬件有能力根据多边形相对于视图方向的斜率偏移多边形。这种功能会产生如下影响:让在光方向边缘上才能看到的多边形具有巨大的偏移量,但是直面光的多边形的偏移量不变。图 10 显示了在相同无偏移斜坡的测试情况下,两个相邻的像素是如何在阴影和无阴影间切换的。 图10. 坡度尺深度偏移与无偏移深度对比
计算紧密投影
将光的投影与视景体紧密结合增加了阴影贴图的覆盖范围。图11显示了使用任意阴影投射,或者让投影适应场景限制会导致更高的投射失真。 图11. 适合场景的任意阴影视景体和阴影视景体
这是光视角的视图。梯形代表摄像头的视景体。在图像绘制的网格表示阴影贴图。右图显示了当阴影贴图更紧密适应场景时,其创建更大纹素范围相同的解决方案。
图12显示了正确适应场景的视景体。为了计算投影,组成视景体的八个点转换成光空间。接下来,可以找到X和Y的最小值和最大值,这些值组成了正交投影的边界。 图12. 适合视图视景体的阴影投影
也有可能将椎体裁剪到场景AABB来得到更严格的限制。但是在所有情况下都不建议这么做,因为这样可能会一帧帧改变光摄像头投影的尺寸。许多技术,如在以纹素尺寸增量移动光这一部分所提到的——当光投影的尺寸在每一帧都保持常量时,结果会更好。 计算近平面和远平面
计算近平面和远平面是计算投影矩阵所需的最后一部分,平面距离越近,深度缓冲区中的值精度越高。
深度缓冲区可以是16位,24位或者32位,值在0到1之间。总的来说,深度缓冲区是固定的点,比起接近于远平面的点来讲,接近于近平面的点的值聚合更紧密。近平面和远平面的比率决定了深度缓冲区的可用精度,使用最紧密的近/远平面可以允许16位深度缓冲区的使用。在提升处理速度的过程中,16位的深度缓冲区可以减少内存的使用。 基于AABB的近平面和远平面
计算近平面和远平面的一个简单方法是把场景的包围体转成光空间。最小的 Z坐标值是近平面,最大的Z坐标值是远平面。对于许多场景和光的配置来说,这种方法就足够了。然而,在最坏的情况下,可能导致深度缓冲区重大的精度损失;图13显示了这样的情景,在图中,从近平面到远平面的距离比所需的大四倍。
在图 13 中,视景体故意被选得很小。小的视景体在一个很大的场景中显示,该场景由从观景摄像头延伸出的柱体组成。为近平面和远平面使用场景 AABB不是最优的。技术文章中描述的 CSM 算法必须是为非常小的截头椎体才能计算近远平面。 图 13.基于场景AABB的近和远平面
基于视景体的近平面和远平面
计算的远近的平面的另一个技巧是分别利用近远平面Z的最小值和最大值将视景体转成光空间。图 14 说明了这种方法的两个问题。首先,计算太保守了,如图所示,当视景体超出场景的几何体时会出现问题。其次,近平面可能太紧密,造成要裁剪阴影投射器。 图 14.只基于视景体的近远平面
与场景相交的光椎体计算近远平面
计算远近飞机的正确方法如图 15 所示。使用光空间中视景体的X和Y坐标最小值和最大值计算四个正交光锥的平面。正交视锥的最后两个平面就是近平面和远平面。若要查找这些平面,场景的界限都是根据四个已知的光锥平面裁剪的。来自新裁剪边界的Z的最小和最大值分别代表近平面和远平面。
执行这部分操作的代码在CascadedShadowMaps11示例中。组成全景AABB的八个点转换成光空间。把这些点转成光空间简化了裁剪测试。光椎体已知的四个平面现在可以按行呈现。这六个四边形之后被裁剪成成12个三角形,这些三角形是根据视景体的已知平面裁剪的(这些都是在光空间中X 和 Y轴上水平和垂直的线)。当找到X和Y的焦点,3D三角形就在那一点被裁剪。所有裁剪三角形Z的最小值和最大值就是近平面和远平面。CascadedShadowMaps11实例显示了如何在ComputeNearAndFar函数中实现这种裁剪。 还有两种技术,可以用来计算尽可能最紧密的近平面和远平面。这些技术不在CascadedShadowMaps 示例中。 通过将场景中场景的层次或者独立对象和光椎交叉,可以计算更紧密的近平面和远平面。这将是更复杂的计算,而不是 CascadedShadowMaps11 示例中说明的那种计算,对于一些图块,这可能是一种有效技巧。
可以通过取以下的最小值计算远平面 光空间中视景体的最大的深度 视景体和场景AABB交集的最大深度 当在可能索引到视景体外时使用级联的阴影贴图时,这种方法可能有问题。在这种情况下,阴影贴图可能会丢失几何体。图 15。基于四个计算平面的光锥和现场的交集的远近飞机的边界几何
图15.基于光椎体的四个计算平面交集的近远平面和场景的边界几何体
常见工件在阴影图中移动光是波光粼粼的边缘效果。当摄像头移动时,阴影的边缘像素点亮,变暗。这不能看到在静止图像,但它是很明显,在真正的时间分心。图 16 强调了这个问题和图 17 显示了如何的阴影边缘应该看看。 以纹素尺寸的增量移动光 在阴影图中常见的伪像是闪烁边缘效果。当摄像头移动时,阴影的边缘像素点亮,变暗。这不能看到在静止图像中看到,但它是很明显,而且是实时转移的。图16强调了这个问题,图17显示了阴影边缘应该看起来什么样。 闪光的边缘误差会发生,因为每次摄像头移动时都会重新计算光投影矩阵,这将在生成的阴影贴图中产生细微差别。所有下列因素可以影响创建的矩阵来限制场景。 视景体的尺寸 视景体的方向 光的位置 摄像头的位置 每当该矩阵改变时,阴影边缘也会改变。
图16. 闪烁的阴影边缘
当摄像头从左向右移动时,阴影边上的像素会进进出出。
图 17. 没有闪烁边缘的阴影
当摄像机从左到右移动时,阴影边缘保持不变。
对于方向性光源,对于这个问题的解决办法是将X和 Y(即组成正交投影边界的X和Y)的最小/最大值四舍五入成像素尺寸增量。这可以用除法操作、 向下取整操作和乘法操作完成。
123456vLightCameraOrthographicMin /= vWorldUnitsPerTvLightCameraOrthographicMin = XMVectorFloor( vLightCameraOrthographicMin );vLightCameraOrthographicMin *= vWorldUnitsPerTvLightCameraOrthographicMax /= vWorldUnitsPerTvLightCameraOrthographicMax = XMVectorFloor( vLightCameraOrthographicMax );vLightCameraOrthographicMax *= vWorldUnitsPerTThevWorldUnitsPerTexel value is calculated by taking a bound of the view frustum,and dividing by the buffer size.
12FLOAT fWorldUnitsPerTexel = fCascadeBound / (float)m_CopyOfCascadeConfig.m_iBufferSvWorldUnitsPerTexel = XMVectorSet( fWorldUnitsPerTexel, fWorldUnitsPerTexel, 0.0f, 0.0f );限制视景体的最大值会导致适应正交投影更宽松。
值得注意的是:使用这种技术时,纹理的宽度和高度会大1个像素。这可防止阴影坐标索引至外阴影贴图。 背面和正面 阴影贴图应该用用标准背面选择渲染,跳过观察者看不到的对象的栅格化步骤,加速场景渲染。另一个常见的选择是渲染启用正面选择的阴影贴图,这意味着正对观察者的物体被排除了。关于此问题的观点是:它可以帮助改善自我阴影,因为组成物体背面几何体稍稍偏移了。关于此想法有以下两个问题。 任何带有不合适正面或背面的几何物体会在阴影贴图中导致伪像。但是,有不正确的正面或背面几何体会引起其他问题,所以假设正面和背面几何体都是正确的可能比较保险。为像foliage这样的基于sprite的几何体创建背面可能不太实际。 距离像墙这样物体底部很近的Peter
Panning和阴影间隙更容易发生,因为阴影深度差异太小了。 阴影贴图——友好的几何体
当应对像Peter Panning和阴影瑕疵这样的伪像时,为了更高的灵活性,创建能够与阴影贴图完美结合的几何体。
硬边缘是有问题的自我阴影。边缘顶端附近的深度差异是非常小的。即使是一个小的偏移量可以导致物体失去它们的影子 (图 18)。 图 18. 锋利边缘造成源自的深度偏移差距的伪像
像墙这样的狭窄物体,即使它们从不可见也应该有背面,这会增加深度差异。
确保几何体面对的方向是正确的也很重要,物体的外面应该背对,物体的内部应该正对。这对于启用的背面选择渲染是很重要的,对于应对深度偏离影响也很重要。 总结
本篇文章中描述的技术可以用于提升标准阴影贴图的质量。下一步是查看可以和标准阴影贴图完美结合的技术。我们推荐CSMs作为首选技术来对抗透视失真。比例接近过滤或者变异阴影贴图可以用于柔化阴影边缘。获取更多信息,请看技术文章。
参考文献: Donnelly, W., andLauritzen, A. . Symposium on Interactive3D Graphics, Proceedings of the 2006 Symposium on Interactive 3D Graphics andGames. 2006, pp. 161–165.
Engel, Woflgang F.Section 4. Cascaded Shadow Maps. ShaderX5, AdvancedRendering Techniques, Wolfgang F. Engel, Ed. Charles River Media,Boston, Massachusetts. 2006. pp. 197–206.
Stamminger, Marc,and Drettakis, George. . International Conference on ComputerGraphics and Interactive Techniques, Proceedingsof the 29th Annual Conference on Computer Graphics and Interactive Techniques.2002, pp 557–562.
Wimmer, M.,Scherzer, D., and Purgathofer, W. . Eurographics Symposium onRendering. 2004. Revised June 10, 2005. .
【版权声明】 原文作者未做权利声明,视为共享知识产权进入公共领域,自动获得授权;
分类:程序新手圈
请勿发表无意义的内容请勿发表重复内容请勿发表交易类内容禁止发表广告宣传贴请使用文明用语其它
淫秽色情政治倾向人身攻击抄袭剽窃广告刷屏恶意挖坟冒充他人其它
登录后参与讨论。点击}

我要回帖

更多关于 3dmax烘焙阴影贴图 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信