Re: [osg-users] Float textures seem to be clamped in GLSL

2009-03-05 Thread J.P. Delport

Hi,


Thrall, Bryan wrote:

Brian R Hill wrote on Wednesday, March 04, 2009 5:41 PM:

// disable clamping
osg::ClampColor* clamp = new osg::ClampColor();
clamp->setClampVertexColor(GL_FALSE);
clamp->setClampFragmentColor(GL_FALSE);
clamp->setClampReadColor(GL_FALSE);
scene->getOrCreateStateSet()->setAttribute(clamp,

osg::StateAttribute::ON |

osg::StateAttribute::OVERRIDE);


I am sad to report that that doesn't work either :(

Is there something I'm doing wrong with osg::TransferFunction1D, or is
my understanding wrong?



I'm not familiar with osg::TransferFunction1D, but I'm sure that float 
texture data can reach shaders without clamping, we use it all the time.


I'd suggest creating an osg::Image that is attached to a texture and see 
if the values then work properly, you can modify the image data 
directly. Have a look at the osgprerender example when the options --hdr 
and --image are enabled. There are e.g. negative values in the image.


jp




--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.


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


Re: [osg-users] Float textures seem to be clamped in GLSL

2009-03-05 Thread Thrall, Bryan
Brian R Hill wrote on Wednesday, March 04, 2009 5:41 PM:
> // disable clamping
> osg::ClampColor* clamp = new osg::ClampColor();
> clamp->setClampVertexColor(GL_FALSE);
> clamp->setClampFragmentColor(GL_FALSE);
> clamp->setClampReadColor(GL_FALSE);
> scene->getOrCreateStateSet()->setAttribute(clamp,
osg::StateAttribute::ON |
> osg::StateAttribute::OVERRIDE);

I am sad to report that that doesn't work either :(

> -osg-users-boun...@lists.openscenegraph.org wrote: -
> 
> To: "OpenSceneGraph Users" 
> From: "Thrall, Bryan" 
> Sent by: osg-users-boun...@lists.openscenegraph.org
> Date: 03/04/2009 05:05PM
> Subject: [osg-users] Float textures seem to be clamped in GLSL
> 
> 
> I'm rather new to using float textures and GLSL, so maybe I'm missing
> something. I'm trying to use a float texture as a lookup table in my
> fragment shader. I create the texture using osg::TransferFunction1D
(see
> attached modified osgviewer.cpp), and use the following in my input
> file:
> 
> ---8<---
> 50
> 0 0 0
> 0 0 50
> ---8<---
> 
> For example: osgviewer --pos implicit.pos implicit_surface.osg
> (the shaders need to be in a shaders/ subdirectory under
> implicit_surface.osg's directory)
> 
> My shader takes these positions and renders implicit spheres around
> them, with the first line of the position file being the radius.
> 
> However, the positions seem to be clamped to [0,1], since the
resulting
> spheres overlap except for a little bit at the edge (changing the
radius
> to 1 shows their centers are 1 unit apart). My understanding is that
> float textures should be passed through to the shader without
clamping.
> 
> Is there something I'm doing wrong with osg::TransferFunction1D, or is
> my understanding wrong?
> 
> Thanks,



-- 
Bryan Thrall
FlightSafety International
bryan.thr...@flightsafety.com
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Float textures seem to be clamped in GLSL

2009-03-04 Thread Brian R Hill
Bryan,

I've used this:

// disable clamping
osg::ClampColor* clamp = new osg::ClampColor();
clamp->setClampVertexColor(GL_FALSE);
clamp->setClampFragmentColor(GL_FALSE);
clamp->setClampReadColor(GL_FALSE);
scene->getOrCreateStateSet()->setAttribute(clamp, osg::StateAttribute::ON |
osg::StateAttribute::OVERRIDE);

Brian


This is a PRIVATE message. If you are not the intended recipient, please
delete without copying and kindly advise us by e-mail of the mistake in
delivery.
NOTE: Regardless of content, this e-mail shall not operate to bind CSC to
any order or other contract unless pursuant to explicit written agreement
or government initiative expressly permitting the use of e-mail for such
purpose. •
-osg-users-boun...@lists.openscenegraph.org wrote: -

To: "OpenSceneGraph Users" 
From: "Thrall, Bryan" 
Sent by: osg-users-boun...@lists.openscenegraph.org
Date: 03/04/2009 05:05PM
Subject: [osg-users] Float textures seem to be clamped in GLSL


I'm rather new to using float textures and GLSL, so maybe I'm missing
something. I'm trying to use a float texture as a lookup table in my
fragment shader. I create the texture using osg::TransferFunction1D (see
attached modified osgviewer.cpp), and use the following in my input
file:

---8<---
50
0 0 0
0 0 50
---8<---

For example: osgviewer --pos implicit.pos implicit_surface.osg
(the shaders need to be in a shaders/ subdirectory under
implicit_surface.osg's directory)

My shader takes these positions and renders implicit spheres around
them, with the first line of the position file being the radius.

However, the positions seem to be clamped to [0,1], since the resulting
spheres overlap except for a little bit at the edge (changing the radius
to 1 shows their centers are 1 unit apart). My understanding is that
float textures should be passed through to the shader without clamping.

Is there something I'm doing wrong with osg::TransferFunction1D, or is
my understanding wrong?

Thanks,
--
Bryan Thrall
FlightSafety International
bryan.thr...@flightsafety.com

___
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] Float textures seem to be clamped in GLSL

2009-03-04 Thread Thrall, Bryan
David Spilling wrote on Wednesday, March 04, 2009 5:06 PM:
> My initial thought was that nowhere were you saying that the image was
> floating point. Digging further, I realised that TransferFunction
should be
> doing it for you - I've never used this before - but this line (in
> osg/TransferFunction1D.cpp) looks a little odd to me:   
> 
> _image->setImage(numX,1,1,GL_RGBA, GL_RGBA, GL_FLOAT, (unsigned
> char*)&_colors[0], osg::Image::NO_DELETE); 
> 
> Shouldn't that be "GL_RGBA32F_ARB,GL_RGBA, GL_FLOAT"?
> 
> I guess also doing a texture1D->setInternalFormat(GL_RGBA32F_ARB)
might help,
> but I think (without looking at the code) that osg probably picks this
up
> from the image format anyway.  

