Re: [osg-users] Problems with TBO Texture Buffer Object's

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

I'm not quite sure but it seems that 
http://www.opengl.org/registry/specs/ARB/pixel_buffer_object.txt

is something different than:
http://www.opengl.org/registry/specs/EXT/texture_buffer_object.txt

Although the way of binding the buffer seems initially the same. 

I just want to use float's within my shader and beeing able to exchange the 
values quite fast. 

When storing floats within a sampler2d uniforms you have to reinitalise the 
texture each time you change a piece of your data (texture).

When using texture buffer objects you just have to rebind the data object which 
is in my mind faster than texture reinitialization. See 
http://www.jotschi.de/?p=424 for a opengl example.

I belive pbo's can't be used within glsl? Tbo's can. Maybe thats the difference?

Thank you!

Cheers,
Johannes

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





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


Re: [osg-users] Problems with TBO Texture Buffer Object's

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


robertosfield wrote:
 
 Your GL code segment actually uses PBO's in it... :-)
 

Yep :) I think TBO's use PBO calls because its also a buffer object. Bu of 
course i use GL_TEXTURE_BUFFER_EXT.


robertosfield wrote:
 
 Do you have to use PBO's with texture buffer?  Or can you just pass
 the data directly as per normal textures?
 


I'm not quite sure which approach is the most fitting for my usecase. 

I want to be able to create mat4's within my shader. The floats for the mat4's 
comes out of the tbo and of course the floats are very dynamic since the mat is 
calculated within my main program loop. So i need way to fetch floats within my 
shader which do not cost much update time. ( Time to update the uniform value ).

As far as i know:
1. bindable uniforms reduce the update time since you just swap the attached 
buffer object. 
2. tbo's are 1d textures that can hold a huge amount of floats.

Do you have a idea which approach/usage of extensions would be the efficient 
one for my usecase?

Greetings

Jotschi

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





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


[osg-users] Problems with TBO Texture Buffer Object's

2009-11-28 Thread Johannes Schüth
Hi,

i want to use texture buffer objects within my program. 

At the beginning i managed to get tbo's to work within a pure opengl 
application. 

This is what i did:

1. create tbo

Code:

// create buffer object
glGenBuffers(1, tbo);
glBindBuffer(GL_TEXTURE_BUFFER_EXT, *tbo);

// initialize buffer object
unsigned int size = mesh_width * mesh_height * 4 * sizeof(float);
glBufferData(GL_TEXTURE_BUFFER_EXT, size, 0, GL_DYNAMIC_DRAW);

//tex
glGenTextures(1, tex);
glBindTexture(GL_TEXTURE_BUFFER_EXT, *tex);
glTexBufferEXT(GL_TEXTURE_BUFFER_EXT, GL_RGBA32F_ARB, *tbo);
glBindBuffer(GL_TEXTURE_BUFFER_EXT, 0);




2. set data of the tbo

Code:

glBindBuffer(GL_TEXTURE_BUFFER_EXT, tbo);
p = (float4*) glMapBuffer(GL_TEXTURE_BUFFER_EXT, GL_WRITE_ONLY);

for (int u = 0; u  mesh_height; u++) {
for (int v = 0; v  mesh_width; v++) {
p[u + (v * mesh_width)][0] = ((float) u / mesh_height) * 2 - 
(1.0);
p[u + (v * mesh_width)][1] = ((float) v / mesh_width) * 2 - 
(1.0);
p[u + (v * mesh_width)][2] = 0.0f;
p[u + (v * mesh_width)][3] = 1.0f;
}
}
glUnmapBuffer(GL_TEXTURE_BUFFER_EXT);
glBindBuffer(GL_TEXTURE_BUFFER_EXT, 0);




3. set uniform

Code:

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_BUFFER_EXT, displacementTex);




And now i wanted to port this into osg. I have no idea how to create the tbo.

I managed to get as far as:

Code:

osg::BufferObject::Extensions* ext = osg::BufferObject::getExtensions(
_gc-getState()-getContextID(), true);
ext-glBindBuffer(GL_TEXTURE_BUFFER_EXT, tbo);
unsigned int size = mesh_width * mesh_height * 4 * sizeof(float);
ext-glBufferData(GL_TEXTURE_BUFFER_EXT, size, 0, GL_DYNAMIC_DRAW);




Do i have to create a osg::Texture::TextureObject Object to bind it to the 
BufferObject? I do not know how to port these calls:

Code:

glBindTexture(GL_TEXTURE_BUFFER_EXT, *tex);
glTexBufferEXT(GL_TEXTURE_BUFFER_EXT, GL_RGBA32F_ARB, *tbo);




My goal is to create a float buffer object by that i can access a huge amount 
of floats within my shader.

