[osg-users] Trouble creating an osg::Image for use as a 2D texture

2011-12-07 Thread Michael . A . Bosse
Hello,

I am trying to encode some position information in a Texture2D for consumption 
by a vertex shader. I found a pretty good example in the OSG examples directory 
of something similar, osgtexture1d and I have successfully implemented the 
method used there. For your reference, the relevant lines are below.

== osgtexture1d.cpp ==
osg::Image* image = new osg::Image;
int noPixels = 1024;
image->allocateImage(noPixels,1,1,GL_RGBA,GL_FLOAT);
image->setInternalTextureFormat(GL_RGBA);
osg::Vec4* dataPtr = (osg::Vec4*)image->data();

(A for loop populating the dataPtr follows, it uses the following syntax)
*dataPtr++ = color;
== end ==

I implemented my code as follows and it works.

unsigned int tex_size = 2048;
positionImage->allocateImage( 2, tex_size, 1, GL_RGBA, GL_FLOAT );
positionImage->setInternalTextureFormat(GL_RGBA32F_ARB);

osg::Vec4 *dataPtr = (osg::Vec4*)positionImage->data();
memset(dataPtr, 0, sizeof(osg::Vec4)*2*tex_size);
(a for loop follows, it uses the following syntax, it moves in increments of 
two, basically angles get stored in the second column, positions in the first)
dataPtr[ii] = positions[ii / 2]; // this is a vec4
dataPtr[ii + 1] = osg::Vec4( sin(angle), cos(angle), 0., 1.);


The problem arises when I want to instance more geometry than a single 1d map 
can reasonably hold, e.g. 10k. I decided to try and use a 1024 x 512 map to 
hold the data, with the capacity being 512*512 entities.
The implementation looks like this:

= begin =
const int tex_width  = 1024; // [0] = position, angle [1] = sin, cos, 0.0, 1.0
const int tex_height = 512; 
positionImage->allocateImage( tex_width, tex_height, 1, GL_RGBA, GL_FLOAT );
positionImage->setInternalTextureFormat(GL_RGBA);

unsigned char* dataPtr = (unsigned char*)positionImage->data();
//memset(dataPtr, 0, sizeof(osg::Vec4)*tex_width*tex_height);
int row_c = 0, col_c = 0;

for(unsigned int ii=0; ii___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgDB::writeImageFile return false in release mode only

2011-12-07 Thread Chris 'Xenon' Hanson
On 12/7/2011 4:50 PM, clement@csiro.au wrote:
> Hi Chris,
> Thanks for your reply.  My project is using MSVS 9.0 and I am sure I have 
> added osgDB.lib in property settings for compiling.  The debug and release 
> settings are the same except the libraries for debug that are used the 
> libraries with "d" at the end of library file.  If you think the problem is 
> the related dll is not loaded in release mode, why it can work in debug mode.


  Possibly you've not copied a DLL to the right place, or something similar. 
There are
many possible reasons. The easiest way to find ou is with the debug level, or a 
tool like
Process Monitor.

>  I also would like to know how to do to turn up osg debug level.  Thanks.

http://lmgtfy.com/?q=osg+debug+level

-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com 
http://www.alphapixel.com/
  Digital Imaging. OpenGL. Scene Graphs. GIS. GPS. Training. Consulting. 
Contracting.
"There is no Truth. There is only Perception. To Perceive is to Exist." - 
Xen
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgDB::writeImageFile return false in release mode only

2011-12-07 Thread Clement.Chu
Hi Chris,

Thanks for your reply.  My project is using MSVS 9.0 and I am sure I have 
added osgDB.lib in property settings for compiling.  The debug and release 
settings are the same except the libraries for debug that are used the 
libraries with "d" at the end of library file.  If you think the problem is the 
related dll is not loaded in release mode, why it can work in debug mode.  I 
also would like to know how to do to turn up osg debug level.  Thanks.


Regards,
Clement

From: osg-users-boun...@lists.openscenegraph.org 
[osg-users-boun...@lists.openscenegraph.org] On Behalf Of Chris 'Xenon' Hanson 
[xe...@alphapixel.com]
Sent: Thursday, 8 December 2011 3:04 AM
To: osg-users@lists.openscenegraph.org
Subject: Re: [osg-users] osgDB::writeImageFile return false in release mode only

On 12/7/2011 1:34 AM, clement@csiro.au wrote:
> Hi,
>   I got a problem on calling osgDB::writeImageFile function.  If my program 
> built in debug mode and using osg debug libraries, this function works 
> perfectly.  If the program is built in release mode with using osg release 
> libraries, this function will return false.  Anyone got an idea to fix it?  
> Thanks.

  Turn up the OSG Debug level. You're probably not loading the release-mode DLL 
for the
image saver.

--
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com 
http://www.alphapixel.com/
  Digital Imaging. OpenGL. Scene Graphs. GIS. GPS. Training. Consulting. 
Contracting.
"There is no Truth. There is only Perception. To Perceive is to Exist." - 
Xen
___
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] setRunMaxFrameRate() when using GraphicsWindowQt & setViewer() will never paint

