Re: [osg-users] Trouble with a simple shader program.

2015-04-12 Thread Alexander Wieser
Hi,

thank you for providing me with some insight.
I had already stumbled upon exactly this example:


> 
>   // for non GL3/GL4 and non GLES2 platforms we need enable the osg_ uniforms 
> that the shaders will use,
> // you don't need thse two lines on GL3/GL4 and GLES2 specific builds as 
> these will be enable by default.
> gc->getState()->setUseModelViewAndProjectionUniforms(true);
> gc->getState()->setUseVertexAttributeAliasing(true); 
> 


I was under the assumption that my machine uses the GL4 core program.
After further inspection I realized that Ubuntu runs OpenGL 4.3 in 
Compatibility Mode for whatever reason.

After changing everything back to the gl_ prefix I can now see the red color.

Thank you!

Cheers,
Alexander[/quote]

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





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


Re: [osg-users] Trouble with a simple shader program.

2015-04-12 Thread Alexander Wieser
Hi,

unfortunately there is no negative output, the shader compiles fine.

I doubt there will be any errors if the input channels are simply not set.
In that case they will be zero and the output vertex will also be zero, which 
would explain the lack of any visible pixels, can't be sure though.

Thank you!

Cheers,
Alexander

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





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


Re: [osg-users] Trouble with a simple shader program.

2015-04-12 Thread Robert Osfield
Hi Alexander,

If you want to use the osg_ModelViewMatrix then you need to enable it via
the osg::State object for the graphics context.  See the osgsimplegl3
example, it has:

// for non GL3/GL4 and non GLES2 platforms we need enable the osg_
uniforms that the shaders will use,
// you don't need thse two lines on GL3/GL4 and GLES2 specific builds
as these will be enable by default.
gc->getState()->setUseModelViewAndProjectionUniforms(true);
gc->getState()->setUseVertexAttributeAliasing(true);

If you don't need to use GL3 or GL4 core profile, then you can just use GL2
profile which is the default for the OSG, here you can happily use
gl_ModelViewMatrix etc.  Most of the other OSG shader examples use this
approach.  Just do a search for osg::Shader in the OSG code base and you'll
find plenty of the examples to learn from.

Robert.



On 11 April 2015 at 18:21, Alexander Wieser  wrote:

> Hi,
>
> I am currently working on my bachelor thesis using which involves the
> OpenSceneGraph. One task is to apply a distortion Shader to a rendered
> texture.
>
> Unfortunately I am failing in getting any Shader to work at all.
> After spending the last couple of days researching and reading books, I
> managed to get several shaders running in other libraries, be it online
> using WebGL or directly using OpenGL. I simply can't get it running using
> OSG.
>
> The code initializing the program is this.
>
>
> Code:
>
> // A simple 4 vertex rectangular geometry drawable.
> Plane* plane = new Plane(40);
> this->addDrawable(plane);
>
> osg::Program* program = new osg::Program();
> program->setName("Debug Shader");
>
> // This refers to a Geode.
> osg::StateSet& state = *this->getOrCreateStateSet();
> state.setAttributeAndModes(program, osg::StateAttribute::ON);
>
> boost::filesystem::path currentPath(boost::filesystem::current_path());
>
> // Init vertex shader.
> RTT::log(RTT::Debug) << "Loading vertex shader."<< RTT::endlog();
> osg::Shader* vertexShader = new osg::Shader(osg::Shader::VERTEX);
> vertexShader->loadShaderSourceFromFile(currentPath.string() +
> "/../resources/shaders/debug.vert");
> program->addShader(vertexShader);
>
> // Init fragment shader.
> RTT::log(RTT::Debug) << "Loading fragment shader."<< RTT::endlog();
> osg::Shader* fragmentShader = new osg::Shader(osg::Shader::FRAGMENT);
> fragmentShader->loadShaderSourceFromFile(currentPath.string() +
> "/../resources/shaders/debug.frag");
> program->addShader(fragmentShader);
>
>
>
>
>
> Vertex Shader
>
> Code:
>
> #version 430
>
> uniform mat4 osg_ModelViewProjectionMatrix;
> in vec4 osg_Vertex;
>
> void main() {
> gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;
> }
>
>
>
>
>
> Fragment Shader
>
> Code:
>
> #version 430
>
> layout(location = 0) out vec4 FragColor;
>
> void main() {
> FragColor = vec4(1.0, 0.0, 0.0, 1.0);
> }
>
>
>
>
> As you can see, the program is not that complicated and does compile fine.
> Unfortunately I don't see anything on the screen. There is no model.
> If I remove the program and simply use the built in lighting, coloring and
> texturing support it renders fine.
>
> Any help is greatly appreciated.
>
>
> Thank you!
>
> Cheers,
> Alexander
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=63328#63328
>
>
>
>
>
> ___
> 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] Trouble with a simple shader program.