Thank you!

Cheers,
Johannes

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





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


Re: [osg-users] Can't assign more than 7 texture matrices

2009-10-20 Thread Johannes Schüth
Hi,

i belive i solved this issue.

I had to use: 
osg::Uniform* uniform = stateSet-getOrCreateUniform(matrices[0],
osg::Uniform::FLOAT_MAT4);

instead of:

osg::Uniform* uniform = stateSet-getOrCreateUniform(matrices,
osg::Uniform::FLOAT_MAT4);



I found this post from 2006 which discussed this issue while searching for 
opengl uniform array documentation.

http://www.mail-archive.com//msg00140.html

I'm using libopenscenegraph-dev - 2.8.1-1  (Debian Lenny)

Cheers,
Johannes

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





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


Re: [osg-users] Can't assign more than 7 texture matrices

2009-10-19 Thread Johannes Schüth
Hi,

i thought i could use the buildin variabled to save some uniforms. But i did'nt 
realize that they were limited. 

Well..

i tried to use uniform arrays but with very little sucess:

I create my Uniform:

ref_ptrUniform matrixArrayUniform = new 
Uniform(Uniform::FLOAT_MAT4,matrices,10);
stateSet-addUniform(matrixArrayUniform.get());

later i add 10 matrices:

for (int i = 0; i  10; i++) {
matrixArrayUniform-setElement(i, texMat-getMatrix());
}

i defined the uniform within my fragment shader:
uniform mat4 matrices[10];

and tried to access a matrix via matrices[2] for example but with no luck. 

If i use no arrays and limit the size of the uniform to one element everything 
works just as expected.

Must i use something other than osg::Uniform::FLOAT_MAT4?

Greetings,

Johannes

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





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


Re: [osg-users] Can't assign more than 7 texture matrices

2009-10-19 Thread Johannes Schüth
Hi,


