我目前在使用英特尔高清图形硬件来实现阴影映射效果时遇到问题。我认为代码与我想要的结果相差不远,因为此代码片段在 ATI Mobility Radeon 5650 和 Nvidia NVS 4200M 上运行良好,但在 Intel HD 3000 和 4000 上不起作用。
GL.GenTextures(1, out ShadowMap);
GL.BindTexture(TextureTarget.Texture2D, ShadowMap);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Clamp);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Clamp);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureCompareFunc, (int)All.Lequal);
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.DepthComponent32, SHADOW_MAP_SIZE, SHADOW_MAP_SIZE, 0, OpenTK.Graphics.OpenGL.PixelFormat.DepthComponent, PixelType.Float, IntPtr.Zero);
GL.BindTexture(TextureTarget.Texture2D, 0);
GL.GenFramebuffers(1, out FBO);
GL.BindFramebuffer(FramebufferTarget.Framebuffer, FBO);
DrawBuffersEnum dbe = DrawBuffersEnum.None;
GL.DrawBuffers(0, ref dbe);
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, TextureTarget.Texture2D, ShadowMap, 0);
FramebufferErrorCode status = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer);
GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
“status”变量表示 FramebufferIncompletReadBuffer,因此使用此 fbo 将不正确(从灯光 POV 渲染场景)。我一直在网上看到这种状态,但我没有找到解决我问题的答案。所以我在这个片段上做错了什么和/或这个 FBO 问题的起源是什么。提前致谢。PS:在着色器中,我使用 1.2 版本,我应该将 ShadowMap 纹理采样为深度图。