2015-04-12 Thread Şan Güneş
Hello Alexander,

On 11/04/2015 20:21, Alexander Wieser wrote:
> Vertex Shader
>
> Code:
>
> #version 430
>
> uniform mat4 osg_ModelViewProjectionMatrix;
> in vec4 osg_Vertex;
>
> void main() {
> gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;
> }

I don't remember using anything that starts with osg_* in the vertex
shader code that I have used with OSG.
You can try using the built-in uniforms of the OpenGL, like "gl_Position
= gl_ModelViewProjectionMatrix * gl_Vertex;" or simply "gl_Position =
ftransform();"

If you have the "OpenSceneGraph 3 Cookbook", you can refer to the point
cloud example there.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Trouble with a simple shader program.

2015-04-12 Thread Sebastian Messerschmidt

  
  Have you tried to use the gl_ModelviewProjectionMatrix? I don't have seen any reference to enableVertexAttributeAliasing.

Cheers 
Sebastian
--

Alexander Wieser schrieb:

Hi,

I am currently working on my bachelor thesis which involves the OpenSceneGraph. One task is to apply a distortion shader to a rendered texture.

Unfortunately I am failing in getting any shader to work at all.
After spending the last couple of days researching and reading books, I managed to get several shaders running in other libraries, be it online using WebGL or directly using OpenGL. I simply can't get it running using OSG.

The code initializing the program is this.


Code:

// A simple 4 vertex rectangular geometry drawable.
Plane* plane = new Plane(40);
this->addDrawable(plane);

osg::Program* program = new osg::Program();
program->setName("Debug Shader");

// This refers to a Geode.
osg::StateSet& state = *this->getOrCreateStateSet();
state.setAttributeAndModes(program, osg::StateAttribute::ON);

boost::filesystem::path currentPath(boost::filesystem::current_path());

// Init vertex shader.
RTT::log(RTT::Debug) << "Loading vertex shader."<< RTT::endlog();
osg::Shader* vertexShader = new osg::Shader(osg::Shader::VERTEX);
vertexShader->loadShaderSourceFromFile(currentPath.string() + "/../resources/shaders/debug.vert");
program->addShader(vertexShader);

// Init fragment shader.
RTT::log(RTT::Debug) << "Loading fragment shader."<< RTT::endlog();
osg::Shader* fragmentShader = new osg::Shader(osg::Shader::FRAGMENT);
fragmentShader->loadShaderSourceFromFile(currentPath.string() + "/../resources/shaders/debug.frag");
program->addShader(fragmentShader);





Vertex Shader

Code:

#version 430

uniform mat4 osg_ModelViewProjectionMatrix;
in vec4 osg_Vertex;

void main() {
gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;
}





Fragment Shader

Code:

#version 430

layout(location = 0) out vec4 FragColor;

void main() {
FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}




As you can see, the program is not that complicated and does compile fine.
Unfortunately I don't see anything on the screen. There is no model.
If I remove the program and simply use the built in lighting, coloring and texturing support it renders fine.

Any help is greatly appreciated.


Thank you!

Cheers,
Alexander

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





___
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] Trouble with a simple shader program.

2015-04-11 Thread Trajce Nikolov NICK
Hi Alexander,

what does it says on the console? Any shader errors, obviously it reports
if the shader is buggy

Nick

On Sun, Apr 12, 2015 at 1:23 AM, Alexander Wieser <
alexander.wie...@crystalbyte.de> wrote:

> Hi,
>
> I managed to get one step closer, if I remove the vertex shader the color
> is properly displayed.
>
> The obvious conclusion is that the vertex shader is bullocks ...
> Is it possible that the attributes, such as osg_Vertex are no longer
> available ?
>
> Thank you!
>
> Cheers,
> Alexander
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=6#6
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



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


Re: [osg-users] Trouble with a simple shader program.

2015-04-11 Thread Alexander Wieser
Hi,

I managed to get one step closer, if I remove the vertex shader the color is 
properly displayed.

The obvious conclusion is that the vertex shader is bullocks ...
Is it possible that the attributes, such as osg_Vertex are no longer available ?

