[osg-users] sending array as uniform to GLSL

2012-12-02 Thread Christian Rumpf
hello!

By looking into Uniform class reference I figured out that there is no 
overloaded constructor for arrays (or int*, float* etc.).

Is it even possible to have an array (stack and/or heap) as uniform?

lg Christian

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





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


[osg-users] Shader reloading

2012-09-24 Thread Christian Rumpf
hello!

I'm trying to simulate noise effects in real time using OSG and GLSL.

I rendered to texture a scene to get a sampler2D. Mu and Sigma for noise 
simulation are static. My idea is to reload fragment shader in a while loop 
with a random number as uniform because GLSL's noise() function doesn't seem to 
work on my computer. Therefore I wrote a function randomNumber(int from, int 
to) which returns a random int between from and to.


Code:

void loadNoiseShader(int width, int height, osg::Vec3d mue, osg::Vec3d sigma, 
osg::Geode* geode)
{
osg::ref_ptrosg::Shader vertShader = 
osgDB::readShaderFile(osg::Shader::VERTEX, noise.vert);
osg::ref_ptrosg::Shader fragShader = 
osgDB::readShaderFile(osg::Shader::FRAGMENT, noise.frag);

osg::ref_ptrosg::Program program = new osg::Program;
program-addShader(vertShader.get());
program-addShader(fragShader.get());

osg::StateSet* ss = geode-getOrCreateStateSet();
ss-setAttributeAndModes(program.get());

osg::ref_ptrosg::Uniform texUniform = new osg::Uniform(RTScene, 0);
osg::ref_ptrosg::Uniform windowSize = new osg::Uniform(screen, 
osg::Vec2(width, height));
osg::ref_ptrosg::Uniform mueUniform = new osg::Uniform(mue, mue);
osg::ref_ptrosg::Uniform sigmaUniform = new osg::Uniform(sigma, 
sigma);
osg::ref_ptrosg::Uniform randomUniform = new osg::Uniform(random, 
randomNumber(-255, 255));
ss-addUniform(texUniform.get());
ss-addUniform(windowSize.get());
ss-addUniform(sigmaUniform.get());
ss-addUniform(mueUniform.get());
ss-addUniform(randomUniform.get());
}

/*...*/

while(!viewer.done())
{
   loadNoiseShader(width, height, mu, sigma, geode.get());
   viewer.frame();
}




I thought that this would work, but unfortunately the executive crashes at the 
beginning. Can someone explain me that please?

lg Chris

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





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


Re: [osg-users] Render to texture, display pre-rendered scene

2012-06-25 Thread Christian Rumpf
Hey again. As I posted before I managed to render to texture a scene and 
projected it onto a Geometry. But it is just an image of a scene and the RTT 
camera can't move around my object (cessna.osg).

Is there a way to move the camera freely around like you would do with viewer's 
camera?

lg Christian

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





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


Re: [osg-users] Render to texture, display pre-rendered scene

2012-06-25 Thread Christian Rumpf

robertosfield wrote:
 Hi Christian,
 
 thank you
 
 Have a look at the osgdistortion example.
 
 Robert.
 
 On 25 June 2012 11:20, Christian Rumpf  wrote:
 
  Hey again. As I posted before I managed to render to texture a scene and 
  projected it onto a Geometry. But it is just an image of a scene and the 
  RTT camera can't move around my object (cessna.osg).
  
  Is there a way to move the camera freely around like you would do with 
  viewer's camera?
  
  lg Christian
  
  --
  Read this topic online here:
  http://forum.openscenegraph.org/viewtopic.php?p=48474#48474
  
  
  
  
  
  ___
  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=48476#48476





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


Re: [osg-users] Render to texture, display pre-rendered scene

2012-06-11 Thread Christian Rumpf
This really sounds helpful, Robert, but for some reason this examples you 
recommended aren't understandable for me. They all tells about reflecting, 
printing it into a flag and so on. isn't there an example which just renders a 
single node, a single box or something else into a texture and projects it into 
the viewer? Just a single object, no camera effects, no artefacts, no 
movements, nothing but a single object.

My problem is that all this examples (and I found a lot in the internet) 
explains how useful this RTT technique is, but aren't understandable after all. 
This sounds like I'm not good in graphics programming, but sometimes small 
steps are necessary. I can't take this big stuffs as start.

lg Christian

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





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


Re: [osg-users] Render to texture, display pre-rendered scene

2012-06-11 Thread Christian Rumpf
No need anymore, Robert. I finally a homepage which explains everything about 
render to texture:

http://beefdev.blogspot.de/2012/01/render-to-texture-in-openscenegraph.html

It really helped me, and I finally could load my shader files with texture as 
uniform sampler2D. Nevertheless thank you very much, Robert.

lg Christian

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





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


[osg-users] Render to texture, display pre-rendered scene