I think you're using an older OSG version than I do, since I've only got
TransferFunction.cpp, and TransferFunction1D uses
image->allocateImage(), but either way, setting the Image internal
format to GL_RGBA32F_ARB doesn't help.

I should also note that I'm running an NVIDIA 8800 GT on Windows
(compiled with VS 2005), and osgviewer reports I have ARB_texture_float
supported.
-- 
Bryan Thrall
FlightSafety International
bryan.thr...@flightsafety.com
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Float textures seem to be clamped in GLSL

2009-03-04 Thread David Spilling
Bryan,

My initial thought was that nowhere were you saying that the image was
floating point. Digging further, I realised that TransferFunction should be
doing it for you - I've never used this before - but this line (in
osg/TransferFunction1D.cpp) looks a little odd to me:

_image->setImage(numX,1,1,GL_RGBA, GL_RGBA, GL_FLOAT, (unsigned
char*)&_colors[0], osg::Image::NO_DELETE);

Shouldn't that be "GL_RGBA32F_ARB,GL_RGBA, GL_FLOAT"?

I guess also doing a texture1D->setInternalFormat(GL_RGBA32F_ARB) might
help, but I think (without looking at the code) that osg probably picks this
up from the image format anyway.

Hope that helps.

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


[osg-users] Float textures seem to be clamped in GLSL

2009-03-04 Thread Thrall, Bryan

I'm rather new to using float textures and GLSL, so maybe I'm missing
something. I'm trying to use a float texture as a lookup table in my
fragment shader. I create the texture using osg::TransferFunction1D (see
attached modified osgviewer.cpp), and use the following in my input
file:

---8<---
50
0 0 0
0 0 50
---8<---

For example: osgviewer --pos implicit.pos implicit_surface.osg
(the shaders need to be in a shaders/ subdirectory under
implicit_surface.osg's directory)

My shader takes these positions and renders implicit spheres around
them, with the first line of the position file being the radius.

However, the positions seem to be clamped to [0,1], since the resulting
spheres overlap except for a little bit at the edge (changing the radius
to 1 shows their centers are 1 unit apart). My understanding is that
float textures should be passed through to the shader without clamping.

Is there something I'm doing wrong with osg::TransferFunction1D, or is
my understanding wrong?

Thanks,
--
Bryan Thrall
FlightSafety International
bryan.thr...@flightsafety.com
 


osgviewer.cpp
Description: osgviewer.cpp


implicit_surface.vert
Description: implicit_surface.vert


implicit_surface.frag
Description: implicit_surface.frag


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