Wojciech Lewandowski wrote:
 Hi again Johannes,
 I hate to say that, ( don't think I enjoy doing it), but it seems to work on 
 NVidia (at least those above GF 8x00) and I am really surprised it does not 
 work for you especially when you have advance gpu supporting 
 GL_EXT_gpu_shader4 extension.


Well.. as far as i can tell i don't get any compile warnings. But i will take a 
closer look. I will also try to isolate this issue with pure opengl as i did 
before with the other ati issues. 

Thank you for your answer.

Greetings,

Johannes

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





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


[osg-users] Can't assign more than 7 texture matrices

2009-10-18 Thread Johannes Schüth
Hi,

i have a small problem. I want to access gl_TextureMatrix[8] within my Shader.

As you can see i used a loop to setup 10 texture matrices:

Code:

for (int i = 0; i  10; i++) {
stateSet-setTextureAttributeAndModes(i, texMat,
osg::StateAttribute::ON);
}




But when i try to access gl_TextureMatrix[8] not the matrix i was hoping.

I checked some build in limits for example:
GL_MAX_TEXTURE_UNITS is 34018.

Just change the used  gl_TextureMatrix[n] to n=8 to see that no texture matrix 
is returned.



Code:

#include osg/Group
#include osg/Geode
#include osgViewer/Viewer
#include osgGA/TrackballManipulator
#include osgViewer/CompositeViewer
#include osg/ShapeDrawable
#include osg/Node
#include osg/MatrixTransform
#include osg/TexMat
#include osgViewer/Viewer
#include osg/Texture2DArray
#include osgDB/ReadFile
#include string
#include stdio.h
#include iostream

using namespace osg;

osg::TexMat* texMat = new osg::TexMat;
osgViewer::View* viewB = new osgViewer::View;


void applyShader(Geode* geode) {
ref_ptrProgram program = new Program;
program-setName(TexturesTest);
ref_ptrShader vertObj = new Shader(Shader::VERTEX);
ref_ptrShader fragObj = new Shader(Shader::FRAGMENT);

program-addShader(vertObj.get());
program-addShader(fragObj.get());

ref_ptrStateSet stateSet = new osg::StateSet;
ref_ptrUniform texturesUniform = new 
Uniform(Uniform::SAMPLER_2D_ARRAY,
textures, 1);
stateSet-addUniform(texturesUniform.get());
stateSet-setAttributeAndModes(program.get(), StateAttribute::ON);

ref_ptrTexture2DArray textureArray = new Texture2DArray;
//textureArray-setInternalFormat(GL_RGBA16F_ARB);
//textureArray-setSourceFormat(GL_RGBA);
//textureArray-setSourceType(GL_FLOAT);


textureArray-setFilter(osg::Texture2DArray::MIN_FILTER,
osg::Texture2DArray::NEAREST);
textureArray-setFilter(osg::Texture2DArray::MAG_FILTER,
osg::Texture2DArray::NEAREST);
textureArray-setWrap(osg::Texture::WRAP_S, 
osg::Texture::CLAMP_TO_BORDER);
textureArray-setWrap(osg::Texture::WRAP_T, 
osg::Texture::CLAMP_TO_BORDER);
textureArray-setWrap(osg::Texture::WRAP_R, 
osg::Texture::CLAMP_TO_BORDER);

textureArray-setTextureDepth(2);

textureArray-setImage(0, osgDB::readImageFile(src/foo2.jpg));
textureArray-setImage(1, osgDB::readImageFile(src/foo2.jpg));

stateSet-setTextureAttribute(0, textureArray.get(),
osg::StateAttribute::ON);
for (int i = 0; i  10; i++) {
stateSet-setTextureAttributeAndModes(i, texMat,
osg::StateAttribute::ON);
}

std::string vertSource = varying vec4 vPos;
void main()
{
vPos = gl_Vertex;
gl_Position = ftransform();
};
vertObj-setShaderSource(vertSource);

std::string fragSource = #version 120\n
#extension GL_EXT_gpu_shader4 : enable\n
#extension GL_EXT_texture_array : enable\n
varying vec4 vPos;
uniform sampler2DArray textures;

void main()
{
vec4 coords = gl_TextureMatrix[7] * vPos;
gl_FragColor = texture2DArray(textures, vec3(coords.st, 0));
};
fragObj-setShaderSource(fragSource);

geode-setStateSet(stateSet.get());
}

int main(int argc, char** argv) {
//  setNotifyLevel(osg::DEBUG_INFO);

// Create a cube
ref_ptrGroup rootNode = new Group;
Box* cube = new Box(Vec3(0, 0, 0), 1.0f);
ShapeDrawable* drawable = new ShapeDrawable(cube);
Geode* geode = new Geode();
geode-addDrawable(drawable);
rootNode-addChild(geode);

// Apply our shader to this cube
applyShader(geode);

osg::ArgumentParser arguments(argc, argv);
osgViewer::CompositeViewer viewer(arguments);

viewer.addView(viewB);
viewB-setUpViewInWindow(10, 650, 640, 480);
viewB-setSceneData(rootNode.get());
viewB-setCameraManipulator(new osgGA::TrackballManipulator);

while (!viewer.done()) {

osg::Matrix mat = viewB-getCamera()-getViewMatrix()
* viewB-getCamera()-getProjectionMatrix();
mat = mat * osg::Matrix::scale(0.5, 0.5, 1) * 
osg::Matrix::translate(
0.5, 0.5, 0);
texMat-setMatrix(mat);

viewer.frame();
}
return 0;

}




Is there a buildin limit for texture matrices? Or am i doing something wrong 
about the setup of texture matrices? When iam using the 1-7 matrices everything 
works as expected but i need 

Re: [osg-users] Can't assign more than 7 texture matrices

2009-10-18 Thread Johannes Schüth
Seems to be another ati related issue. I was able to reproduce this issue with 
pure opengl.

:-\

Any suggestions on how i can handover multiple texture matrices to my shader?

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





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


[osg-users] osg::Image SubImage

2009-10-17 Thread Johannes Schüth
Hi,

is there a way of getting a subimage from an osg::Image? I only found the 
option of inserting an image as a portion of a bigger image by using 
osg::Image::copySubImage.

Thank you!

Cheers,
Johannes

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





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


Re: [osg-users] Texture Wrapping Texture2DArray (Clamping doesn't work)

2009-10-11 Thread Johannes Schüth
Hi,

i think i found a workaround that will work for me. I just implemented the 
clamping in my fragment shader myself :) 

Code:

#extension GL_EXT_gpu_shader4 : enable

uniform sampler2DArray base_texture;
varying vec2 texCoord;
void main()
{

vec4 borderColor =vec4(0.1,0.7,0.2,0.1);
if(texCoord.s1  texCoord.s 0  texCoord.t 1  texCoord.t 
0)
{
borderColor = texture2DArray(base_texture, 
vec3(texCoord.st,1));
}
gl_FragColor = borderColor;

}



No need to buy another graphicscard ;)

Cheers,
Johannes

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





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


