Re: [osg-users] Mipmapping for downsampling

2012-09-28 Thread Kenzo Lespagnol
Hi Sebastian,

Ok, I've displayed the different mipmap in my application and I realized that a 
black square is propagated along the different mipmap level (see pictures). 
Finally the last level became completely black. 
We solved the problem by changing the model involved.

Thanks for the precious advices,
Kenzo

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50346#50346




Attachments: 
http://forum.openscenegraph.org//files/mipmap7_205.png


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Mipmapping for downsampling

2012-09-28 Thread Sergey Polischuk
Hi

looks like you was hitting NaN's somewhere, as they propagate in such fashion.

Cheers.

28.09.2012, 18:11, Kenzo Lespagnol kenzo.lespag...@cm-labs.com:
 Hi Sebastian,

 Ok, I've displayed the different mipmap in my application and I realized that 
 a black square is propagated along the different mipmap level (see pictures). 
 Finally the last level became completely black.
 We solved the problem by changing the model involved.

 Thanks for the precious advices,
 Kenzo

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=50346#50346

 Attachments:
 http://forum.openscenegraph.org//files/mipmap7_205.png

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Mipmapping for downsampling

2012-09-27 Thread Sebastian Messerschmidt

Okay, one last try:

1. Have you tried showing the last mip-level (i.e. avg. lum) in a 
separate window so you can check the value?
2. Have you double checked your actual tone-mapping? (say by providing 
the average luminance via uniform)?


I'm asking this rather silly questions, because last time I looked for 
an error I simply assumed the error to be in a step where indeed it was 
not ;-)



cheers
Sebastian

Thank you Sebastian for your support. I appreciate it.



More or less. I don't know the exact wording from the specification, but
the mipmapping should actually do a bilinear interpolation for 4
neighbouring texels per mip level. I've found many examples that used
the last LOD for average lum.


This is what I expecting from the mipmapping to implement my tone mapping 
algorithm.



That looks okay. I suppose you are using FrameBuffer Objects and this
the setup code for the texture.

Exactly, I'm using FBO to render-to-texture.


Code:
mainCamera-setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT, 
osg::Camera::PIXEL_BUFFER_RTT);






Have you simply tried the 1000.0 (it is clamped to the last level)?

Yes I've tried it. But still the issue.



Can you maybe provide a screenshot of your artifacts?

Actually a screenshot will not help you as there is no really artifact. 
Basically the screen is flashing. Some particularly views give a brighter image 
as no tone mapping was disable. At this moment if I move just a bit the image 
come back darker as expected from my tone mapping. It's little bit weird... I'm 
wondering if it is actually the mipmapping or if it is conflicting with an 
other stuff.

Thanks a lot,
Kenzo

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50322#50322





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Mipmapping for downsampling

2012-09-26 Thread Sebastian Messerschmidt

Hi Kenzo.

I think you are misinterpreting the last argument to the textureLod, 
which is an offset IIRC.


I use the following to sample the last level (which is 1 px and gives 
you exactly the average):


exp(texture2DLod(LuminanceSampler, vec2(0.5,0.5), 1000.0));

cheers
Sebastian










Hi,

I've managed to generate my mipmap via the hardware. But I'm guessing I don't 
have the good mipmap as the result of my tone mapping is unstable. The screen 
is brighter in a jerky manner for some position of the camera.

As below, how to create my mipmap:

Code:

osg::ref_ptrosg::Texture2D tex2D = 
dynamic_castosg::Texture2D*(logAveragedLumTexture.get());
tex2D-setNumMipmapLevels(9);
tex2D-setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
tex2D-setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR);




Then I'm retrieving the values of the smallest mipmap (2x2), by accessing to 
the LOD level 9 as my texture is 512 by 512 as the beginning:

Code:

// get last mipmap level as 2x2 texture
vec4 lastMipmapLevel;
lastMipmapLevel.x = textureLod(logAveragedLumTexture, vec2(0.25, 0.25), 9.0).r;
lastMipmapLevel.y = textureLod(logAveragedLumTexture, vec2(0.75, 0.25), 9.0).r;
lastMipmapLevel.z = textureLod(logAveragedLumTexture, vec2(0.25, 0.75), 9.0).r;
lastMipmapLevel.w = textureLod(logAveragedLumTexture, vec2(0.75, 0.75), 9.0).r;




I'm not sure about the way to access to my mipmap. I've tried other texture 
coordinates but the results is still unstable.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50295#50295





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Mipmapping for downsampling

2012-09-26 Thread Kenzo Lespagnol
Hi Sebastian,

I've followed your advice, but I've still the issue. So it's seems I'm using a 
wrong way to generate my mipmaps. Is hardware mipmap generation actually 
average the values between the different mipmap levels?


Code:
logAveragedLumTexture-setUseHardwareMipMapGeneration(true);
logAveragedLumTexture-allocateMipmapLevels();
osg::ref_ptrosg::Texture2D tex2D = 
dynamic_castosg::Texture2D*(logAveragedLumTexture.get());
tex2D-setNumMipmapLevels(numMipMap);
tex2D-setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_NEAREST);




