Bug #898
Shadows under Linux
| Status: | Closed | Start date: | 05/13/2010 | |
|---|---|---|---|---|
| Priority: | High | Due date: | ||
| Assignee: | % Done: | 100%  | 
||
| Category: | OS: GNU/Linux | |||
| Target version: | Version 0.8.0 | 
Description
Shadows are bugging under Linux (big dark blocks).
Check what could change from Windows version.
History
#1
    
    
    Updated by jayme over 8 years ago
    
    If you enable bloom, the shadows look normal.
#2
    
    
    Updated by kervala over 8 years ago
    
    Thanks a lot ! So it could be related to bloom code :)
#3
    
    
    Updated by Krolock over 8 years ago
    
    hm, if I enable bloom, it doesn't change anything. I have still these dark blocks.
#4
    
    
    Updated by kervala about 8 years ago
    
    Bug seems to be located in driver_opengl_texture.cpp and most precisely in setRenderTarget.
We already had a bug with shadows when bloom was implemented so this part was fixed, but I suspect there is another bug in this method.
Previous code (which was not working properly with bloom) :
 1bool CDriverGL::setRenderTarget (ITexture *tex, uint32 x, uint32 y, uint32 width, uint32 height, uint32 mipmapLevel, uint32 cubeFace)
 2{
 3        H_AUTO_OGL(CDriverGL_setRenderTarget )
 4
 5        // Check the texture is a render target
 6        if (tex)
 7                nlassertex (tex->getRenderTarget(), ("The texture must be a render target. Call ITexture::setRenderTarget(true)."));
 8
 9        _RenderTargetFBO = supportFrameBufferObject();
10        _RenderTargetPackedDepthStencil = supportPackedDepthStencil();
11
12        // make backup of offscreen buffer to old texture if not using FBOs
13        if (!_RenderTargetFBO && _TextureTarget && (_TextureTarget != tex || _TextureTargetCubeFace != cubeFace) && _TextureTargetUpload)
14        {
15                // Flush it
16                copyFrameBufferToTexture (_TextureTarget, _TextureTargetLevel, _TextureTargetX, _TextureTargetY, 0,
17                        0, _TextureTargetWidth, _TextureTargetHeight, _TextureTargetCubeFace);
18        }
19
20        // Backup the texture
21        _TextureTarget = tex;
22
23        // Set a new texture as render target
24        if (tex)
25        {
26                // Backup the parameters
27                _TextureTargetLevel = mipmapLevel;
28                _TextureTargetX = x;
29                _TextureTargetY = y;
30                _TextureTargetWidth = width;
31                _TextureTargetHeight = height;
32                _TextureTargetUpload = true;
33                _TextureTargetCubeFace = cubeFace;
34
35                if (_RenderTargetFBO)
36                {
37                        uint32 w, h;
38                        getWindowSize(w, h);
39
40                        getViewport(_OldViewport);
41                        CViewport newVP;
42                        newVP.init(0, 0, ((float)width/(float)w), ((float)height/(float)h));
43                        setupViewport(newVP);
44                        setupScissor(_CurrScissor);
45                        if (!tex->TextureDrvShare)
46                                setupTexture(*tex);
47                        return activeFrameBufferObject(tex);
48                }
49                else
50                {
51                        // Update the viewport
52                        setupViewport (_CurrViewport);
53                        // Update the scissor
54                        setupScissor (_CurrScissor);
55                        //_RenderTargetFBO = false;
56                        _OldViewport = _CurrViewport;
57                }
58        }
59        else
60        {
61                if (_RenderTargetFBO)
62                        activeFrameBufferObject(NULL);
63                setupViewport(_OldViewport);
64                setupScissor(_CurrScissor);
65                _OldViewport = _CurrViewport;
66                _RenderTargetFBO = false;
67        }
68
69        return true;
70}
#5
    
    
    Updated by vl about 8 years ago
    
    - Status changed from Validated to Assigned
 - Assignee set to kervala
 - Target version set to Version 0.8.0
 
#6
    
    
    Updated by kervala about 8 years ago
    
    Oldest version I found :
