Discussion:
[Opensg-users] Billboard particle shader
Victor Haefner
2014-11-04 17:17:49 UTC
Permalink
Hi all,

the gl_ProjectionMatrix allows me to compute the up and right vector in
view coordinates.
vec4 right = gl_ProjectionMatrix*vec4(1,0,0);
vec4 up = gl_ProjectionMatrix*vec4(0,1,0);
I can use those vectors to create a nice quad in the geometry shader.

The problem is when using head tracking (OSGProjectionCameraDecorator).
The orientation of the head messes with the gl_ProjectionMatrix, and thus
with the shape of my quad.

I essentially just need the aspect ratio of the viewport in my shader.
Passing it as a variable is not possible (I think?) because I have a
cluster environment, multiple viewports, with different aspect ratios...

thanks for reading!
best regards,
Victor
Carsten Neumann
2014-11-04 17:30:31 UTC
Permalink
Hello Victor,
Post by Victor Haefner
the gl_ProjectionMatrix allows me to compute the up and right vector in
view coordinates.
vec4 right = gl_ProjectionMatrix*vec4(1,0,0);
vec4 up = gl_ProjectionMatrix*vec4(0,1,0);
I can use those vectors to create a nice quad in the geometry shader.
The problem is when using head tracking (OSGProjectionCameraDecorator).
The orientation of the head messes with the gl_ProjectionMatrix, and
thus with the shape of my quad.
I essentially just need the aspect ratio of the viewport in my shader.
Passing it as a variable is not possible (I think?) because I have a
cluster environment, multiple viewports, with different aspect ratios...
you can use one of the 'magic' OpenSG variables:
uniform vec2 OSGViewportSize;

see Source/State/Shader/Variables/OSGShaderVariableOSG.{h,cpp} and
ShaderProgram::addOSGVariable()

Cheers,
Carsten

------------------------------------------------------------------------------
Victor Haefner
2014-11-04 22:39:24 UTC
Permalink
Hello Carsten,

Thanks a lot! this is exactly what I needed!! :)

best regards,
Victor
Post by Carsten Neumann
Hello Victor,
Post by Victor Haefner
the gl_ProjectionMatrix allows me to compute the up and right vector in
view coordinates.
vec4 right = gl_ProjectionMatrix*vec4(1,0,0);
vec4 up = gl_ProjectionMatrix*vec4(0,1,0);
I can use those vectors to create a nice quad in the geometry shader.
The problem is when using head tracking (OSGProjectionCameraDecorator).
The orientation of the head messes with the gl_ProjectionMatrix, and
thus with the shape of my quad.
I essentially just need the aspect ratio of the viewport in my shader.
Passing it as a variable is not possible (I think?) because I have a
cluster environment, multiple viewports, with different aspect ratios...
uniform vec2 OSGViewportSize;
see Source/State/Shader/Variables/OSGShaderVariableOSG.{h,cpp} and
ShaderProgram::addOSGVariable()
Cheers,
Carsten
------------------------------------------------------------------------------
_______________________________________________
Opensg-users mailing list
https://lists.sourceforge.net/lists/listinfo/opensg-users
Loading...