2011-12-07 Thread Thomas Lerman
If I setRunMaxFrameRate() when using GraphicsWindowQt and setViewer(), frame() 
never gets called in GraphicsWindowQt's HeartBeat::timerEvent(). The code for 
this method follows:
Code:
if( viewer->getRunMaxFrameRate() > 0.0)
{
double dt = _lastFrameStartTime.time_s();
double minFrameTime = 1.0 / viewer->getRunMaxFrameRate();
if (dt < minFrameTime)
OpenThreads::Thread::microSleep(static_cast(100.0*(minFrameTime-dt)));
}
else
{
// avoid excessive CPU loading when no frame is required in ON_DEMAND 
mode
if( viewer->getRunFrameScheme() == osgViewer::ViewerBase::ON_DEMAND )
{
double dt = _lastFrameStartTime.time_s();
if (dt < 0.01)
OpenThreads::Thread::microSleep(static_cast(100.0*(0.01-dt)));
}

// record start frame time
_lastFrameStartTime.setStartTick();

// make frame
if( viewer->getRunFrameScheme() == osgViewer::ViewerBase::ON_DEMAND )
{
if( viewer->checkNeedToDoFrame() )
{
viewer->frame();
}
}
else
{
viewer->frame();
}
}

Notice that if the first if-statement is true, frame() can never be called!

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





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


Re: [osg-users] World to Screen Space

2011-12-07 Thread Shayne Tueller
Hi,

This topic has been discussed in various forms. Please see

http://forum.openscenegraph.org/viewtopic.php?p=18256#18256

-Shayne

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





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


Re: [osg-users] Running a viewer in a thread other than main thread

2011-12-07 Thread Tom Pearce
We use multiple viewers created and run from multiple threads, since our 
application is heavily modular and multiple modules can create and control 
their own viewers without a central coordinator.  We don't limit what threading 
mode is used, and we haven't had problems with multiple viewers in 
multithreaded mode. We haven't done anything particularly complex as far as 
rendering goes so I don't know what the performance implications are, but I 
know it works for some things at least.

Cheers,
Tom

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





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


[osg-users] World to Screen Space

2011-12-07 Thread Martin Haffner
Hi,

I want to transform a point from world space to screen space with this code:
Camera* cam = ...
Matrix viewMat = cam->getViewMatrix();
Matrix projMat = cam->getProjectionMatrix();
Viewport* vp   = cam->getViewport();
Matrix vpMat   = vp->computeWindowMatrix(); 
Vec3 ls1SS = ls1WSPos * viewMat * projMat * vpMat;

Unfortunately the result vector ls1SS is not correct. Is my approach generelly 
right or did I miss something?

Thank you!

Cheers,
Martin

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





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


Re: [osg-users] Building on OpenGL ES

