[osg-users] How to combine soft shadow mapping with normal mapping (and possibly other techs)?

2012-11-12 Thread michael kapelko
Hi.
I know OSG has built-in soft shadow mapping, but I'm not sure if it has
normal mapping.
I only know how to implement normal mapping in GLSL, but not how to combine
built-in OSG soft shadow mapping with custom normal mapping shader.
Please tell me how to do it.
Thanks.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Problem with TBN matrix

2012-11-12 Thread Sebastian Messerschmidt

Hello Peterakos,

Have you checked if the tangent space gives you correct results if 
applied to lighting?
Also I don't understand what you need the tangent space for. Usually the 
fragment's normal is what you already have in the normal-buffer, if 
you doing some sort of deferred shading.
In this case you would write screenspace or viewspace normals to your 
normal-buffer and simply use them in the SSAO pass.
Another issue that comes to mind is that there is no such thing as the 
tangent space of a single fragment, so maybe explain to us, what the 
tangent space is needed for in your opinion.


cheers
Sebastian

Hello.

I try to implement an ssao algorithm, but i cant figure out why the
grey artifacts appear (image 1).

Samples
---
Here i create the sample points that will be checked:

//assume hemisphere
float radius = 1.0f;
for (int i=0; i16; ++i) {
osg::Vec3f sample = osg::Vec3f(
getRandomFloat(-radius, radius),
getRandomFloat(-radius, radius),
getRandomFloat(0, radius)
);
sample.normalize();
uni-setElement(i,sample);
}


Fragment Shader

Here i create the tangent space based on fragment's normal (image 2):

vec3 normal = normalize( getFragNormal() * 2.0 - 1.0 );
vec3 temp_vec = vec3(normal.x, -normal.y, normal.z);
vec3 tangent = normalize(cross(temp_vec, normal));
vec3 bitangent = normalize(cross(normal, tangent));
mat3 tbn = mat3(tangent, bitangent, normal); //Do i have to transpose this ?


And here is the usage of tbn and sample:
vec4 sample_in_view_space = origin + vec4( tbn * sample_kernel[i] , 0);
where origin is the fragments world coordinates.
After that i project the sample back to window coordinates and i test
the depth value.

The first thing that comes to my mind is that i get grey pixels
because there are occluders for those pixels.
That shouldnt be happening, because the hemisphere is normal oriented
according to fragments normal.

Do i miss anything as fas as TBN matrix is concerned  ?

Thank you for your time and sorry for the long post.


___
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


[osg-users] qt rendering thread

2012-11-12 Thread Filip Arlet
Hi,

Current state GraphicsWindowQt uses QTimer and function osgQt::setViewer for 
rendering traversal. It's clever, because Qt and osg events get correctly 
dispatched. But if fps drops, Qt Gui lags, mainly because some events (menu for 
example) will request redraw. I want to render scene in different thread, so it 
will not slow down my app when render slow frame. And maybe reset rendering if 
I for example move my scene.

How to achieve that ?

Thank you!

Cheers,
Filip

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





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


Re: [osg-users] Review of osgQt changes.

2012-11-12 Thread Martin Scheffler
Hi,

I am just learning about the changes to the OpenGL integration in Qt 5.
The new way of dealing with  OpenGL seems to be a lot less retarded than the 
QGLWidget way. You can simply create a QOpenGLContext object in the render 
thread and a QSurface object in the GUI thread and do 
context-makeCurrent(surface). No opengl calls are done implicitly by Qt.
So maybe it would be wise to simply leave the nightmare that is Qt4/OpenGL 
integration behind us and start anew :) 

Cheers,
Martin

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





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


Re: [osg-users] How to combine soft shadow mapping with normal mapping (and possibly other techs)?

2012-11-12 Thread Sebastian Messerschmidt

Hi Michael,

First of all you should search the forum for questions regarding shadow 
mapping and custom shaders.

The general answer is:
Write your own vertex and fragment shaders and simply apply the shadow 
mapping as in the stock shaders by applying the shadow term to your 
lighting.
Look into the source code of the shadow technique, usually there are 
in-code shader sources.


hth
Sebastian

__

Hi.
I know OSG has built-in soft shadow mapping, but I'm not sure if it 
has normal mapping.
I only know how to implement normal mapping in GLSL, but not how to 
combine built-in OSG soft shadow mapping with custom normal mapping 
shader.

Please tell me how to do it.
Thanks.


___
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] Oddities when loading a FLT file

2012-11-12 Thread Paul Martz
I had another thought on this, Chris. Set a breakpoint in the Multiswitch 
constructor and verify that the missing Multiswitch is being created under 
both circumstances. Assuming that test passes, set a breakpoint in the 
Multiswitch destructor, it should get hit when the missing Multiswitch is 
deleted. Then you can look at the call stack and find out why and how it is 
being removed.

   -Paul


On 11/8/2012 7:55 PM, Chris Hanson wrote:


   I've encountered a strange behavior when loading a client-supplied FLT file
and I haven't been able to drill down and find an explanation. I think I know
what must be happening, but I can't find any mechanism to explain how.

   The customer has a TXP database which refers to a FLT model. The FLT model
