[osg-users] Website not reachable from france and austria

2009-05-30 Thread Johannes Schüth
Hi,

i can access:

blog.openscenegraph.org
forum.openscenegraph.org

but not www.openscenegraph.org / openscenegraph.org

Seems to be a dns problem?

ping www.openscenegraph.org
PING lemonvm-osg.ai2.upv.es (158.42.9.50) 56(84) bytes of data.

Thank you!

Cheers,
Johannes

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





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


[osg-users] Projective Texturing does not work when using shaders

2009-05-30 Thread Johannes Schüth
Hi,

when i'm using shaders instead of fixed functionality to create projective 
textures the resulting texture mapping is a tiny spot in the center of the 
terrain model.

[Image: http://www.jotschi.de/download/osg/projection_shader.jpg ]

If i disable the shaders by removing the follwing line i get a correct 
projection as you can see in the image below.

Code:

/* 4. Enable this to see that the shader is not working :\ */
stateset->setAttribute(projProg.get());



[Image: http://www.jotschi.de/download/osg/projection_fixedfunctionality.jpg ]


I belive i do something wrong about the texture matrix generation.


My vertex shader just calculates the texture coordinate for the given vertex by 
using the texture matrix 1:

Code:

varying vec4 projCord;
void main()
{
projCord= gl_TextureMatrix[1] * gl_Vertex;
gl_Position = ftransform();
gl_FrontColor = gl_Color;
}




My fragment shader uses the given projCord texture coordinate to load the color 
data from the given projectionMap texture:

Code:

uniform sampler2D projectionMap;
varying vec4 projCord;
void main()
{
vec4 shadowCoordinateWdivide = projCord / projCord.w ;
shadowCoordinateWdivide.z += 0.0015;
vec4 color = texture2D(projectionMap,shadowCoordinateWdivide.st);
gl_FragColor = color * gl_Color;
}







Code:

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

osg::StateSet* createProjectorState() {
osg::StateSet* stateset = new osg::StateSet;

/* 1. Load the texture that will be projected */
osg::Texture2D* texture = new osg::Texture2D();
texture->setImage(osgDB::readImageFile("foo.jpg"));
texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_BORDER);
texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_BORDER);
texture->setWrap(osg::Texture::WRAP_R, osg::Texture::CLAMP_TO_BORDER);
stateset->setTextureAttributeAndModes(1, texture, osg::StateAttribute::ON);

// set up tex gens
stateset->setTextureMode(1, GL_TEXTURE_GEN_S,
osg::StateAttribute::ON);
stateset->setTextureMode(1, GL_TEXTURE_GEN_T,
osg::StateAttribute::ON);
stateset->setTextureMode(1, GL_TEXTURE_GEN_R,
osg::StateAttribute::ON);
stateset->setTextureMode(1, GL_TEXTURE_GEN_Q,
osg::StateAttribute::ON);

/* 2. Load the Shaders */
osg::ref_ptr projProg(new osg::Program);
osg::ref_ptr projvertexShader(osg::Shader::readShaderFile(
osg::Shader::VERTEX, "VertexShader.glsl"));
osg::ref_ptr projfragShader(osg::Shader::readShaderFile(
osg::Shader::FRAGMENT, "FragmentShader.glsl"));
projProg->addShader(projvertexShader.get());
projProg->addShader(projfragShader.get());

/* 3. Handover the texture to the fragment shader via uniform */
osg::Uniform* texUniform = new osg::Uniform(osg::Uniform::SAMPLER_2D,
"projectionMap");
texUniform->set(1);
stateset->addUniform(texUniform);

/* 4. Enable this to see that the shader is not working :\ */
stateset->setAttribute(projProg.get());

return stateset;
}

osg::Node* createModel() {

/* 1. Setup projector parameters */
osg::Group* root = new osg::Group;
osg::Vec3 projectorPos = osg::Vec3(0.0f, 0.0f, 324.0f);
osg::Vec3 projectorDirection = osg::Vec3(osg::inDegrees(0.0f),
osg::inDegrees(280.0f), osg::inDegrees(-460.0f));
float projectorAngle = 110;

/* 2. create tex gen. for the texture unit 1*/
osg::Vec3 up(0.0f, 0.0f, 1.0f);
//up = (projectorDirection ^ up) ^ projectorDirection;
//up.normalize();

osg::TexGenNode* texgenNode = new osg::TexGenNode;
/* As you can see texture unit 1 is assigned the texgenNode. Does this mean the 
texture matrix will be stored in: gl_TextureMatrix[1] ?*/
texgenNode->setTextureUnit(1);
osg::TexGen* texgen = texgenNode->getTexGen();
texgen->setMode(osg::TexGen::EYE_LINEAR);
texgen->setPlanesFromMatrix(osg::Matrixd::lookAt(projectorPos, projectorPos
+ projectorDirection, up) * osg::Matrixd::perspective(
projectorAngle, 1.0, 0.1, 100));


root->addChild(texgenNode);

/* 3. Load the terrain which will be the receiver of out projection */
osg::Node* terr = osgDB::readNodeFile("Terrain2.3ds");

osg::Matrix m;
osg::ref_ptr mt =new osg::MatrixTransform;
m.makeTranslate( 112.f, 410.f, -2.f );
m.makeScale(2.f,2.f,2.f);
mt->setMatrix( m );
root->addChild( mt.get() );
mt->addChild( terr );

//root->addChild(terr);

root->setStateSet(createProjectorState());

return root;
}