2011-12-07 Thread Chris 'Xenon' Hanson
On 12/7/2011 10:10 AM, Robert Osfield wrote:
>> settable parameter in CMake. Is this supposed to be a setting that's exposed 
>> in the CMake
>> GUI? The recipe implies it is, since it is listed with other 
>> publicly-exposed parameters
>> (like OSG_GL1_AVAILABLE).
> ccmake have advanced options that are aren't displayed by default, but
> can be toggled on using 't'.  I believe OPENGL_INCLUDE_DIR is one of
> these advanced options.

  In my testing here, even toggling on the Advanced filter, OPENGL_INCLUDE_DIR 
did not
appear, on Windows CMake-GUI.

> Robert.

-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com 
http://www.alphapixel.com/
  Digital Imaging. OpenGL. Scene Graphs. GIS. GPS. Training. Consulting. 
Contracting.
"There is no Truth. There is only Perception. To Perceive is to Exist." - 
Xen
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Building on OpenGL ES

2011-12-07 Thread Robert Osfield
Hi Chris,

On 6 December 2011 15:48, Chris 'Xenon' Hanson  wrote:
>  Well, I think OPENGL_INCLUDE_DIR is provided by FIND_PACKAGE(OpenGL), but 
> even when it
> is found (such as when I'm building with normal full-spec OpenGL) it doesn't 
> show up as a
> settable parameter in CMake. Is this supposed to be a setting that's exposed 
> in the CMake
> GUI? The recipe implies it is, since it is listed with other publicly-exposed 
> parameters
> (like OSG_GL1_AVAILABLE).

ccmake have advanced options that are aren't displayed by default, but
can be toggled on using 't'.  I believe OPENGL_INCLUDE_DIR is one of
these advanced options.

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


Re: [osg-users] Building on OpenGL ES

2011-12-07 Thread Chris 'Xenon' Hanson
On 12/6/2011 8:48 AM, Chris 'Xenon' Hanson wrote:
>   Well, I think OPENGL_INCLUDE_DIR is provided by FIND_PACKAGE(OpenGL), but 
> even when it
> is found (such as when I'm building with normal full-spec OpenGL) it doesn't 
> show up as a
> settable parameter in CMake. Is this supposed to be a setting that's exposed 
> in the CMake
> GUI? The recipe implies it is, since it is listed with other publicly-exposed 
> parameters
> (like OSG_GL1_AVAILABLE).

  Ok, manually adding OPENGL_INCLUDE_DIR works. We've configured for egl, but 
at link
time, it still appears to be referring to wgl functions.

  I found this message from two years ago:

http://forum.openscenegraph.org/viewtopic.php?t=4208&view=previous

  where you say

> I've only written EGL support for GraphicsWindowX11.cpp, and don't 
> have any access to a Windows or OSX system so can't directly help 
> there. Members of the community will have to dive in and add EGL 
> support to src/osgViewer/GraphicsWindowWin32.cpp to enable OpenGL ES 
> under Windows. 

  Can anyone confirm -- am I missing something, or in two years nobody has 
built GLES on
Windows and written the egl stubs for GraphicsWindowWin32?

  I'm going to go dissect GraphicsWindowWin32 now and see what I can learn.

-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com 
http://www.alphapixel.com/
  Digital Imaging. OpenGL. Scene Graphs. GIS. GPS. Training. Consulting. 
Contracting.
"There is no Truth. There is only Perception. To Perceive is to Exist." - 
Xen
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgDB::writeImageFile return false in release mode only

2011-12-07 Thread Chris 'Xenon' Hanson
On 12/7/2011 1:34 AM, clement@csiro.au wrote:
> Hi,
>   I got a problem on calling osgDB::writeImageFile function.  If my program 
> built in debug mode and using osg debug libraries, this function works 
> perfectly.  If the program is built in release mode with using osg release 
> libraries, this function will return false.  Anyone got an idea to fix it?  
> Thanks.

  Turn up the OSG Debug level. You're probably not loading the release-mode DLL 
for the
image saver.

-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com 
http://www.alphapixel.com/
  Digital Imaging. OpenGL. Scene Graphs. GIS. GPS. Training. Consulting. 
Contracting.
"There is no Truth. There is only Perception. To Perceive is to Exist." - 
Xen
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] best format for paged database

2011-12-07 Thread Chris 'Xenon' Hanson
On 12/7/2011 12:29 AM, PC John wrote:
> Thanks Chris and J.P.,
> I am wondering that flt and vpb and similar formats does not support paging 

  VPB isn't a format. VPB is a tool. It generates data in any OSG-writable 
format,
including .osg/.ive/.osgt/.osgb. It does support terrain paging with PagedLOD.

> (PagedLOD). In that case, osgb seems to be the best format. Can it store 
> texture data internally, or all jpegs and pngs have to stay as separate files 
> (possibly increasing data fragmentation)?

  It can do either way.

> osgEarth is definitely the project to look at. Thanks,

  Yes.

  If you're not interested in building it from scratch (it can be difficult the 
first
time), my company, AlphaPixel offers subscriptions to a binaries-download 
system that
builds projects like osgEarth every night, whenever the source has changed.