has a named MultiSwitch node, which controls some LightPointNodes.

   The symptom is that if the FLT file is loaded by itself (into osgViewer.exe
for example) a NodeVisitor of ours is able to locate the MultiSwitch by name. If
the FLT file is loaded via the DataBasePager from the TXP file, the FLT loads,
but the visitor is unable to locate the MultiSwitch.

   Further investigation (adding debug code in a readfilecallback to save out a
temporary .OSG file) reveals that somehow the MultiSwitch is not even in the
resulting graph that gets produced from the FLT file. Converting the FLT file to
OSG via osgconv, or a simple readNodeFile+writeNodeFile at the beginning of
main() however produces an .OSG file that does contain the missing MultiSwitch.

   I've gone so far as to add this debug code at the beginning of main(), as
well as in the readfilecallback that is invoked when the databasepager loads the
FLT file:

osgDB::ReaderWriter::ReadResult result =
osgDB::Registry::instance()-readNodeImplementation(foo.flt,NULL);
osgDB::writeNodeFile(*(result.getNode()), foo.osg);


   I use readNodeImplementation to ensure we're avoiding any callbacks.

  When execute from main(), this code produces a OSG file containing the
MultiSwitch. When copy  pasted to the readfilecallback, it produces a OSG file
lacking the MultiSwitch.
.
   I don't believe the osgUtil Optimizer is in play here, as the databasepager
runs that after the load returns. I don't think any of the FLT loader options (
http://www.openscenegraph.org/projects/osg/wiki/Support/KnowledgeBase/OpenFlight
 )like
preserveObject are affecting things, because I'm passing a NULL options pointer
in both cases.

   What else could be different between these two cases that could lead to a
different graph being produced from the same FLT file, and how do I unify this
to one (correct) behavior? (I wouldn't think preserveObject or other FLT loader
options would be optimizing out a MultiSwitch as redundant anyway, but perhaps
it's misguided.)


   Please grant me some sanity.


--
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com
http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 • GLSL
• OpenGL ES 1 • OpenGL ES 2 • OpenCL
Digital Imaging • GIS • GPS • Telemetry • Cryptography • Digital Audio • LIDAR •
Kinect • Embedded • Mobile • iPhone/iPad/iOS • Android



___
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] Problem with TBN matrix

2012-11-12 Thread Peterakos
Hello.

I use this method: http://www.john-chapman.net/content.php?id=8 for ssao pass.
For each fragment i create a hemisphere of samples. This hemisphere is
oriented based on fragment's normal, which means
the samples have to be oriented based on normal too.

The problem is that i cant be sure for correctness. If i use more
samples, the grey artifacts tend to disappear.
I also use blur for more smooth results.

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


Re: [osg-users] Keyboard handler: SHIFT modifier doesn't work on Linux

2012-11-12 Thread Michael Rubin

robertosfield wrote:
 
 Could you try the osgkeyboard example
 


Example works fine -- thanks for the tip! I've tracked the issue (in my code) 
to masking against osgGA::GUIEventAdapter::KEY_Shift_L instead of (like the 
example) osgGA::GUIEventAdapter::MODKEY_LEFT_SHIFT.

Thank you very much for the quick response,
Mike

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





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


[osg-users] how to use several texture one time?

2012-11-12 Thread wh_xiexing

i have a mesh and want to project several photo on the mesh .   code is here:

osg::Switch *layer = new osg::Switch;
osg::Geode* leaf = 0;
if (!hasTexture){
leaf = createLeaf(points, numOfVert, tris,header.np);
layer-addChild(leaf); 
}else{ 
osg::Group *group = new osg::Group; 
for (unsigned int gr = 0; gr  header.ngr; gr++){ 
/*for every group , load the different texture*/
osg::Texture2D* texture = 0L;
osg::ref_ptrosg::Image image;
if(osgDB::isAbsolutePath(groups[gr].texmap)){
image = osgDB::readImageFile(std::string(groups[gr].texmap));
}else{
std::string absoluteFile = osgDB::getFilePath(fileName) 
+ std::string(/) 
+ std::string(groups[gr].texmap);
image = osgDB::readImageFile(absoluteFile);
} 
texture = new osg::Texture2D;
texture-setImage( image.get() );
if (texture-getImage()!=0L){
group-getOrCreateStateSet()-setTextureAttributeAndModes(gr,texture );
//set texture units
group-getOrCreateStateSet()-setTextureAttribute(gr, new 
osg::TexEnv(osg::TexEnv::DECAL));
} 
/*create group leaf*/
leaf = createLeaf(points, tris_t, groups[gr].poly_begin, groups[gr].poly_end, 
gr);
group-addChild(leaf);
}
layer-addChild(group); 
}

the problem is that just one texture unit works .   
in case :
 for (unsigned int gr = 0; gr  header.ngr; gr++){  unit 0 works 
 for (unsigned int gr = 1; gr  2; gr++){   unit 1 
works


then , how can i show the whole mesh with texture?


thanks in advance



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