2012-06-07 Thread Christian Rumpf
Hey!

I read nearly everything about render to texture techniques and what you can do 
with them, but not how to SIMPLY display it. My intention is to pre-render the 
scene into a texture and sending this texture into my fragment shader (GLSL) to 
simulate blur effects.

But before I can do this shading stuff I need to display this pre-rendered 
scene and I don't know how to do it. Here my code so you can see what I 
programmed:


Code:
#include osg/Node
#include osg/Texture2D
#include osg/Shader
#include osgDB/ReadFile
#include osgViewer/Viewer

#include iostream

osg::Camera* createRTTCamera(int width, int height, osg::Texture2D* texture)
{
texture-setTextureSize(width, height);
texture-setInternalFormat(GL_RGB);
texture-setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR);
texture-setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR);

osg::ref_ptrosg::Camera rttCamera = new osg::Camera;

rttCamera-setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
rttCamera-setClearColor(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
rttCamera-setViewport(0, 0, width, height);
rttCamera-setRenderOrder(osg::Camera::PRE_RENDER);
rttCamera-setReferenceFrame(osg::Transform::RELATIVE_RF);

rttCamera-setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
rttCamera-attach(osg::Camera::COLOR_BUFFER, texture);

return rttCamera.release();
}

int main(int argc, char** argv)
{
osg::ref_ptrosg::Node model = osgDB::readNodeFile(cessna.osg);

osg::ref_ptrosg::Texture2D texture = new osg::Texture2D;
osg::ref_ptrosg::Camera camera = createRTTCamera(1600, 900, 
texture.get());
camera-addChild(model.get());

osg::StateSet* ss = model-getOrCreateStateSet();
ss-setTextureAttributeAndModes(0, texture.get(), 
osg::StateAttribute::ON);

osg::ref_ptrosg::Group root = new osg::Group;
root-addChild(camera.get());

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




By running this code I get nothing, only if I add this line before my viewer my 
plane appears:


Code:
root-addChild(model.get());




Can someone help me out?

lg Christian

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





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


[osg-users] [osgPPU] Problems installing osgPPU using cmake 2.8.4

2012-06-05 Thread Christian Rumpf
I tried to install the latest osgPPU version I found today, using cmake 2.8.4 
and Visual Studio 10, but when i started to configure the folder I got the 
following cmake-error:


 Check for working C compiler using: Visual Studio 10
 Check for working C compiler using: Visual Studio 10 -- works
 Detecting C compiler ABI info
 Detecting C compiler ABI info - done
 Check for working CXX compiler using: Visual Studio 10
 Check for working CXX compiler using: Visual Studio 10 -- works
 Detecting CXX compiler ABI info
 Detecting CXX compiler ABI info - done
 Found OpenGL: opengl32 
 CUDA installation wasn't found
 Could not find nvcc, CUDA examples wouldn't be built
 Could not find cudart library (cudart)
 Could not find cuda libraries.
 CMake Warning (dev) at CMakeLists.txt:45 (INCLUDE):
   Policy CMP0011 is not set: Included scripts do automatic cmake_policy PUSH
   and POP.  Run cmake --help-policy CMP0011 for policy details.  Use the
   cmake_policy command to set the policy and suppress this warning.
 
   The included script
 
 C:/osgPPU-0.4.0/CMakeModules/cuda/FindCuda.cmake
 
   affects policy settings.  CMake is implying the NO_POLICY_SCOPE option for
   compatibility, so the effects are applied to the including context.
 This warning is for project developers.  Use -Wno-dev to suppress it.
 
 CMake Error: The following variables are used in this project, but they are 
 set to NOTFOUND.
 Please set them or make sure they are set and tested correctly in the CMake 
 files:
 OPENTHREADS_LIBRARY_RELEASE
 linked by target osgppu_hdr in directory C:/osgPPU-0.4.0/src/example/hdr
 linked by target osgppu_viewer in directory 
 C:/osgPPU-0.4.0/src/example/viewer
 linked by target osgppu_dof in directory C:/osgPPU-0.4.0/src/example/dof
 linked by target osgppu_cubemap in directory 
 C:/osgPPU-0.4.0/src/example/cubemap
 linked by target osgppu_texture3D in directory 
 C:/osgPPU-0.4.0/src/example/texture3D
 linked by target osgppu_video in directory 
 C:/osgPPU-0.4.0/src/example/video
 linked by target osgppu_ssao in directory 
 C:/osgPPU-0.4.0/src/example/ssao
 linked by target osgppu_glow in directory 
 C:/osgPPU-0.4.0/src/example/glow
 linked by target osgPPU in directory C:/osgPPU-0.4.0/src/osgPPU
 OSGDB_LIBRARY_RELEASE
 linked by target osgppu_hdr in directory C:/osgPPU-0.4.0/src/example/hdr
 linked by target osgppu_viewer in directory 
 C:/osgPPU-0.4.0/src/example/viewer
 linked by target osgppu_dof in directory C:/osgPPU-0.4.0/src/example/dof
 linked by target osgppu_cubemap in directory 
 C:/osgPPU-0.4.0/src/example/cubemap
 linked by target osgppu_texture3D in directory 
 C:/osgPPU-0.4.0/src/example/texture3D
 linked by target osgppu_video in directory 
 C:/osgPPU-0.4.0/src/example/video
 linked by target osgppu_ssao in directory 
 C:/osgPPU-0.4.0/src/example/ssao
 linked by target osgppu_glow in directory 
 C:/osgPPU-0.4.0/src/example/glow
 linked by target osgPPU in directory C:/osgPPU-0.4.0/src/osgPPU
 OSGGA_LIBRARY_RELEASE
 linked by target osgppu_hdr in directory C:/osgPPU-0.4.0/src/example/hdr
 linked by target osgppu_viewer in directory 
 C:/osgPPU-0.4.0/src/example/viewer
 linked by target osgppu_dof in directory C:/osgPPU-0.4.0/src/example/dof
 linked by target osgppu_cubemap in directory 
 C:/osgPPU-0.4.0/src/example/cubemap
 linked by target osgppu_texture3D in directory 
 C:/osgPPU-0.4.0/src/example/texture3D
 linked by target osgppu_video in directory 
 C:/osgPPU-0.4.0/src/example/video
 linked by target osgppu_ssao in directory 
 C:/osgPPU-0.4.0/src/example/ssao
 linked by target osgppu_glow in directory 
 C:/osgPPU-0.4.0/src/example/glow
 OSGTEXT_LIBRARY_RELEASE
 linked by target osgppu_hdr in directory C:/osgPPU-0.4.0/src/example/hdr
 linked by target osgppu_viewer in directory 
 C:/osgPPU-0.4.0/src/example/viewer
 linked by target osgppu_dof in directory C:/osgPPU-0.4.0/src/example/dof
 linked by target osgppu_cubemap in directory 
 C:/osgPPU-0.4.0/src/example/cubemap
 linked by target osgppu_texture3D in directory 
 C:/osgPPU-0.4.0/src/example/texture3D
 linked by target osgppu_video in directory 
 C:/osgPPU-0.4.0/src/example/video
 linked by target osgppu_ssao in directory 
 C:/osgPPU-0.4.0/src/example/ssao
 linked by target osgppu_glow in directory 
 C:/osgPPU-0.4.0/src/example/glow
 linked by target osgPPU in directory C:/osgPPU-0.4.0/src/osgPPU
 OSGUTIL_LIBRARY_RELEASE
 linked by target osgppu_hdr in directory C:/osgPPU-0.4.0/src/example/hdr
 linked by target osgppu_viewer in directory 
 C:/osgPPU-0.4.0/src/example/viewer
 linked by target osgppu_dof in directory C:/osgPPU-0.4.0/src/example/dof
 linked by target osgppu_cubemap in directory 
 C:/osgPPU-0.4.0/src/example/cubemap
 linked by target osgppu_texture3D in directory 
 C:/osgPPU-0.4.0/src/example/texture3D
 linked by target osgppu_video in directory 
 

Re: [osg-users] OSG fragment shader

2012-05-31 Thread Christian Rumpf
the image processing effect should work in realtime (i.e. blur shading). shall 
I send the texture coordinates from vertex shader into fragment shader or is it 
ok to just use a fragment shader for image processing?

My intenstion:

I have to create a scene where I can freely move my camera. I can either load 
one of the prepared *.osg files OR create some drawables and let them display 
it with osg::Viewer (as I know you just need 5-10 lines for that).

I heard of a method called render-to-texture, but I'm not sure if this is 
efficient for realtime shading.

lg Christian

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





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


[osg-users] osgDB::readImageFile don't work correctly

2012-05-31 Thread Christian Rumpf
Hi,

I wanted to experiment a little bit with osg::Image, but when I used 
osgDB::readImageFile(...); in my beginner's guide to read a png, I got the 
following message:


 Warning: Could not find plugin to read objects from file clockface.jpg.


I installed osg-library according to osg guide with cmake for VS 2010. Does 
somebody know what the issue could be?

lg Christian

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





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


[osg-users] OSG fragment shader

2012-05-25 Thread Christian Rumpf
Hello everyone!

I just learned GLSL and image processing using different filter masks. Now I 
want to implement this into my OSG-project, but my test object (a cow ^^) is 
black, totally black.

For the beginning I used the following code for fragment shader:


Code:

uniform sampler2D image;

void main()
{
   gl_FragColor = texture2D(image, gl_FragCoord.xy);
}




glShaderCompiler said that this code is ok, no errors, but still my test object 
is black.

My Question:
How do I uniform sampler2D which should be my realtime output image?

lg Christian

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





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