> John

-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com 
http://www.alphapixel.com/
  Digital Imaging. OpenGL. Scene Graphs. GIS. GPS. Training. Consulting. 
Contracting.
"There is no Truth. There is only Perception. To Perceive is to Exist." - 
Xen
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgexport for blender?

2011-12-07 Thread Maia Randria
Hi,

I will do so.

Cheers,

Maia



Cedric Pinson wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> Hi,
> you can export animation without armature in blender. It will uses
> osgAnimation in osg. You can see examples about osgAnimation in the
> directory examples of osg.
> 
> Cheers,
> Cedric
> 
> On 12/06/2011 09:50 PM, Maia Randria wrote:
> 
> > Hi,
> > 
> > Thank you very much.
> > 
> > BTW, what kind of animation should be worth to be done with Blender
> > and exported to OSG since with OSG, we can also do animation ?
> > 
> > Maia
> > 
> > 
> > 
> > Cedric Pinson wrote: Thank you, I fixed the problem, btw it's not
> > exported correctly because of skeleton. Anyway now it save it
> > without error.
> > 
> > Need to update the animation part to export skeleton correctly.
> > 
> > If you have other models that produces error, I will be happy to
> > fix it.
> > 
> > Cedric
> > 
> > On 12/01/2011 04:45 PM, Maia Randria wrote:
> > 
> > 
> > > 
> > > > 
> > > > > Hi,
> > > > > 
> > > > > I downloaded this model here: 
> > > > > http://e2-productions.com/repository/modules/PDdownloads/singlefile.php?cid=1&lid=12
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > 
> > > 
> > 
> (Low Poly Female Model by TiZeta).
> 
> > 
> > > 
> > > > 
> > > > > 
> > > > > Thanks,
> > > > > 
> > > > > Maia
> > > > > 
> > > > > -- Read this topic online here: 
> > > > > http://forum.openscenegraph.org/viewtopic.php?p=44164#44164
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > > ___ osg-users
> > > > > mailing list 
> > > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > 
> > > 
> > > 
> > 
> ___
> 
> > 
> > > osg-users mailing list
> > > 
> > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > 
> > > 
> > > 
> > > 
> > 
> - --
> 
> > 
> > > Post generated by Mail2Forum
> > > 
> > 
> > 
> > -- Read this topic online here: 
> > http://forum.openscenegraph.org/viewtopic.php?p=44248#44248
> > 
> > 
> > 
> > 
> > 
> > ___ osg-users mailing
> > list  
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > 
> > 
> > 
> - -- 
> Cedric Pinson
> Provide OpenGL, WebGL and OpenSceneGraph services
> +33 659 598 614 - 
> http://plopbyte.com - http://osgjs.org - http://showwebgl.com
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAk7fUoQACgkQs6ZHzVQN0IiftwCcCuhoZnb/qfgKg8sq5tX6sDA2
> JOkAoJrV7u75Jnz43gyKES4TrwwiHEQt
> =cVg7
> -END PGP SIGNATURE-
> ___
> osg-users mailing list
> 
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 
>  --
> Post generated by Mail2Forum


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





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


