c++ - Shadow map stuck at 1 -


I am following the shadow tutorial and given depth in the combine quad on the screen, I see depth values ​​in depth texture Can i The problem is that when I am sampled with this depth texture, then I get only one value.

In this way I set up a depth texture FBO; The size of the texture is set to the size of the window, I'm not sure that this is part of the problem, but if I try to see the dimensions of the depth and try to see it, I look at the fourth part of a corner of the scene. I thought textures are always used from [0,1]?

  glagfire buffers (1, and framebuffer name); GlobeFramebuffer (GLFFAMFFER, framebuffernname); Glenn Texture (1, and Display Fixtures); Globind Extraction (GL_EditEdda, Renderettecht); GlTexImage2D (GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, FBWITH, FBHEIT, 0, GL_DPTHG, GL_Float, 0); GlTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); GltexPamerMarty (GL_EducationEd.D., GL_WhartWar_User, GLCLAAPMOGOGEG); GlTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); GlTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); Gltexamamarti (GL- especially DD, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); GlTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); GlFramebufferTextxture2D (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, sung, 0); GlDrawBuffer (GL_NONE); GlReadBuffer (GL_NONE); If (Glacframbrarstats (GL_FRAFFER)! = GL_FRAFFACOCAPLEEEE) says that (wrong and framebuffer is not ok);  

The first pass short shader

  150 core in the #version vec3 position; Uniform Mat 4 models; Zero main () {gl_Position = model * vec4 (position, 1.0); }  

The first pass piece shader

  #version 150 core zero main () {// the default gl_FragDepth assignment}}   

the second peak shader shader

  150 core in the vec3 position; Out vec4 shadow cord; Uniform Mat 4 models; Uniform matte camera; Uniform mat 4 depthISMVP; Zero main () {gl_Position = camera * model * vec4 (position, 1.0); ShadowCoord = DepthBiasMVP * vec4 (status, 1.0); }  

The second pass piece shader: in comments stranded in 1 or 0 problems, along with the changes I made

  #version 150 Vec4 Core in shadowCoord; Uniform Mat 4 models; Out vec4 outcolor; // Both types of try / uniform sampling 2D shadow; Uniform Sampler 2D Shadow Shadow Map; Zero main () {vec3 finalColor = ... float visibility = 1.0; Vec3 P = shadowCoord.xyz / shadowCoord.w; // // vec3 P = vec3 (shadowCoord.x, shadowCoord.y, shadowCoord.z) does not work; // No difference / vec3 P = vec3 (Shadow Co. .. Xy, shadowCoord.z ​​/ shadowCoord.w); // also no difference visibility = texture (cinematography, p); // always 1 // when the shadmap sample is set to 2D / vec3 textureCoord = shadowCoord.xyz/ shadowCoord.w; // if (texture (shadowMap, shadowCoord.xy) .z == 0) // always 0 // if (texture (chemap, shadow code.exe) .x == 0) // always 1 // if (Shadow Cord .Z == 0) // always // // visibility = 0.06; // final color * * visibility; OutColor = vec4 (final color, 1.0);}  

this Type I call pass, the object I am looking at is located in the original

  glm :: vec3 srcPerspective (0,0), -4); Glm :: mat4 depth projection matrix = glm :: Ortho; Float & gt; (-1, -1, -1, -110, 10); Glm :: mat4 Depth ViewMatrix = glm :: lookAt (srcPerspective, glm :: vec3 (0,0,0), glm :: vec3 (0,1,0)); // close 1 glideframebuffer (GL_FRAMEBUFFER, framebuffernname); Gluclease (GL_Collo_B_BFFER_BIT | GL_DEPTH_BUFFER_BIT); GlUseProgram (shadowMap.shaderProgram); DeepMVP = Depth ProcessMatics * Depthviewmatics * ModelMatrix; ShadowMap.drawIndexed (world, camera, depthMVP, size [Ship ID]. Mesh.indices.data ()); // near 2 glibbedfreembrother (GL_framebuffer, 0); Gluclease (GL_Collo_B_BFFER_BIT | GL_DEPTH_BUFFER_BIT); GlActiveTexture (GL_TEXTURE0); Globind Extraction (GL_EditEdda, Renderettecht); Glm :: mat4 biasMatrix (0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0); Glm :: mat4 depth BiasMVP = bias matrix * depthMVP; Gluniformmatics 4 FIV (Public, 1, GL_flcey, and Depth BISMVP [0] [0]); Ship.drawIndexed (World, Camera, LightPos, MVP, Ship Chlorer, Shape [Ship IDX]. Mesh.indices.data ());  


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -