XNA中的阴影效果

编程入门 行业动态 更新时间:2024-10-22 02:51:13
本文介绍了XNA中的阴影效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是文档带有xna 4.0的3D图形" 中的代码示例.当我在本书中构建有关阴影效应"的示例代码失败时.我已经对其进行了编辑,但效果不佳.像这样: -图片效果阴影:效果阴影 [ ^ ] -图片我的代码:我的图片 [ ^ ] 具有xna 4.0代码的-3D图形:代码示例阴影 [ ^ ] -我的代码:我的代码 [ ^ ] 希望你能帮助我! #-------------(编辑-elybob)----------- # #在Compare ++(文件夹diff模式)中打开了两个文件夹 #以下是相对于代码(逐个区分)的信息 #文字是从原始海报的角度而言的 #----------------------------------------------- 它说内容文件夹是相同的. 有2个不同的文件. Game1.cs(我的):

This is code sample in document "3D graphic with xna 4.0". And When I built sample code about "Shawdow effect" in this book has failed''. I have edit it but it were not good. Like this: -Picture effect shadow: effect shadow[^] -Picture my code: my picture[^] -3D graphic with xna 4.0 code: code sample shadow[^] -My code: my code[^] Hope you help me!! #-------------(edit - elybob)----------- # # opened up the two folders in Compare++ (folder diff mode) # Below is the information which is relivant from the code (diff-wise) # wording is in terms of original posters perspective #----------------------------------------------- and it says that the content folders are the same. there are 2 files which are not the same. Game1.cs (mine):

new PPPointLight(new Vector3(0, 1000, -1000), Color.White * .85f, 2000000), new PPPointLight(new Vector3(0, 1000, 1000), Color.White * .85f, 2000000),

他们的:

theirs:

new PPPointLight(new Vector3(0, 1000, -1000), Color.White * .85f, 20000), new PPPointLight(new Vector3(0, 1000, 1000), Color.White * .85f, 20000),

请注意,我将20000 00 设置为20000 并且我已经添加了我的Draw(mine):

note that I''m setting the 2000000 vs 20000 and I''ve added in my Draw(mine):

// For reach compatibility GraphicsDevice.SamplerStates[0] = SamplerState.AnisotropicClamp;

在PrelightingRenderer.cs中: (我的):

in PrelightingRenderer.cs: (mine):

void drawDepthNormalMap() { // Set the render targets to 'slots' 1 and 2 graphicsDevice.SetRenderTargets(normalTarg); // Clear the render target to 1 (infinite depth) graphicsDevice.Clear(Color.White); // Draw each model with the PPDepthNormal effect foreach (CModel model in Models) { model.CacheEffects(); model.SetModelEffect(depthNormalEffect, false); model.Draw(Camera.View, Camera.Projection, ((FreeCamera)Camera).Position); model.RestoreEffects(); } // Set the render targets to 'slots' 1 and 2 graphicsDevice.SetRenderTargets(depthTarg); // Clear the render target to 1 (infinite depth) graphicsDevice.Clear(Color.White); // Draw each model with the PPDepthNormal effect foreach (CModel model in Models) { model.CacheEffects(); model.SetModelEffect(depthNormalEffect, false); model.Draw(Camera.View, Camera.Projection, ((FreeCamera)Camera).Position); model.RestoreEffects(); } // Un-set the render targets graphicsDevice.SetRenderTargets(null); }

他们的:

theirs:

void drawDepthNormalMap() { // Set the render targets to 'slots' 1 and 2 graphicsDevice.SetRenderTargets(normalTarg, depthTarg); // Clear the render target to 1 (infinite depth) graphicsDevice.Clear(Color.White); // Draw each model with the PPDepthNormal effect foreach (CModel model in Models) { model.CacheEffects(); model.SetModelEffect(depthNormalEffect, false); model.Draw(Camera.View, Camera.Projection, ((FreeCamera)Camera).Position); model.RestoreEffects(); } // Un-set the render targets graphicsDevice.SetRenderTargets(null); }

还(我):

also (mine):

// Draw the point-light-sphere // For reach compatibility ///////////////////////////////////////////////////// graphicsDevice.SamplerStates[0] = SamplerState.AnisotropicClamp; graphicsDevice.SamplerStates[1] = SamplerState.AnisotropicClamp; graphicsDevice.SamplerStates[2] = SamplerState.AnisotropicClamp; lightMesh.Meshes[0].Draw();

他们的:

theirs:

// Draw the point-light-sphere lightMesh.Meshes[0].Draw();

推荐答案

我不知道"记得确切的规格.但是,我知道阴影的API截面对于使用哪种硬件功能非常挑剔.您可以从以下资源开始: xbox.create.msdn/zh-CN/education/catalog/sample/shadow_mapping_1 [ ^ ] xboxforums.create.msdn/forums/p/50998/307994.aspx [ ^ ] 改善阴影深度图的常用技术 [ ^ ] xbox.create.msdn/zh-CN/education/catalog/sample/avatar_shadows [ ^ ] 我建议您的图形车是否具有修改驱动程序设置的能力,以进行尝试(请务必记下启动状态,以便在不起作用时可以撤消所做的任何更改)... 我不想成为坏消息的承担者,但是如果这不能解决问题,并且代码在另一台计算机的图形卡上运行,则可能需要外出并升级图形卡. ... I don''t remember the exact Spec., however I know that the API cross section for shadows was very picky as to which hardware capabilities it works with. you can start with these resources: xbox.create.msdn/en-US/education/catalog/sample/shadow_mapping_1[^] xboxforums.create.msdn/forums/p/50998/307994.aspx[^] Common Techniques to Improve Shadow Depth Maps[^] xbox.create.msdn/en-US/education/catalog/sample/avatar_shadows[^] I recommend if your graphics car has the ability to modify driver settings, to try that out (be sure to write down the starting state, so you can undo any changes you make if they do not work)... I don''t want to be the bearer of bad news, but if that doesn''t fix it, and the code runs on a different machine''s graphics card, you may need to go out and upgrade your Graphics card....

更多推荐

XNA中的阴影效果

本文发布于:2023-11-12 03:52:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580439.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:阴影   效果   XNA

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!