Re: [osg-users] Instanced geometry using a (non power of two)texture1D like a vertex buffer.

2010-09-23 Thread Jordi Torres
Hi Juan,

+0.5 did the trick! Anyway I will make tests with texelFetch1D and TBO's
looking for a better performance. Thank you for the tips.

Muchas gracias!!

2010/9/23 Juan Hernando 

> Hi Jordi,
> I think the problem is in this line of code in your vertex shader:
>
> vec4 pos= gl_Vertex+
> vec4(texture1D(texturePos,(float(gl_InstanceID)/nInstances)).xyz,0.);
>
> I think that texels are placed in the [0..1] range using their centers and
> not the left edge as your code assumes. That means that if you have to
> texels they are not placed at 0 and 0.5 or 0 and 1 but 0.25 and 0.75. It's
> difficut to assure what happens in 0.5. In short, the nearest texel may not
> be the one you are expecting (only with two images, my guess is that the 9th
> square overdraws the 8th). If your hardware supports it, use texelFetch1D,
> which admits integer coordinates. Maybe adding 0.5 to gl_InstanceID can also
> do the job.
>
> Finally, remember that 1D textures are limited to 8192 texels in current
> hardware (at least mine). You'll need a Texture Buffer Object if you need
> more.
>
> Regards,
> Juan
>
> Jordi Torres wrote:
>
>> Hi all,
>>
>> I am trying to show instanced geometry using a texture1D like a vertex
>> buffer. In fact I have it working more or less... but if my Texture 1D is
>> non power of two then my shader does not render some of the instances.
>> Attached is the code and two images, one with a non power of two texture(9
>> elements) that fails to draw last element, and other with 256 elements
>> that
>> is drawn correctly.
>>
>> I am using TransferFunction1D to pass my geometry array to a texture1D.
>> Anybody knows what I'm doing wrong? Of course I have set
>> texture->setResizeNonPowerOfTwoHint(false);
>>
>> Thank you in advance!
>>
>> Jordi.
>>
>>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
Jordi Torres Fabra

gvSIG 3D blog
http://gvsig3d.blogspot.com
Instituto de Automática e Informática Industrial
http://www.ai2.upv.es
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Instanced geometry using a (non power of two)texture1D like a vertex buffer.

2010-09-23 Thread Juan Hernando

Hi Jordi,
I think the problem is in this line of code in your vertex shader:

vec4 pos= gl_Vertex+ 
vec4(texture1D(texturePos,(float(gl_InstanceID)/nInstances)).xyz,0.);


I think that texels are placed in the [0..1] range using their centers 
and not the left edge as your code assumes. That means that if you have 
to texels they are not placed at 0 and 0.5 or 0 and 1 but 0.25 and 0.75. 
It's difficut to assure what happens in 0.5. In short, the nearest texel 
may not be the one you are expecting (only with two images, my guess is 
that the 9th square overdraws the 8th). If your hardware supports it, 
use texelFetch1D, which admits integer coordinates. Maybe adding 0.5 to 
gl_InstanceID can also do the job.


Finally, remember that 1D textures are limited to 8192 texels in current 
hardware (at least mine). You'll need a Texture Buffer Object if you 
need more.


Regards,
Juan
Jordi Torres wrote:

Hi all,

I am trying to show instanced geometry using a texture1D like a vertex
buffer. In fact I have it working more or less... but if my Texture 1D is
non power of two then my shader does not render some of the instances.
Attached is the code and two images, one with a non power of two texture(9
elements) that fails to draw last element, and other with 256 elements that
is drawn correctly.

I am using TransferFunction1D to pass my geometry array to a texture1D.
Anybody knows what I'm doing wrong? Of course I have set
texture->setResizeNonPowerOfTwoHint(false);

Thank you in advance!

Jordi.



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