Thank you!

Cheers,
Alexander

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





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


Re: [osg-users] Trouble with a simple shader program.

2015-04-11 Thread Alexander Wieser
Hi,

I am currently working on my bachelor thesis which involves the OpenSceneGraph. 
One task is to apply a distortion shader to a rendered texture.

Unfortunately I am failing in getting any shader to work at all.
After spending the last couple of days researching and reading books, I managed 
to get several shaders running in other libraries, be it online using WebGL or 
directly using OpenGL. I simply can't get it running using OSG.

The code initializing the program is this.


Code:

// A simple 4 vertex rectangular geometry drawable.
Plane* plane = new Plane(40);
this->addDrawable(plane);

osg::Program* program = new osg::Program();
program->setName("Debug Shader");

// This refers to a Geode.
osg::StateSet& state = *this->getOrCreateStateSet();
state.setAttributeAndModes(program, osg::StateAttribute::ON);

boost::filesystem::path currentPath(boost::filesystem::current_path());

// Init vertex shader.
RTT::log(RTT::Debug) << "Loading vertex shader."<< RTT::endlog();
osg::Shader* vertexShader = new osg::Shader(osg::Shader::VERTEX);
vertexShader->loadShaderSourceFromFile(currentPath.string() + 
"/../resources/shaders/debug.vert");
program->addShader(vertexShader);

// Init fragment shader.
RTT::log(RTT::Debug) << "Loading fragment shader."<< RTT::endlog();
osg::Shader* fragmentShader = new osg::Shader(osg::Shader::FRAGMENT);
fragmentShader->loadShaderSourceFromFile(currentPath.string() + 
"/../resources/shaders/debug.frag");
program->addShader(fragmentShader);





Vertex Shader

Code:

#version 430

uniform mat4 osg_ModelViewProjectionMatrix;
in vec4 osg_Vertex;

void main() {
gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;
}





Fragment Shader

Code:

#version 430

layout(location = 0) out vec4 FragColor;

void main() {
FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}




As you can see, the program is not that complicated and does compile fine.
Unfortunately I don't see anything on the screen. There is no model.
If I remove the program and simply use the built in lighting, coloring and 
texturing support it renders fine.

Any help is greatly appreciated.


Thank you!

Cheers,
Alexander

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





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


[osg-users] Trouble with a simple shader program.

2015-04-11 Thread Alexander Wieser
Hi,

I am currently working on my bachelor thesis using which involves the 
OpenSceneGraph. One task is to apply a distortion Shader to a rendered texture.

Unfortunately I am failing in getting any Shader to work at all.
After spending the last couple of days researching and reading books, I managed 
to get several shaders running in other libraries, be it online using WebGL or 
directly using OpenGL. I simply can't get it running using OSG.

The code initializing the program is this.


Code:

// A simple 4 vertex rectangular geometry drawable.
Plane* plane = new Plane(40);
this->addDrawable(plane);

osg::Program* program = new osg::Program();
program->setName("Debug Shader");

// This refers to a Geode.
osg::StateSet& state = *this->getOrCreateStateSet();
state.setAttributeAndModes(program, osg::StateAttribute::ON);

boost::filesystem::path currentPath(boost::filesystem::current_path());

// Init vertex shader.
RTT::log(RTT::Debug) << "Loading vertex shader."<< RTT::endlog();
osg::Shader* vertexShader = new osg::Shader(osg::Shader::VERTEX);
vertexShader->loadShaderSourceFromFile(currentPath.string() + 
"/../resources/shaders/debug.vert");
program->addShader(vertexShader);

// Init fragment shader.
RTT::log(RTT::Debug) << "Loading fragment shader."<< RTT::endlog();
osg::Shader* fragmentShader = new osg::Shader(osg::Shader::FRAGMENT);
fragmentShader->loadShaderSourceFromFile(currentPath.string() + 
"/../resources/shaders/debug.frag");
program->addShader(fragmentShader);





Vertex Shader

Code:

#version 430

uniform mat4 osg_ModelViewProjectionMatrix;
in vec4 osg_Vertex;

void main() {
gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;
}





Fragment Shader

Code:

#version 430

layout(location = 0) out vec4 FragColor;

void main() {
FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}




As you can see, the program is not that complicated and does compile fine.
Unfortunately I don't see anything on the screen. There is no model.
If I remove the program and simply use the built in lighting, coloring and 
texturing support it renders fine.

Any help is greatly appreciated.


Thank you!

Cheers,
Alexander

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





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