Re: [osg-users] Texture Wrapping Texture2DArray (Clamping doesn't work)

2009-10-08 Thread Johannes Schüth
Hi,

this is definitly no osg issue - i could reproduce it with nativ opengl.

Just switch to see the difference. 
//#define NOARRAY

http://www.jotschi.de/download/opengl_texture_array_glsl_example.tgz

I will send this to ati / amd though i don't think that will help me in any 
way. 

Cheers,
Johannes

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





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


Re: [osg-users] Texture Wrapping Texture2DArray (Clamping doesn't work)

2009-10-07 Thread Johannes Schüth
Hi,

amazing news - i do own an ATI 4850 - I will try to update my drivers or 
consider to swap to another graphics card. Are you able to test this example 
with an ati card?
Were you able to use CLAMP_TO_BORDER too?

Thank you!

Greetings,
Johannes

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





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


Re: [osg-users] Texture Wrapping Texture2DArray (Clamping doesn't work)

2009-10-07 Thread Johannes Schüth
Hi,

one more question. Did clamp to border work on nvidia chips?

Wojciech Lewandowski wrote:
 
 We tested on ATI 4890. Vista 64 bit. Catalyst 9.9. Clamp to edge works. 
 Clamp to border does not.


Any idea why clamp to border does not work with ATI 4890?

Greetings

Johannes

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





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


Re: [osg-users] Texture Wrapping Texture2DArray (Clamping doesn't work)

2009-10-06 Thread Johannes Schüth
No, not yet. But its a good news to hear that you managed to use 
CLAMP_TO_BORDER - Perhaps this might be a driver problem or maybe there is just 
a problem with my code.
Yes - i use only one texture in the shader - but i have to add two textures to 
the texture array to make it work. You must add at least two textures otherwise 
it might not work. 


Wojciech Lewandowski wrote:
 Johannes,
  I guess something like your code could maybe work with Texture3D where 
 linear filter would interpolate between two layers. But Texture2DArray works 
 like nearest on the trhird coordinate. Write more about your problem maybe we 
 could help if you still 
 need it.
 


I think i will try to isolate the problem and present it in a small example.

Greetings

Johannes

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





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


Re: [osg-users] Texture Wrapping Texture2DArray (Clamping doesn't work)

2009-10-06 Thread Johannes Schüth
Hi,
 
i managed to reproduce the problem. And i even used another much simpler 
shader. This might tell us that the problem is not located in my shaders.


Code:

#include osg/Group
#include osg/Geode
#include osg/ShapeDrawable
#include osg/Node
#include osgViewer/Viewer
#include osg/Texture2DArray
#include osgDB/ReadFile
#include string

using namespace osg;

void applyShader(Geode* geode)
{
ref_ptrProgram program = new Program;
program-setName(TexturesTest);
ref_ptrShader vertObj = new Shader(Shader::VERTEX);
ref_ptrShader fragObj = new Shader(Shader::FRAGMENT);

program-addShader(vertObj.get());
program-addShader(fragObj.get());

ref_ptrStateSet stateSet = new osg::StateSet;
ref_ptrUniform texturesUniform = new 
Uniform(Uniform::SAMPLER_2D_ARRAY, textures, 0);
stateSet-addUniform(texturesUniform.get());
stateSet-setAttributeAndModes(program.get(), StateAttribute::ON);

ref_ptrTexture2DArray textureArray = new Texture2DArray;
textureArray-setFilter(osg::Texture2DArray::MIN_FILTER, 
osg::Texture2DArray::NEAREST);
textureArray-setFilter(osg::Texture2DArray::MAG_FILTER, 
osg::Texture2DArray::NEAREST);
textureArray-setWrap(osg::Texture::WRAP_S, 
osg::Texture::CLAMP_TO_BORDER);
textureArray-setWrap(osg::Texture::WRAP_T, 
osg::Texture::CLAMP_TO_BORDER);
textureArray-setWrap(osg::Texture::WRAP_R, 
osg::Texture::CLAMP_TO_BORDER);



textureArray-setTextureDepth(2);
Image* image = osgDB::readImageFile(src/foo2.jpg);
textureArray-setImage(0, image);
textureArray-setImage(1, image);
stateSet-setTextureAttribute(0, textureArray.get(), 
osg::StateAttribute::ON);

std::string vertSource =
void main()
{
gl_TexCoord[0].st = gl_MultiTexCoord0.st;
gl_Position = ftransform();
};
vertObj-setShaderSource(vertSource);

std::string fragSource =
#version 120\n
#extension GL_EXT_gpu_shader4 : enable\n

uniform sampler2DArray textures;

void main()
{
gl_FragColor = texture2DArray(textures, 
vec3(gl_TexCoord[0].xy*vec2(1.5,1.5), 0));
};
fragObj-setShaderSource(fragSource);

geode-setStateSet(stateSet.get());
}

int main(int argc, char** argv)
{
setNotifyLevel(osg::DEBUG_INFO);

// Create a cube
ref_ptrGroup rootNode = new Group;
Box* cube = new Box(Vec3(0,0,0), 1.0f);
ShapeDrawable* drawable = new ShapeDrawable(cube);
Geode* geode = new Geode();
geode-addDrawable(drawable);
rootNode-addChild(geode);

// Apply our shader to this cube
applyShader(geode);

osgViewer::Viewer viewer;
viewer.setSceneData(rootNode.get());
return viewer.run();
}





http://www.jotschi.de/download/osg/Texture2DArrayClampingExample.cpp

I resized the texture coords so that you can see that there is no clamping.

Thank you!

Cheers,
Johannes

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





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


Re: [osg-users] Texture Wrapping Texture2DArray (Clamping doesn't work)

2009-10-06 Thread Johannes Schüth
Hi,

even if i use st instead of the xy coords:

Code:

gl_FragColor = texture2DArray(textures, 
vec3(gl_TexCoord[0].xy*vec2(1.5,1.5), 0));



instead of:

Code:

gl_FragColor = texture2DArray(textures, 
vec3(gl_TexCoord[0].st*vec2(1.5,1.5), 0));




The problem is the same.

Thank you!

Cheers,
Johannes

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





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


Re: [osg-users] Texture Wrapping Texture2DArray (Clamping doesn't work)

2009-10-06 Thread Johannes Schüth
Hi,

textureArray-setWrap(osg::Texture::WRAP_S, osg::Texture::MIRROR);
textureArray-setWrap(osg::Texture::WRAP_T, osg::Texture::MIRROR);
textureArray-setWrap(osg::Texture::WRAP_R, osg::Texture::MIRROR);

does work with me. The textures will be mirrored.

Thank you!

Cheers,
Johannes

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





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


Re: [osg-users] Texture Wrapping Texture2DArray (Clamping doesn't work)

2009-10-06 Thread Johannes Schüth
Hi,

i read that clamping is not supported when using s3c texture compression so 
perhaps the internal format in which the texture2darray is stored affects the 
clamping behaviour?

Thank you!

Cheers,
Johannes

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





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


Re: [osg-users] Texture Wrapping Texture2DArray (Clamping doesn't work)

2009-10-05 Thread Johannes Schüth
If i had read the specs earlier i would probably also remember the section you 
mentioned.

Are there any other possible issues regarding this problem?


Wojciech Lewandowski wrote:
 Hi Johannes,
 My apologies, I must have misinterpreted this pragraph of the spec:
 


Otherwise i'm really stuck here.

Greetings

Johannes

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





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


[osg-users] Texture Wrapping Texture2DArray (Clamping doesn't work)

2009-10-04 Thread Johannes Schüth
Hi,

i have just changed my code to use Texture2DArray instead of texture2D's. I 
works fine but i have one problem. My texture is not clamped to the border.

This is my code:

Texture2DArray:

Code:

osg::Texture2DArray* textureArray = new osg::Texture2DArray;
textureArray-setFilter(osg::Texture2DArray::MIN_FILTER,osg::Texture2DArray::LINEAR);
textureArray-setFilter(osg::Texture2DArray::MAG_FILTER,osg::Texture2DArray::LINEAR);
textureArray-setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_BORDER);
textureArray-setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_BORDER);
textureArray-setWrap(osg::Texture::WRAP_R, osg::Texture::CLAMP_TO_BORDER);




Vertex Shader:

Code:

varying vec4 vPos; 
void main()
{
vPos = gl_Vertex;
gl_Position = ftransform();
gl_FrontColor = gl_Color;
}




Fragment Shader:

Code:

#version 120
#extension GL_EXT_gpu_shader4 : enable

uniform sampler2DArray projectionMaps;
varying vec4 vPos; 

void main()
{
vec4 coords = gl_TextureMatrix[5] * vPos;
vec4 dividedCoord = coords / coords.w ;
vec4 color = texture2DArray(projectionMaps, 
vec3((dividedCoord.st*vec2(0.5,0.5)+vec2(0.5,0.5)), 1));
gl_FragColor=color* gl_Color;
}




I add two images and one custom TexMat. 
Is there a special way to enable clamping or might this be a bug in any form?


Thank you!

Cheers,
Johannes

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





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


[osg-users] [forum] Encoding errors within code Tag

2009-10-04 Thread Johannes Schüth
Hi,

i get some ugly encoding error when inserting code into the code tag:


Code:
for (cii = gProjectorSegments.begin(); cii != gProjectorSegments.end(); cii++) {
i++;
osg::TexMat* texMat = (*cii)-getTextureMat();
stateSet-setTextureAttributeAndModes(i, texMat,
osg::StateAttribute::ON);

//texture-setImage(Helper::convertToOsgImage((*cii)-getTexture()));
}



Using firefox 3.0 - Linux - Browser detects page as UTF-8.

Maybe the \n unix style compared to \r\n is the problem. 

Thank you!

Cheers,
Johannes

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





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


Re: [osg-users] Texture Wrapping Texture2DArray (Clamping doesn't work)

2009-10-04 Thread Johannes Schüth
Hi,

thank you for your quick response. I have read these specs for 
GL_EXT_texture_array :
http://www.opengl.org/registry/specs/EXT/texture_array.txt

There is no clue about wrapping and clamping issues inside of it and i tried to 
use CLAMP_TO_EDGE as well but it had no affect at all.

Greetings

Johannes

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





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


Re: [osg-users] Focus object/scene (clamping frustum)

2009-09-15 Thread Johannes Schüth
Hi,

I see. Of course thats very simple. I had something much more complicated in my 
mind. (Checking if the frustum planes intersect with some bounding box lines or 
so..) 
Anyway..

Here is my solution:


Code:

osg::Vec3f eye, center, up;
float n;
viewA1-getCamera()-getViewMatrixAsLookAt(eye, center, up, n);
//printf(r: %f\n,boundingSphere._radius);
double d = (boxCenter - eye).length();
double fovy = osg::RadiansToDegrees(atan(boundingSphere._radius/d))*2;
double aspectratio = 1.0;
double znear = 1.;
double zfar = 1000.;
viewA1-getCamera()-setProjectionMatrixAsPerspective(fovy,
aspectratio, znear, zfar);




(Of course you can compute the znear and zfar as well by using d and d+radius.)

Cheers,
Johannes

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





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


Re: [osg-users] Focus object/scene (clamping frustum)

2009-09-14 Thread Johannes Schüth
Hi,

Thank for your advice. I took a look at:
http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/branches/OpenSceneGraph-2.6/src/osgGA/TrackballManipulator.cpp

But i can't find any place in the code where the frustum will be calculated.

Thank you!

Cheers,
Johannes

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





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


Re: [osg-users] Focus object/scene (clamping frustum)

2009-09-14 Thread Johannes Schüth
Hi,

Yes, the computeHomePosition calculates a position and set's it. In my case i'm 
not able to change the camera positon at all because it is fixed.
I'm able to change the orientation and the fov (by the frustum). 

Perhaps the osgShadow::MinimalShadowMap class does this kind of frustum 
calculation to minimize the fov of the camera that collects the shadowmap? 

Thank you!

Cheers,
Johannes

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





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


[osg-users] Focus object/scene (clamping frustum)

2009-09-13 Thread Johannes Schüth
Hi,

is there any easy way to focus a object? 
I'm able to center my camera onto the object but i want to zoom in as much as 
possible. 
In some way i must fit the bounding sphere of my object into the camera 
frustum. 
I think i have to set the frustum my self but perhaps there is an easy way to 
calculate the frustum?

Thank you!

Cheers,
Johannes

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





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


[osg-users] Dynamic projective textures (Applies to ShadowMaps too)

2009-09-04 Thread Johannes Schüth
Hi,

I have a small problem. 

Imagine the following scene:

The viewer/cam can see two objects. One is very near and the other is very far 
away from the viewpoint. Both will be textured using the same projection 
source. The object that is very far away from the viewer is very near to the 
projection source and will therefor be textured very good. 
The other object which is very near to the viewer is very far away from the 
projection source and will therefor be textured not very well.

I thought i could solve this issue by splitting the projection into chunks. 
Instead of using one huge projection and projection texture i would use a 
number of textures and projection sources. For example if the full projection 
source would cover a viewangle of about 90°x90° it could be split into four 
seamlessly attached segments with each about 22,5°x22,5°. Each 
segment/projection source could now use a projective texture which could be 
adapted to the distance of the objects that the chunk would cover.

I thought i could also use midmap textures for each chunk to determine the 
level of datail of the  texture that should be used for the projection. 

Any maybe i could use a depth map to determine the distance of the objects. I 
would do this before i apply the projective texture to determine the level of 
detail that i would use for each chunk.

These images should illustrate the process. Here you can see two light sources 
instead of one large that casts a shadow map shadow. 
[Image: 
http://www.jotschi.de/wp-content/uploads/2009/09/512_1024_split_shadowmap.png ]

This is the scene:
[Image: http://www.jotschi.de/wp-content/uploads/2009/09/shadow_scene.png ]

Do you think this i a good approach? 

I know this is not directly a osg related problem but perhaps you could give me 
some feedback about this approach.

Thank you!

Cheers,
Johannes

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





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


Re: [osg-users] Multiple projective textures - Conditional per Pixel Multipass rendering

2009-09-01 Thread Johannes Schüth
Hi,

i will try uniform arrays as soon as i get to it. But the approach sounds quite 
good. 
Thank you.


Paul Martz wrote:
 I believe you can use a uniform array of samplers. This means the number of 
 texture can be arbitrary and therefore you don't need to recompile your 
 shader based on number of textures.
  


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





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


[osg-users] DelaunayTriangulator - DelaunayConstraint for convex shapes

2009-09-01 Thread Johannes Schüth
Hi,

i want to triangulate the following U character like shape.
[Image: http://jotschi.de/download/osg/delaunay_3.png ]

The DelaunayTriangulator generates this triangulated mesh. But as you can see 
the space in the middle of the U is also triangulated which i do not want.
[Image: http://jotschi.de/download/osg/delaunay_2.png ]

So i tried the DelaunayConstraint to add a constraint for all edges. Obviously 
i have no clue how to do this but i attach the image anyway. This doesn't seem 
to work:
[Image: http://jotschi.de/download/osg/delaunay_1.png ]

I used the following code:

Code:

osg::Group* root = new osg::Group();

osg::Vec3Array* v = new osg::Vec3Array;
v-resize(16);

//U
(*v)[0].set(500, 250, 0);
(*v)[1].set(500, 1000, 0);

(*v)[2].set(500, 1000, 0);
(*v)[3].set(1300, 1000, 0);

(*v)[4].set(1300, 1000, 0);
(*v)[5].set(1300, 250, 0);

(*v)[6].set(1300, 250, 0);
(*v)[7].set(1200, 250, 0);

(*v)[8].set(1200, 250, 0);
(*v)[9].set(1200, 900, 0);

(*v)[10].set(1200, 900, 0);
(*v)[11].set(650, 900, 0);

(*v)[12].set(650, 900, 0);
(*v)[13].set(650, 200, 0);

(*v)[14].set(650, 200, 0);
(*v)[15].set(500, 250, 0);



osg::ref_ptrosgUtil::DelaunayTriangulator trig =
new osgUtil::DelaunayTriangulator();
trig-setInputPointArray(v);



osg::ref_ptrosgUtil::DelaunayConstraint constraint =
new osgUtil::DelaunayConstraint;

constraint-setVertexArray(v);
constraint-addPrimitiveSet(new osg::DrawArrays(
osg::PrimitiveSet::LINE_LOOP, 0, 3));
trig-addInputConstraint(constraint.get());


trig-triangulate();
trig-removeInternalTriangles(constraint.get());

osg::Geometry* gm = new osg::Geometry;
gm-setVertexArray(v);
gm-addPrimitiveSet(trig-getTriangles());
osg::Vec4Array* colors = new osg::Vec4Array(1);
colors-push_back(osg::Vec4(1, 0, 1, 1));
gm-setColorArray(colors);
gm-setColorBinding(osg::Geometry::BIND_OVERALL);
osg::Geode* geode = new osg::Geode();
geode-addDrawable(gm);

// you do not need this function call to use this example
//forcedWireFrameModeOn(root);

root-addChild(geode);

/*
int nEdges = 16;
int i = 0;
while (i  nEdges) {

osg::Vec4 c = osg::Vec4(1., 1., 1., 1.);
root-addChild(drawEdge(c, (*v)[i], (*v)[i + 1]));

i += 2;
}
*/



Do you have any idea how to solve this problem? I just want to get a 
triangulated mesh from the imput of a shapes outline. (The input is not a point 
cloud)

Thank you!

Cheers,
Johannes

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





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


Re: [osg-users] DelaunayTriangulator - DelaunayConstraint for convex shapes

2009-09-01 Thread Johannes Schüth
Hi,

that worked like a charm :) Thank you very much for the quick answer. 

I attach the full example. Maybe this comes handy to someone else too :)


Code:

osg::Geometry* contourGeom = new osg::Geometry();
contourGeom-setVertexArray(v);
contourGeom-addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP, 
0, v-size()));

osg::ref_ptrosgUtil::Tessellator tess = new osgUtil::Tessellator();

tess-setTessellationType( osgUtil::Tessellator::TESS_TYPE_GEOMETRY );  
tess-setWindingType( osgUtil::Tessellator::TESS_WINDING_POSITIVE );
tess-retessellatePolygons( *contourGeom );

osg::Geode* geode = new osg::Geode();
geode-addDrawable(contourGeom);
root-addChild(geode);
return root;



[Image: http://jotschi.de/download/osg/tessellate.png ]

Cheers,
Johannes

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





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


[osg-users] Multiple projective textures - Conditional per Pixel Multipass rendering

2009-08-08 Thread Johannes Schüth
Hi,

I basically got multiple images that i want to project onto the same world 
geometry.

By comparing the normal vector of the world geometry polygon and the direction 
vector of the projection source i want to calculate the angle in which the 
projected image 'shines' onto the polygon. This is no big deal. But here is my 
problem:

I want use this angle to decide whether one of the images should be projected 
onto the face. In fact i want to ensure that only the image that 'shines' most 
direct onto the face will be finally visible. In addition i want to use a 
fallback mechanism. 
If there is only one image that projects onto the face than it should be 
allowed to project onto the face although the angle might be very flat.

I found this conversion 
http://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg10267.html

Approach 1:

Just passing all textures and texture matrices to the shader
Problem: This requires a fixed amount of projections or the shader must be 
recompiled each time the amount of projective images changes.

Approach 2:

Multipass Shading:
Render the scene with a single projective texture
Render the scene again with the next projective texture and so on.
Combine each pass with osgPPU
Problems:
1. I have no idea to do this and where to start
2. I believe it is not possible to handle the conditional projection that i 
described above in this approach.

Maybe a neat solution for my problem. 

Thank you!

Cheers,
Johannes

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





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


[osg-users] Camera view volume visualization

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

i want to create a visualization of the view volume of a camera. 

I created a test application with two views and two cameras. I want to use one 
view to take a look at the created volume.

This is what i did so far:

I created an osgGA::TrackballManipulator() and assigned it to the camera of 
viewA:


Code:

osgGA::TrackballManipulator *Tman = new osgGA::TrackballManipulator();
viewA-setCameraManipulator(Tman);




Look at position:

Code:

osg::Vec3d center;
   viewA-getCamera()-getViewMatrixAsLookAt(eye, center, up, 
distance);
sphereXForm-setPosition(center);




I tried to use 'eye' as a source for the camera position but that did'nt work.

Finnaly i used the TrackballManipulator to get the eye/camera position:

Code:

sphereXFormB-setPosition(Tman-getCenter());




sphereXForm and sphereXFormB are two spheres that show me the positions.

As for now i just have the camera position and the direction. Is this 
sufficient to create a view volume using:

Code:

viewA-getCamera()-getProjectionMatrixAsPerspective(fovy, ratio,
znear, zfar);



? In which units are fovy, ratio etc. stored? I mean can i just take fovy and 
ratio to calculate the fovx and than calculate the points of the view volume?

Is there any way to get and set the camera position without using a 
TrackballManipulator? 


Thank you!

Cheers,
Johannes

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





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


Re: [osg-users] Camera view volume visualization

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

nope. Thank you very much. That was exactly what i wanted to achieve. Nice 
example. 

Thank you!

Greetings,
Johannes

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





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


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

2009-06-02 Thread Johannes Schüth
Hi Jose,

why do you want to use full virtualisation at all? Thats a waste of resources. 
Especially if you are hosting Linux in Linux which you'll do i assume.

Paravirtualization does a much better job here. You don't have to care about 
interrupts and memory issues. I use OpenVZ for my server. 

Greetings,

Johannes


Jose Luis Hidalgo wrote:
 
 We've had a problem with the host of our OSG virtual machine, looks
 like we are having problems with the vmware that we are currently
 using. I'm considering the possibility to move to another
 virtualization technology , like libvirt, does any of you have insight
 into wich one is better?
 
 BTW, the host is up again.
 


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





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


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

2009-05-31 Thread Johannes Schüth
Hi Ulrich,

thank you very much. You gave me the right hint to solve my problem.

I just added the texture matrix and everything worked as expected:


Code:

/* set Texture matrix*/
osg::TexMat* texMat = new osg::TexMat;
osg::Matrix mat;

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;
osg::Vec3 up(0.0f, 0.0f, 1.0f);

mat = osg::Matrixd::lookAt(projectorPos, projectorPos
+ projectorDirection, up) * osg::Matrixd::perspective(
projectorAngle, 1.0, 0.1, 100);

texMat-setMatrix(mat);
stateset-setTextureAttributeAndModes(1, texMat, 
osg::StateAttribute::ON);





Ulrich Hertlein wrote:
 Hi Johannes,
 1) TexGen doesn't modify the texture matrix but generates texture coordinates.
 2) TexGen is a fixed-function functionality so you'll have to generate the 
 texture 
 coordinates yourself in the vertex shader.
 


Thank you!

Greetings,
Johannes

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





___
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 iostream
#include osg/Notify
#include osg/MatrixTransform
#include osg/ShapeDrawable
#include osg/PositionAttitudeTransform
#include osg/Geometry
#include osg/Texture2D
#include osg/Geode
#include osg/LightSource
#include osg/TexGenNode
#include osgUtil/Optimizer
#include osgDB/Registry
#include osgDB/ReadFile
#include osgViewer/Viewer

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_ptrosg::Program projProg(new osg::Program);
osg::ref_ptrosg::Shader projvertexShader(osg::Shader::readShaderFile(
osg::Shader::VERTEX, VertexShader.glsl));
osg::ref_ptrosg::Shader 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_ptrosg::MatrixTransform 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 

[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