Re: [osg-users] osgexport for blender?

2011-12-07 Thread Cedric Pinson
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,
you can export animation without armature in blender. It will uses
osgAnimation in osg. You can see examples about osgAnimation in the
directory examples of osg.

Cheers,
Cedric

On 12/06/2011 09:50 PM, Maia Randria wrote:
> Hi,
> 
> Thank you very much.
> 
> BTW, what kind of animation should be worth to be done with Blender
> and exported to OSG since with OSG, we can also do animation ?
> 
> Maia
> 
> 
> 
> Cedric Pinson wrote: Thank you, I fixed the problem, btw it's not
> exported correctly because of skeleton. Anyway now it save it
> without error.
> 
> Need to update the animation part to export skeleton correctly.
> 
> If you have other models that produces error, I will be happy to
> fix it.
> 
> Cedric
> 
> On 12/01/2011 04:45 PM, Maia Randria wrote:
> 
 Hi,
 
 I downloaded this model here: 
 http://e2-productions.com/repository/modules/PDdownloads/singlefile.php?cid=1&lid=12


 
(Low Poly Female Model by TiZeta).
 
 Thanks,
 
 Maia
 
 -- Read this topic online here: 
 http://forum.openscenegraph.org/viewtopic.php?p=44164#44164
 
 
 
 
 
 ___ osg-users
 mailing list 
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



>>
 
___
>> osg-users mailing list
>> 
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>> 
- --
>> Post generated by Mail2Forum
> 
> 
> -- Read this topic online here: 
> http://forum.openscenegraph.org/viewtopic.php?p=44248#44248
> 
> 
> 
> 
> 
> ___ osg-users mailing
> list osg-users@lists.openscenegraph.org 
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
> 
- -- 
Cedric Pinson
Provide OpenGL, WebGL and OpenSceneGraph services
+33 659 598 614 - cedric.pin...@plopbyte.com
http://plopbyte.com - http://osgjs.org - http://showwebgl.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk7fUoQACgkQs6ZHzVQN0IiftwCcCuhoZnb/qfgKg8sq5tX6sDA2
JOkAoJrV7u75Jnz43gyKES4TrwwiHEQt
=cVg7
-END PGP SIGNATURE-
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Problem with deferred rendering

2011-12-07 Thread Sebastian Messerschmidt

Hi Micael,

as J-S already pointed out, you have to be aware of the space you are 
working in.
I don't really agree that it has to be done directly in world space, but 
that is not important, as you can get correct results in view-space too.


In my point light lighting pass I do:
Vertex:

varying out vec4 vsLightPosition;
uniform mat4 ModelViewMatrix;

void main()
{

gl_TexCoord[0] = gl_MultiTexCoord0;
vsLightPosition = ModelViewMatrix * vec4(0.0,0.0,0.0,1.0);
gl_Position = ftransform();
}


Frag:
varying in vec4 vsLightPosition;
varying in vec4 vsPosition;