About the last parameter, I've checked the OpenGL specifications and I'm 
understanding that the last parameter will correspond to the lod level if no 
bias is given. See section 8.14.1, formula (8.4), (8.5) and (8.6).

Thank you!

Kenzo

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50315#50315





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Mipmapping for downsampling

2012-09-26 Thread Sebastian Messerschmidt

Am 26.09.2012 17:27, schrieb Kenzo Lespagnol:

Hi Sebastian,

I've followed your advice, but I've still the issue. So it's seems I'm using a 
wrong way to generate my mipmaps. Is hardware mipmap generation actually 
average the values between the different mipmap levels?
More or less. I don't know the exact wording from the specification, but 
the mipmapping should actually do a bilinear interpolation for 4 
neighbouring texels per mip level. I've found many examples that used 
the last LOD for average lum.



Code:
logAveragedLumTexture-setUseHardwareMipMapGeneration(true);
logAveragedLumTexture-allocateMipmapLevels();
osg::ref_ptrosg::Texture2D tex2D = 
dynamic_castosg::Texture2D*(logAveragedLumTexture.get());
tex2D-setNumMipmapLevels(numMipMap);
tex2D-setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_NEAREST);
That looks okay. I suppose you are using FrameBuffer Objects and this 
the setup code for the texture.





About the last parameter, I've checked the OpenGL specifications and I'm 
understanding that the last parameter will correspond to the lod level if no 
bias is given. See section 8.14.1, formula (8.4), (8.5) and (8.6).
Okay, but the last mip levels number  is dependent on the texture 
resolution.

Have you simply tried the 1000.0 (it is clamped to the last level)?
Also: as you put the log of the luminance into the texture, you must 
uncompress it afterwards (i.e. pow) to get the average in linear space.


Can you maybe provide a screenshot of your artifacts?



Thank you!

Kenzo

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50315#50315





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Mipmapping for downsampling

2012-09-26 Thread Kenzo Lespagnol
Thank you Sebastian for your support. I appreciate it.


 More or less. I don't know the exact wording from the specification, but 
 the mipmapping should actually do a bilinear interpolation for 4 
 neighbouring texels per mip level. I've found many examples that used 
 the last LOD for average lum.


This is what I expecting from the mipmapping to implement my tone mapping 
algorithm.


 That looks okay. I suppose you are using FrameBuffer Objects and this 
 the setup code for the texture.

Exactly, I'm using FBO to render-to-texture.


Code:
mainCamera-setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT, 
osg::Camera::PIXEL_BUFFER_RTT);





 Have you simply tried the 1000.0 (it is clamped to the last level)?

Yes I've tried it. But still the issue.


 Can you maybe provide a screenshot of your artifacts?

Actually a screenshot will not help you as there is no really artifact. 
Basically the screen is flashing. Some particularly views give a brighter image 
as no tone mapping was disable. At this moment if I move just a bit the image 
come back darker as expected from my tone mapping. It's little bit weird... I'm 
wondering if it is actually the mipmapping or if it is conflicting with an 
other stuff.

Thanks a lot,
Kenzo

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50322#50322





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Mipmapping for downsampling

2012-09-25 Thread Kenzo Lespagnol
Hi,

I'm currently implementing my own global tone mapping (without osgPPU). As a 
first iteration, I'm averaging the luminance by using hardware mipmap 
generation. Then I'm wondering if there is a mean to retrieve the last level of 
mipmapping from a osg::Texture?

Is someone have a useful link I missed during my searchs? A example will be 
also appreciated.

Thank you!

Cheers,
Kenzo

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50237#50237





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Mipmapping for downsampling

2012-09-25 Thread Kenzo Lespagnol
Hi,

I've managed to generate my mipmap via the hardware. But I'm guessing I don't 
have the good mipmap as the result of my tone mapping is unstable. The screen 
is brighter in a jerky manner for some position of the camera. 

As below, how to create my mipmap:

Code:

osg::ref_ptrosg::Texture2D tex2D = 
dynamic_castosg::Texture2D*(logAveragedLumTexture.get());
tex2D-setNumMipmapLevels(9);
tex2D-setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
tex2D-setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR);




Then I'm retrieving the values of the smallest mipmap (2x2), by accessing to 
the LOD level 9 as my texture is 512 by 512 as the beginning:

Code:

// get last mipmap level as 2x2 texture
vec4 lastMipmapLevel;
lastMipmapLevel.x = textureLod(logAveragedLumTexture, vec2(0.25, 0.25), 9.0).r;
lastMipmapLevel.y = textureLod(logAveragedLumTexture, vec2(0.75, 0.25), 9.0).r;
lastMipmapLevel.z = textureLod(logAveragedLumTexture, vec2(0.25, 0.75), 9.0).r;
lastMipmapLevel.w = textureLod(logAveragedLumTexture, vec2(0.75, 0.75), 9.0).r;




I'm not sure about the way to access to my mipmap. I've tried other texture 
coordinates but the results is still unstable.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50295#50295





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org