int main(int, char **) {
osgViewer::Viewer viewer;
viewer.setSceneData(createModel());
viewer.setUpViewInWindow(0, 0, 1024, 768);
return viewer.run();
}




The complete project can be downloaded here:
http://www.jotschi.de/download/osg/OSG_ProjectiveTexturesExample.tgz

Perhaps you have any tips according to my problem? Maybe i have missed a step 
according to the texture matrix generation? 

Thank you!

Cheers,
Johannes

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





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

Re: [osg-users] smooth angle on normal calculation

2009-05-30 Thread Matthias Asselborn
Hi,

i need a smooth with recalculate normals of 30 degrees 
the left side of picture shows a smoothed version 
with smoot visitor. The right side without it.
can i recalculate the normals to 30 degrees with smooth visitor? 

Thank you!

Cheers,
Matthias

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



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


[osg-users] Osg steteo problems!! Help!!!

2009-05-30 Thread 神和龙
Dears,

 

I have two problems when using osg stereo functions.

  

   1.  When I use this function to configure the fusion distance, 

setFusionDistance(osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE , 
fusionDistance) 

 

It seems none effect. As it is calculated automatically by osg and equals to 
the distance between eye and the center of the scene. How can control it?

 

   2.   How to realize the stereo effect of the prerender texture? 

 

I use a camera to render the normal scene and another prerender camera 
to render the reflect texture of the scene. The normal scene can get stereo 
effects. But the texture in prerender camera couldn't have stereo effects.

   How can the prerender camera are controlled by the stereo parameters.

 

Thank You Very Much.

Best Regards.

Helong
--


以下是签名,请略过。。。
 
  一分之千  沧海一粟
   神和龙___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Getting texture IDs from ive file for passing to shader

2009-05-30 Thread Miroslav Andel
My bad.. I totally mixed up two different things. Thanks for your reply. Works 
great just passing zero as an uniform sampler2D value. 

//Miroslav

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





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


Re: [osg-users] Getting texture IDs from ive file for passing to shader

2009-05-30 Thread Robert Osfield
Hi Miroslav,

I think perhaps you are mixing names of things a bit so your questions
are bit open to confusion.

My best guess to what you are after is not a the texture ID but the
texture unit number that you should bind to the shader using a
uniform.  Which texture units are active in a scene graph are governed
by the StateSet's that are atttached to the Nodes and Drawables in the
scene graph, typically you could probably just assume that texture
unit 0 is active and just bind this value as a uniform.

For examples of settings up shaders with textures have a look at the
osgshader* examples.

Robert.

On Sat, May 30, 2009 at 8:09 AM, Miroslav Andel  wrote:
> Hi,
>
> I'm want to desaturate a model in my scene that is loaded as an ive file. I 
> have a glsl shader that does the desaturation but I need to pass the texture 
> id as argument to the shader. My problem is how to get the texture id(s) from 
> the model node.
>
> I guess I need to create a node visitor to apply the shader to all geodes in 
> the model but whats the propper way to get the texture ids?
>
> Thank you!
>
> Cheers,
> Miroslav
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=13205#13205
>
>
>
>
>
> ___
> 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] UserData

2009-05-30 Thread Robert Osfield
Hi Guy,

This is how I'd do it.  First up you can't multiple buffer UserData
directly, so to do the multi-buffer you'll need to create your own
multibuffer UserData class subclassed from osg::Referenced.  Second to
decide between the two buffers you can use the current osg::RenderInfo
that is passed into the drawImplementation(RenderInfo&) to find out
the current view/camera.

Robert.

On Sat, May 30, 2009 at 1:55 AM, Guy Volckaert
 wrote:
> Hi,
>
> What's the best way to pass user data to all nodes and drawables. For 
> example, lets assumes I have 2 cameras (left & right). Each camera points to 
> the same scene. When rendering the left camera, I want the the nodes and 
> drawables to use userdata1, and when rendering the right camera I want the 
> nodes and drawables to use userdata2.
>
> The goal is to pass thread safe data during the rendering of each camera 
> without having to use a mutext or a critical section to access the data. 
> Since each camera has its own user data "copy" it should be thread safe.
>
> I know that the RenderInfo contains a userdata ptr, but I don't know how to 
> use it as decribed above.
>
> Any suggestions are appreciated.
>
> Thank you!
>
> Cheers,
> Guy
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=13202#13202
>
>
>
>
>
> ___
> 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] Getting texture IDs from ive file for passing to shader

2009-05-30 Thread Miroslav Andel
Hi,

I'm want to desaturate a model in my scene that is loaded as an ive file. I 
have a glsl shader that does the desaturation but I need to pass the texture id 
as argument to the shader. My problem is how to get the texture id(s) from the 
model node.

I guess I need to create a node visitor to apply the shader to all geodes in 
the model but whats the propper way to get the texture ids? 

Thank you!

Cheers,
Miroslav

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





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