Re: [osg-users] Use glTexStorrage to avoid frame rate breaks when osg::ICO is uploading mipmap texture

2014-05-30 Thread Marcel Pursche
Hi, to me this looks like a driver implementation specific problem. I would guess that the nVidia driver only allocates enough memory for the first mipmap-level on the first glTexImage2D. On the second glTexImage2D call it reallocates memory for all mipmap-level and copies the first level to

[osg-users] Pop Buffers with OpenSceneGraph

2014-04-19 Thread Marcel Pursche
Hi, I am currently evaluating different Level Of Detail techniques for my masters thesis. One of them is the relatively new Pop Buffer(http://x3dom.org/pop/) technique. A short summary how the technique works: * Vertex clustering is used to simplify the input geometry. This is implemented by

Re: [osg-users] Built application with pthread openthreads runs only on one core

2014-01-09 Thread Marcel Pursche
Hi, I think I found the source of this bug. There is a Linux specific detail in the pthreads API: The new thread inherits copies of the calling thread's capability sets (see capabilities(7)) and CPU affinity mask (see sched_setaffinity(2)). This can be found in the man page of

Re: [osg-users] How to add shadows to deferred shading?

2013-10-21 Thread Marcel Pursche
Hi, the shadow on the wall is probably created, because the wall is outside of the shadow cameras view frustum. How do you setup the wrapping of your depth texture? You could fix it, if you set the mode to clamp to border and set the border color to your far plane. This way everything that

Re: [osg-users] How to add shadows to deferred shading?

2013-10-20 Thread Marcel Pursche
Hi, the matrix multiplication in OpenSceneGraph works in reverse order. Normally(for example in the shader) MVP = Projection * View * Model is the right order, but in OSG its the other way arround. If you get the same results for View * Projection and Projection * View, one of your matrices is

Re: [osg-users] How to add shadows to deferred shading?

2013-10-17 Thread Marcel Pursche
Hi, it is a bit complex to explain in detail how the projection matrix transforms depth values. In short: the depth is linearized to [0,1] with the near and far plane and after this multiplied with a depth-dependent factor, so that near values take up more space in the depth range than far

Re: [osg-users] How to add shadows to deferred shading?

2013-10-13 Thread Marcel Pursche
Hi, this line seems to be wrong: Code: float depth = texture2D(shadowMap, shadowTexCoord.x/2 + 0.5, shadowTexCoord.y/2 + 0.5).z; it should be Code: float depth = texture2D(shadowMap, vec2(shadowTexCoord.x/2 + 0.5, shadowTexCoord.y/2 + 0.5)).x; Additionally you compare the depth from

Re: [osg-users] How to add shadows to deferred shading?

2013-10-13 Thread Marcel Pursche
Hi, you write the depth in your first texture component(accessed from the shader with .r, .x or .s). But you read it from the third component of your texture(.z). I know it looks confusing at first to read the depth from .x, but this is actually right. Thank you! Cheers, Marcel

Re: [osg-users] How to add shadows to deferred shading?

2013-10-12 Thread Marcel Pursche
Hi, No shadow with 0,0,1 is a bug. I'm not sure where ist comes from. The length in the shader was a test I forgot to revert this change. -viewspacePosition.z shold be used instead in both cases. 1000.0 is my far plane, i write the depth value unormalized [near, far]. Thank you! Cheers, Marcel

Re: [osg-users] How to add shadows to deferred shading?

2013-10-12 Thread Marcel Pursche
Hi, In your current implementation you store your fragment positions in world space and use them for lighting in the final fragment shader. If you pass a matrix uniform to this pass, that translates from world space to screen space of the light pass, you can calculate your shadow texcoords. So

Re: [osg-users] How to add shadows to deferred shading?

2013-10-11 Thread Marcel Pursche
Hi, shadow mapping is a projective texturing approach. A good methaphor to explain it is that from the light source a slide projector is casting the depth buffer on your scene. For this to work you need to do two things: 1. create your depth buffer with screenspace coordinates(the screenspace

Re: [osg-users] How to add shadows to deferred shading?

2013-10-10 Thread Marcel Pursche
Hi, your other buffers use the rectangle format. This texture format can be accesed with unormalized coordinates [0, texturesize]. Regular 2D textures need to be accessed with normalized texture coordinates [0, 1]. Thank you! Cheers, Marcel -- Read this topic online here:

Re: [osg-users] How to add shadows to deferred shading?

2013-10-09 Thread Marcel Pursche
Hi, I think the used data type for the depth texture is set wrong. A depth buffer does not use a floating point type but a fixed point type. When you access the texture in a shader you get values in the range of [0,1]. But it is stored as a 24 bit integer value in the texture. Just like a RGBA8

Re: [osg-users] How to add shadows to deferred shading?

2013-10-09 Thread Marcel Pursche
Hi Sebastian, I never tested the color buffer approach for simple shadow mapping without filtering. I only used it to implement variance shadow mapping(a GL_RG32F texture stores the mean depth value and the variance). The implementation was significantly faster than percentage closer filtering

Re: [osg-users] How to add shadows to deferred shading?

2013-10-09 Thread Marcel Pursche
Hi Sebastian, But in case one is writing to the attached depth target (e.g. a linear depth value) the hierachical culling should be gone AFAIK. Well my idea was to write to the regular color buffer target. The depth target is unaffected. It will still use the logarithmic depth value and

Re: [osg-users] How to add shadows to deferred shading?

2013-10-09 Thread Marcel Pursche
Hi Sebastian, But in case one is writing to the attached depth target (e.g. a linear depth value) the hierachical culling should be gone AFAIK. Well my idea was to write to the regular color buffer target. The depth target is unaffected. It will still use the logarithmic depth value and

Re: [osg-users] How to add shadows to deferred shading?

2013-10-08 Thread Marcel Pursche
Hi, I don't know if you already found the solution to your problem, but this is how you can calculate the camera position in worldspace: Code: vec4 cameraPos_wordspace = osg_ViewMatrixInverse * vec4(0.0, 0.0, 0.0, 1.0); The rotation and scale factors can be found in the first three rows

Re: [osg-users] How to add shadows to deferred shading?

2013-10-07 Thread Marcel Pursche
Hi, your comments are looking good so far. A good name for the posDir_worldspace would be view direction or eye direction. In most lighting formulas it is abbreviated with V or E. It is the direction from the vertex to the eye/camera. There are good wikipedia articles that explain the

Re: [osg-users] How to add shadows to deferred shading?

2013-10-07 Thread Marcel Pursche
Hi, your right, this part of the shader code is wrong. This direction needs to be calculated: Code: posDir_worldspace = normalized(camera_worldspace-p_worldspace); The way it is done in the shader only works for viewspace positions, as the camera position is always 0,0,0 in viewspace

Re: [osg-users] How to add shadows to deferred shading?

2013-10-04 Thread Marcel Pursche
Hello, I can't give you a example code but a general concept. The most commonly used technique to create shadows nowadays is shadow mapping. The basic idea is to render in a depth buffer from the light source looking to the scene. The projection and model view matrix, that was used to generate

Re: [osg-users] reflection / refraction clip plane

2013-09-18 Thread Marcel Pursche
Hello Daniel, what kind of graphics card are you using? ATI/AMD? And are you using a vertex shader for your terrain? I had a similiar problem with reflections in osgOcean. The solution was to add the line gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex; to my vertex shader. On nVidia cards this

Re: [osg-users] OSG errors when running on a virtual machine

2013-09-05 Thread Marcel Pursche
Hi, it looks like the driver in your virtual machine does not support OpenGL =2.0. The function pointers for some newer features can not be found. So things like shaders, occlusion queries, framebuffers and instancing will not work. If fear there is nothing much you can do about that. You can

Re: [osg-users] OSG errors when running on a virtual machine

2013-09-05 Thread Marcel Pursche
Hi, according to the homepage of VMWare they support DirectX 9.0 and OpenGL 2.1 and VirtualBox has DirectX 9.0 and OpenGL(no version mentioned) support. So hardware accelaration should work, if a new version of VMWare or VirtualBox is used. Thank you! Cheers, Marcel -- Read

Re: [osg-users] Performance of Uniform-Buffer-Objects and question to the software design of osg::BufferObject

2013-08-29 Thread Marcel Pursche
Hi Aurelien, Thank you, for your answer. I suspected something like this, but I was not sure if I was right. It looks like I am using the cache for the uniform buffers in a very bad way, because I change the data so often. As you suggested I'm currently trying out storing the matrices in a

[osg-users] Performance of Uniform-Buffer-Objects and question to the software design of osg::BufferObject

2013-08-28 Thread Marcel Pursche
Hi, I am currently evaluating the performance of uniform buffer objects vs. regular uniforms. My demo applications uses hardware instancing to render thousands of quads that represent grass. The geometry is static in my demo. I tried out different approaches to store the model matrix for each

Re: [osg-users] Performance of Uniform-Buffer-Objects and question to the software design of osg::BufferObject

2013-08-28 Thread Marcel Pursche
Hi, I tested it on a nVidia GTX670, driver version 314.22 for Windows 7 x64. Thank you! Cheers, Marcel -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56011#56011 ___ osg-users mailing list

[osg-users] [ANN] Blog and github repository with OpenSceneGraph Examples

2013-08-27 Thread Marcel Pursche
Hello dear OSG-community, I want to present you my new blog Advanced 3D Computer Graphic Tutorials (http://3dcgtutorials.blogspot.de/). It could be interesting to some of you. Among other topics, there will be some tutorials for OpenSceneGraph. The tutorials are not meant as an introduction to

Re: [osg-users] [ANN] Visual Studio 2012 Binaries Available

2013-08-22 Thread Marcel Pursche
Hello John, thank you for providing Visual Studio 2012 binaries, this saves me alot of time. I have noticed that the link for the 3.2.0 includes is broken. I made an educated guess and tried http://www.helleboreconsulting.com/downloads/OpenSceneGraph_v3_2_0_Includes.zip and it worked. So

Re: [osg-users] Problem when using DrawCallbacks with nested cameras

2013-05-30 Thread Marcel Pursche
Hello Robert, thank you for your help. Using mutliple RTT Cameras worked, but I went back to using just a single one. Executing mutliple read backs per frame had a huge impact on the performance. I just changed inherhitance mask of the read back camera that it doesn't inherit the cull mask.

[osg-users] Problem when using DrawCallbacks with nested cameras

2013-05-22 Thread Marcel Pursche
Hi, I'm currently having a problem in understanding, when the PreDrawCallback and PostDrawCallback of a camera are called. I'm working on a project where Virtual Texturing and Depth Peeling is used. For Virtual Texturing the following steps are necessary: 1. Render whole scene with special

Re: [osg-users] Problem when using DrawCallbacks with nested cameras

2013-05-22 Thread Marcel Pursche
Hi, I found the cause of the problem myself. When the scene graph is traversed a osgUtil::RenderStage is created for the camera and added to the RenderCache of the camera. So only one RenderStage per CullVisitor is created. When the RenderStage is drawn it sets a flag that is was already drawn

Re: [osg-users] Order Independent Transparancy with Per-Pixel-Linked-Lists

2013-04-25 Thread Marcel Pursche
Hi, after reading some of the commit messages it looks like not all necessary api methods are integrated in OpenSceneGraph right now. glMemoryBarrier for example is not called anywhere but necessary to make sure all data is written to the image before starting the next rendering stage. So my

[osg-users] Order Independent Transparancy with Per-Pixel-Linked-Lists

2013-04-23 Thread Marcel Pursche
Hi, I recently checked out the newest development release of OSG (version 3.1.5). After playing around with the osgatomiccounter and osgcomputeshader examples I tried to implement order independent transparency with per pixel linked lists as mentioned in this presentation: click!

Re: [osg-users] Order Independent Transparancy with Per-Pixel-Linked-Lists

2013-04-23 Thread Marcel Pursche
Hi, Thank you for your response. To be honest your raw OpenGL example was the first I have found, when I was searching for an implementation of this technique. It gave me the idea to implement it with OpenSceneGraph right now ;) As far as I can see you are using nVidia specific extensions in