1bool CDriverGL::setRenderTarget (ITexture *tex, uint32 x, uint32 y, uint32 width, uint32 height, uint32 mipmapLevel, uint32 cubeFace) 2{ 3 H_AUTO_OGL(CDriverGL_setRenderTarget ) 4 5 // Check the texture is a render target 6 if (tex) 7 nlassertex (tex->getRenderTarget(), ("The texture must be a render target. Call ITexture::setRenderTarget(true).")); 8 9 if(tex==NULL && _RenderTargetFBO) 10 { 11 activeFrameBufferObject(NULL); 12 setupViewport(_OldViewport); 13 _OldViewport = _CurrViewport; 14 15 _RenderTargetFBO = false; 16 return false; 17 } 18 else if(tex && tex->isBloomTexture() && supportBloomEffect()) // && activeFrameBufferObject(tex) 19 { 20 uint32 w, h; 21 getWindowSize(w, h); 22 23 getViewport(_OldViewport); 24 CViewport newVP; 25 newVP.init(0, 0, ((float)width/(float)w), ((float)height/(float)h)); 26 setupViewport(newVP); 27 28 _RenderTargetFBO = true; 29 30 return activeFrameBufferObject(tex); 31 } 32 else 33 { 34 // Have a previous texture ? 35 if (_TextureTarget && (_TextureTarget != tex || _TextureTargetCubeFace != cubeFace) && _TextureTargetUpload) 36 { 37 // Flush it 38 copyFrameBufferToTexture (_TextureTarget, _TextureTargetLevel, _TextureTargetX, _TextureTargetY, 0, 39 0, _TextureTargetWidth, _TextureTargetHeight, _TextureTargetCubeFace); 40 } 41 42 // Backup the texture 43 _TextureTarget = tex; 44 45 // Set a new texture as render target ? 46 if (tex) 47 { 48 // Backup the parameters 49 _TextureTargetLevel = mipmapLevel; 50 _TextureTargetX = x; 51 _TextureTargetY = y; 52 _TextureTargetWidth = width; 53 _TextureTargetHeight = height; 54 _TextureTargetUpload = true; 55 _TextureTargetCubeFace = cubeFace; 56 } 57 58 // Update the viewport 59 setupViewport (_CurrViewport); 60 61 // Update the scissor 62 setupScissor (_CurrScissor); 63 64 _RenderTargetFBO = false; 65 _OldViewport = _CurrViewport; 66 } 67 68 return true; 69}
#7
    
    
    Updated by kervala about 8 years ago
    
    - Status changed from Assigned to Resolved
 - % Done changed from 0 to 100
 
Applied in changeset r270.
#8
    
    
    Updated by kervala about 8 years ago
    
    It was a trivial error... Stencil was not defined :s
I deduced that after investigating more than 10 hours to fix a lot of parts and finally comparing Windows and Linux pixel format settings.
#9
    
    
    Updated by kervala about 8 years ago
    
    - Status changed from Resolved to Assigned
 
I tried with a fresh mercurial and it doesn't seem to be fixed...
#10
    
    
    Updated by kervala about 8 years ago
    
    - % Done changed from 100 to 90
 
#11
    
    
    Updated by kervala about 8 years ago
    
    - Status changed from Assigned to Resolved
 - % Done changed from 90 to 100
 
Applied in changeset r289.
#12
    
    
    Updated by kervala about 8 years ago
    
    Please could you confirm it's working under your configurations ?
#13
    
    
    Updated by jayme about 8 years ago
    
    kervala wrote:
Please could you confirm it's working under your configurations ?
Works for me (with and without bloom).
#14
    
    
    Updated by ThibG about 8 years ago
    
    With bloom, the shadows are buggy and don't get updated (well, the animation is, but not the orientation nor the equipments)
#15
    
    
    Updated by kervala about 8 years ago
    
    Are you using nouveau ?
If yes, it could be a bug in nouveau FBO implementation (or a not yet implemented feature).
#16
    
    
    Updated by kervala about 8 years ago
    
    - Status changed from Resolved to Closed
 
#17
    
    
    Updated by kervala about 8 years ago
    
    - Category changed from NeL: General to OS: GNU/Linux