vec3 vertex_pos = getPosition(uv); //essentially you can take your 
pos-gbuffer here as long as you write the view-space in here (i.e 
gl_ModelViewMatrix

vec3 diffuse_color = vec3(0,0,0);
vec3 light_to_vertex = vec3(vertex_pos - vsLightPosition.xyz);
float distance = length(light_to_vertex);
light_to_vertex /= distance;
//normal = //sample your normal buffer here
float ndotl = dot(normal, -light_to_vertex);

You can assume this here, because the camera is setup as RELATIVE to the 
original camera. You should follow J-S's advice though: setup all 
transforms as own uniforms, as it really forces you to think about the 
transforms you are passing.
I render might light-volumes in this pass (i.e. a sphere for the point 
light). This way only the affected fragments are shaded. If the spheres 
are transformed to their correct positions in the scene graph you can 
easily use the ModelViewMatrix * 0,0,0,1 approach.


I found this the more intuitive approach.

If you are working under windows (or mac i think) I really recommend 
gDebugger. It is really helpful, as you can debug the values that you 
write to the buffers.
Also I strongly recommend not to start with tangent-space bumpmapping as 
long as you don't have basic lighting running. I had rotating normals 
with tangent-space mappings all the time, because I forget to normalize 
somewhere.

So start out with the basic things, that will make debugging a lot easier.

Feel free to ask If you encounter more problems.
I was just planning to provide a minimal deferred shading example to the 
community, but unfortunately I'm busy with other stuff right now.


cheers
Sebastian





Hi,

I recently have been trying to get a deferred rendering system to work using 
osg.

   First of all in almost all the tutorials I've seen so far, the normal vector 
was multiplied by the normal matrix (gl_NormalMatrix), but when I did so in my 
geometry vertex shader, I had strange results (the normals where changing while 
I was moving in the scene) ... I later discovered that by leaving the gl_Normal 
untouched, I was getting the right result :|

   The real problem is at the "mixing" part in the deferred fragment shader, I can't seem 
to get the light vector right. After comparing my FBOs output with what I've seen online I 
concluded that the problem has to be with the way I computed the light vector... My first clue 
would be that since the position vector is multiplied with gl_ModelViewMatrix I guess the light 
vector should need to be transformed too but I can't find a way to get the valid ModelViewMatrix 
from osg, I tried to get it trough osg::State::getModelViewMatrix() but it didn't work... does it 
have something to do with the "osg_" uniforms because I can't get them to work either.

Here's a screen of the FBOs

[Image: http://i43.tinypic.com/2irssjm.png ]

[Image: http://i42.tinypic.com/2eztsvd.png ]

[Image: http://i39.tinypic.com/2hi6lj4.png ]

Here's my shaders

gbuffer_vert.glsl

Code:
varying vec3 pos;
varying vec3 t;
varying vec3 b;
varying vec3 n;

attribute vec4 aTangent;
attribute vec4 aBitangent;

void main(void)
{   
gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;


pos = gl_ModelViewMatrix * gl_Vertex;
t = normalize(aTangent.xyz);
b = normalize(aBitangent.xyz);
n = normalize(gl_Normal);
}



gbuffer_frag.glsl

Code:
varying vec3 pos;
varying vec3 t;
varying vec3 b;
varying vec3 n;

uniform sampler2D sColorMap;
uniform sampler2D sNormalMap;

void main(void)
{
vec3 N = texture2D(sNormalMap, gl_TexCoord[0].xy).xyz;
vec3 smoothOut = vec3(0.5,0.5,1.0);
N = normalize((mix(smoothOut,N,1.0)*2.0)-1.0);

gl_FragData[0] = vec4(pos, 1.0);
gl_FragData[1] = vec4(normalize(n) * 0.5 + 0.5, 1.0);
gl_FragData[2] = vec4(texture2D(sColorMap, gl_TexCoord[0].xy).xyz, 1.0);
}



light_pass_vert.glsl

Code:
void main(void)
{
gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;

}



light_pass_frag.glsl

Code:
uniform sampler2D uBuffer0;
uniform sampler2D uBuffer1;
uniform sampler2D uBuffer2;

void main(void)
{
vec4 buffer0 = texture2D(uBuffer0,gl_TexCoord[0].st);
vec4 buffer1 = texture2D(uBuffer1,gl_TexCoord[0].st);
vec4 buffer2 = texture2D(uBuffer2,gl_TexCoord[0].st);

ve

[osg-users] osgDB::writeImageFile return false in release mode only

2011-12-07 Thread Clement.Chu
Hi,

  I got a problem on calling osgDB::writeImageFile function.  If my program 
built in debug mode and using osg debug libraries, this function works 
perfectly.  If the program is built in release mode with using osg release 
libraries, this function will return false.  Anyone got an idea to fix it?  
Thanks.


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