Re: [osg-users] OSG and shaders

2009-08-12 Thread Hadrien Thomas
Hello everybody!

Afeter some research on the net, I gathered some clues, day after day and I 
managed to make the shader i had to... just in part.

I have no more problem with shaders! My only concern is now Openscenegraph.

I don't understand AT ALL who has the knowledge of this language??
The research system on openscenegraph.org is UN-understandable, tutorials are 
cruelly missing in every field...

The class guide is very useful... when you know what does the class and methods 
already!
A simple explanation of one sentence could be great but there isn't any!

So I'm back on the forum trying to get some help because it's impossible to do 
it alone.

In my shader, i have to build a radial wave on textures (using normal light 
changes) by clicking.
With fixed coordinates of the click, I managed to do it.
I have the idea of how doing it for several clicks but I need arrays...

I do know how to push_back but i don't know how to withdraw elements...

I am stunned I can't find this information anywhere.

Thank you if you can help me!

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





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


Re: [osg-users] OSG and shaders

2009-08-12 Thread Kim Bale
Hi Hadrien,

The learning curve for the OSG is pretty steep, I think we can all
agree on that. However, if you have a good knowledge of graphics in
general or OpenGL in particular, the transition to the OSG is fairly
straightforward.

Documentation can be sparse in some areas, but one should remember
that the OSG is a free, fully featured scenegraph that is fully
capable of rivalling the commercial alternatives. Providing
comprehensive documentation of every function and class is an
extremely time consuming task and I think it is more desirable to have
extra functionality than a lesser featured scenegraph with masses of
documentation.

But anyway.. the way I and I think the majority of the people here
learnt how to use the OSG is by looking at the examples in the source
and then if that doesn't help, by looking at the OSG source itself.

 I have the idea of how doing it for several clicks but I need arrays...
 I do know how to push_back but i don't know how to withdraw elements...

To be honest this doesn't sound like an OSG question but more of a
general programming issue. Try looking at the documentation for
osg::Array or indeed the STL vector.

Regards,

Kim.


2009/8/12 Hadrien Thomas thomas.hadr...@gmail.com:
 Hello everybody!

 Afeter some research on the net, I gathered some clues, day after day and I 
 managed to make the shader i had to... just in part.

 I have no more problem with shaders! My only concern is now Openscenegraph.

 I don't understand AT ALL who has the knowledge of this language??
 The research system on openscenegraph.org is UN-understandable, tutorials are 
 cruelly missing in every field...

 The class guide is very useful... when you know what does the class and 
 methods already!
 A simple explanation of one sentence could be great but there isn't any!

 So I'm back on the forum trying to get some help because it's impossible to 
 do it alone.

 In my shader, i have to build a radial wave on textures (using normal light 
 changes) by clicking.
 With fixed coordinates of the click, I managed to do it.
 I have the idea of how doing it for several clicks but I need arrays...

 I do know how to push_back but i don't know how to withdraw elements...

 I am stunned I can't find this information anywhere.

 Thank you if you can help me!

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





 ___
 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] OSG and shaders

2009-08-12 Thread J.P. Delport

Hi,

also see here:
http://mew.cx/osg_glsl_july2005.pdf

OpenSceneGraph Quick Start Guide
http://www.lulu.com/content/paperback-book/openscenegraph-quick-start-guide/767629

Mail archives
http://news.gmane.org/gmane.comp.graphics.openscenegraph.user

OpenGL Shading Language
http://www.amazon.com/OpenGL-Shading-Language-Randi-Rost/dp/0321637631/

To use GLSL and OSG effectively you will have to read a lot: books, web 
pages, mailing list archives and even code. All the information is out 
there.


jp

Hadrien Thomas wrote:

Hello everybody!

Afeter some research on the net, I gathered some clues, day after day and I 
managed to make the shader i had to... just in part.

I have no more problem with shaders! My only concern is now Openscenegraph.

I don't understand AT ALL who has the knowledge of this language??
The research system on openscenegraph.org is UN-understandable, tutorials are 
cruelly missing in every field...

The class guide is very useful... when you know what does the class and methods 
already!
A simple explanation of one sentence could be great but there isn't any!

So I'm back on the forum trying to get some help because it's impossible to do 
it alone.

In my shader, i have to build a radial wave on textures (using normal light 
changes) by clicking.
With fixed coordinates of the click, I managed to do it.
I have the idea of how doing it for several clicks but I need arrays...

I do know how to push_back but i don't know how to withdraw elements...

I am stunned I can't find this information anywhere.

Thank you if you can help me!

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





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


--
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] OSG and shaders

2009-08-12 Thread Maxime BOUCHER

carnibirdy wrote:
 Hello everybody!
 
 Afeter some research on the net, I gathered some clues, day after day and I 
 managed to make the shader i had to... just in part.
 
 I have no more problem with shaders! My only concern is now Openscenegraph.
 
 I don't understand AT ALL who has the knowledge of this language??
 The research system on openscenegraph.org is UN-understandable, tutorials are 
 cruelly missing in every field...
 
 The class guide is very useful... when you know what does the class and 
 methods already!
 A simple explanation of one sentence could be great but there isn't any!
 
 So I'm back on the forum trying to get some help because it's impossible to 
 do it alone.
 
 In my shader, i have to build a radial wave on textures (using normal light 
 changes) by clicking.
 With fixed coordinates of the click, I managed to do it.
 I have the idea of how doing it for several clicks but I need arrays...
 
 I do know how to push_back but i don't know how to withdraw elements...
 
 I am stunned I can't find this information anywhere.
 
 Thank you if you can help me!

Hi,

 As Kim and I told you, if you want to be cumfortable with OpenSceneGraph, the 
best is to cumfortable with OpenGL.

Cheers,


Max

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





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


Re: [osg-users] OSG and shaders

2009-08-12 Thread Hadrien Thomas
I've asked a friend what to do. He told me to look in the sources, which I am 
doing right now and might help me for every problem instead of coming here 
whining about the lack of documentation (which I now understand thanks to you 
Kim Bale). Beign a noob, I forgot OSG was opensource...

He told me about the STL vector too, I hope I will find something there  :P 

Thanks for your answers :)

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





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


Re: [osg-users] OSG and shaders

2009-08-12 Thread Tomlinson, Gordon
OSG its self has over 140 examples, plus applications like OsgViewer ,
there are many more examples on the web, there are more tutorials on web
and on the OSG Web site these will give you over 200 working examples
and tutorials on how to use/ learn OSG. There's several FAQ's out on the
web as well as the OSG site

There is a an excellent Quick start Guide to OSG written by Paul Martz
which you can down load for free

But like anything you actually need to take the time and run the
examples, work through tutorials to get an understanding.  OSG is like
many programming things you learn by doing and you have the advantage of
access to the FULL source code so no  black boxes, but to fully
appreciate OSG or any other scene graph you need to have at least a good
understanding of basic OpenGl , OSG in simplistic terms just wraps and
extend Opengl to be more useful, 

You will find a lot of people here will help you and are much more
tolerant than many other user groups (
http://www.catb.org/~esr/faqs/smart-questions.html ) , but just coming
on and attacking OSG will likely turn many off helping out



http://www.osgbooks.com/books/osg_qs.html
http://www.openscenegraph.org/projects/osg/wiki/Support/Tutorials
http://www.vis-sim.com/osg/index.htm
http://www.openscenegraph.org/projects/osg/wiki/Support/UserGuides
http://www.openscenegraph.org/projects/osg/wiki/Support/ProgrammingGuide
s
http://www.openscenegraph.org/projects/osg/wiki/Support/ReferenceGuides
http://www.openscenegraph.org/projects/osg/wiki/Support/KnowledgeBase



Gordon
Product Manager 3d
__
Gordon Tomlinson
Email  : gtomlinson @ overwatch.textron.com
__


-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Hadrien
Thomas
Sent: Wednesday, August 12, 2009 7:33 AM
To: osg-users@lists.openscenegraph.org
Subject: Re: [osg-users] OSG and shaders

I've asked a friend what to do. He told me to look in the sources, which
I am doing right now and might help me for every problem instead of
coming here whining about the lack of documentation (which I now
understand thanks to you Kim Bale). Beign a noob, I forgot OSG was
opensource...

He told me about the STL vector too, I hope I will find something there
:P 

Thanks for your answers :)

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





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


Re: [osg-users] OSG and shaders

2009-08-06 Thread Hadrien Thomas
Thank you for the book reference. I will think about purchasing it. I can 
afford it but it's a big expense for me  :-* 

For now, I'm still blocked with OSG.
I want to map the same texture to the 6 faces of a cube.

I made a Geometry called cube and 6 DrawElementsUInt called face1/2/.../6.

I don't know how to setTexCoords to each QUADS.
I thought about making 6 Geometry so I can use a same vertice several times but 
I don't find any method able to link them into a cube as a single geometry.

Is there any other solution? Maybe I can do it with shaders but with so few 
experience I can't see the possibilities they bring.

Thanks again for your help :)

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





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


Re: [osg-users] OSG and shaders

2009-08-06 Thread Kim Bale
I agree with Paul, the Orange book is a *must have* title if you're
learning shaders.

http://books.google.co.uk/books?id=kDXOXv_GeswCdq=opengl+shader+languageprintsec=frontcoversource=bnhl=enei=E5Z6Svb-K5Cy-AbQ87lSsa=Xoi=book_resultct=resultresnum=5#v=onepageq=opengl%20shader%20languagef=false

2009/8/5 Paul Speed psp...@progeeks.com:
 And it deserves saying, if you can get your hands on an OpenGL Orange Book
 you'll be that many more steps ahead.  I thought it was really good at
 explaining things in depth while also being easily navigated to drill in on
 target areas.

 I had complex shaders up and running in a few days with that book... I have
 had some embedded-style coding experience before, though.

 -Paul

 Maxime BOUCHER wrote:

 Well,

  I'm doing an internship too.

 At the beginning I didn't know osg at all, neither shaders.
 There are still an extraordinary amount of things I ignore about OSG (my
 advice: when you try to do or understand something, take a look at how it's
 done in OpenGL).
 Shaders aren't as hard to use as OSG, I discovered about one month ago and
 I can now write some modests but nice effects.

 The essential is to read code and tutorials.
 Don't try to go fast, it's the best way to misunderstand what you
 manipulate and to write bad code, failing your internship. You have 6
 months, you can waste it OR spend 2 months to understand osg and shaders and
 then writting good code, masterizing your internship.

 Thus, first read a few osg tutorials (to understand how textures are
 mapped for example, it seems you don't), I think the 4 or 5 firsts should be
 enough.
 After, try to understand what is a shader (I guess you don't really).
 Then try to understand the shader tutorials from typhoonlabs, or this
 (http://www.siteduzero.com/tutoriel-3-8879-communiquer-avec-l-application-attributs-et-uniforms.html?bcsi-ac-20A76BC15DBD50F6=194870AE0303lbVE9ryZWUuZzrBgMzY7DS6IPWi9BwMAAMDCRwEQDgAAINVbBwA=),
 it's in french.
 I advice to look at osgshader example ONLY to understand (or copy the
 code) how to load and activate a shader, it's 5 lines.

 Don't take me for moralistic, I did these errors.

 Good luck and take your time, it's the best way to success.

 Cheers,
 Maxime

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





 ___
 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

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


Re: [osg-users] OSG and shaders

2009-08-06 Thread Maxime BOUCHER
Hi,


carnibirdy wrote:
 
 For now, I'm still blocked with OSG.
 I want to map the same texture to the 6 faces of a cube.
 
 I made a Geometry called cube and 6 DrawElementsUInt called face1/2/.../6.
 
 I don't know how to setTexCoords to each QUADS.
 I thought about making 6 Geometry so I can use a same vertice several times 
 but I can't find any method able to link them into a cube as a single 
 geometry.
 
 Is there any other solution? 
 

Look at this:
http://faculty.nps.edu/jasullivan/osgtutorials/


carnibirdy wrote:
 
 Maybe I can do it with shaders but with so few experience I can't see the 
 possibilities they bring.
 

It depends on what you want to do.
It seems to me you don't want to do it this way.


Cheers,

Max

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





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


Re: [osg-users] OSG and shaders

2009-08-05 Thread Maxime BOUCHER
Hi,

@btrall:
 Where do you find this ShaderGen? I found it neither in the classlist nor the 
osg examples.

@carnibirdy:
Rewritting the lights effects and texture mapping in the shader is quite easy.
You can find implementation examples here (http://www.typhoonlabs.com/), in the 
OpenGL Shading Language Course part or here 
(http://www-evasion.imag.fr/Membres/Sebastien.Barbier/Enseignement/tp_glsl.zip) 
for several shaders, including a phong lighting.
For the texture mapping see this post 
(http://forum.openscenegraph.org/viewtopic.php?t=3293).


Have fun!

Cheers,
Maxime

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





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


Re: [osg-users] OSG and shaders

2009-08-05 Thread Ulrich Hertlein

On 5/08/09 11:41 AM, Maxime BOUCHER wrote:

@btrall:
  Where do you find this ShaderGen? I found it neither in the classlist nor the 
osg examples.


It could be that it's not part of 2.8 but in trunk it's in:
src/osgUtil/ShaderGen.cpp
include/osgUtil/ShaderGen
examples/osgshadergen/osgshadergen.cpp

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


Re: [osg-users] OSG and shaders

2009-08-05 Thread Hadrien Thomas
Thank you for the links. I have already read them and found nothing useful at 
this stage.

As every link I've read...

The shaders codes are given without the mains, the mains without the shaders, 
the openscenegraph.org tutorials are with osgGL2 (which I can't work with), and 
there is no other tutorial on openscenegraph WITH shaders.

I opened something like 300 links these past three days.
I had to combine 5 of them to get to understand what is a shader, to load it 
and to write:

gl_Position = ftransform();
gl_FragColor = gl_Color;

for .vert and .frag

One more day to know how to send the texture. And now I'm stuck with the 
mapping.

Has anyone a long rope?

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





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


Re: [osg-users] OSG and shaders

2009-08-05 Thread Maxime BOUCHER
Well,

 I'm doing an internship too.

At the beginning I didn't know osg at all, neither shaders.
There are still an extraordinary amount of things I ignore about OSG (my 
advice: when you try to do or understand something, take a look at how it's 
done in OpenGL).
Shaders aren't as hard to use as OSG, I discovered about one month ago and I 
can now write some modests but nice effects.

The essential is to read code and tutorials.
Don't try to go fast, it's the best way to misunderstand what you manipulate 
and to write bad code, failing your internship. You have 6 months, you can 
waste it OR spend 2 months to understand osg and shaders and then writting good 
code, masterizing your internship.

Thus, first read a few osg tutorials (to understand how textures are mapped for 
example, it seems you don't), I think the 4 or 5 firsts should be enough.
After, try to understand what is a shader (I guess you don't really).
Then try to understand the shader tutorials from typhoonlabs, or this 
(http://www.siteduzero.com/tutoriel-3-8879-communiquer-avec-l-application-attributs-et-uniforms.html?bcsi-ac-20A76BC15DBD50F6=194870AE0303lbVE9ryZWUuZzrBgMzY7DS6IPWi9BwMAAMDCRwEQDgAAINVbBwA=),
 it's in french.
I advice to look at osgshader example ONLY to understand (or copy the code) how 
to load and activate a shader, it's 5 lines.

Don't take me for moralistic, I did these errors.

Good luck and take your time, it's the best way to success.

Cheers,
Maxime

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





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


Re: [osg-users] OSG and shaders

2009-08-05 Thread Hadrien Thomas
Thank you very much, I was so desperate  :\

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





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


Re: [osg-users] OSG and shaders

2009-08-05 Thread Paul Speed
And it deserves saying, if you can get your hands on an OpenGL Orange 
Book you'll be that many more steps ahead.  I thought it was really good 
at explaining things in depth while also being easily navigated to drill 
in on target areas.


I had complex shaders up and running in a few days with that book... I 
have had some embedded-style coding experience before, though.


-Paul

Maxime BOUCHER wrote:

Well,

 I'm doing an internship too.

At the beginning I didn't know osg at all, neither shaders.
There are still an extraordinary amount of things I ignore about OSG (my 
advice: when you try to do or understand something, take a look at how it's 
done in OpenGL).
Shaders aren't as hard to use as OSG, I discovered about one month ago and I 
can now write some modests but nice effects.

The essential is to read code and tutorials.
Don't try to go fast, it's the best way to misunderstand what you manipulate 
and to write bad code, failing your internship. You have 6 months, you can 
waste it OR spend 2 months to understand osg and shaders and then writting good 
code, masterizing your internship.

Thus, first read a few osg tutorials (to understand how textures are mapped for 
example, it seems you don't), I think the 4 or 5 firsts should be enough.
After, try to understand what is a shader (I guess you don't really).
Then try to understand the shader tutorials from typhoonlabs, or this 
(http://www.siteduzero.com/tutoriel-3-8879-communiquer-avec-l-application-attributs-et-uniforms.html?bcsi-ac-20A76BC15DBD50F6=194870AE0303lbVE9ryZWUuZzrBgMzY7DS6IPWi9BwMAAMDCRwEQDgAAINVbBwA=),
 it's in french.
I advice to look at osgshader example ONLY to understand (or copy the code) how 
to load and activate a shader, it's 5 lines.

Don't take me for moralistic, I did these errors.

Good luck and take your time, it's the best way to success.

Cheers,
Maxime

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





___
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] OSG and shaders

2009-08-04 Thread Hadrien Thomas
Hi,


I found this tutorial which was very convenient:

http://www.openscenegraph.org/documentation/NPSTutorials/osgGL2ShaderIntro.htm

But the problem was the path of my shader files.

Now I have solved that, it compiles but there is still a problem remaining:


Code:
VERTEX glCompileShader  FAILED
VERTEX Shader  infolog:
0(3) : error C1008: undefined variable glPosition
0(3) : error C1008: undefined variable glProjectionMatrix
0(3) : error C1008: undefined variable glModelViewMatrix
0(3) : error C1008: undefined variable glVertex

glLinkProgram  FAILED
Program  infolog:
Vertex info
---
0(3) : error C1008: undefined variable glPosition
0(3) : error C1008: undefined variable glProjectionMatrix
0(3) : error C1008: undefined variable glModelViewMatrix
0(3) : error C1008: undefined variable glVertex




I give you my new code:



Code:

#include osgViewer/Viewer
#include osgViewer/ViewerEventHandlers
#include osgGA/StateSetManipulator
#include osgDB/ReadFile
#include osg/Uniform
#include osg/Geode
#include osg/Node
#include osg/Group
#include osg/Vec3
#include osg/Vec4
#include osg/ShapeDrawable
#include osg/Shader
#include osg/Program
#include osg/ref_ptr

int main(int ac, char **av)
{
osg::Vec4 red(1.0, 0.0, 0.0, 1.0);
osg::setNotifyLevel(osg::NOTICE);

// Viewer init
osgViewer::Viewer viewer;

viewer.addEventHandler(new 
osgGA::StateSetManipulator(viewer.getCamera()-getOrCreateStateSet()));
viewer.addEventHandler(new osgViewer::StatsHandler());
//viewer.addEventHandler(new osgViewer::ThreadingHandler);
viewer.addEventHandler(new osgViewer::WindowSizeHandler);
viewer.setUpViewInWindow(100, 100, 800, 600);

//root
osg::Group* rootNode = new osg::Group();

//objet de la scene
osg::Geode* MaGeode = new osg::Geode();
rootNode-addChild(MaGeode);
// Sphere
osg::ShapeDrawable* sd = new osg::ShapeDrawable;
osg::Sphere* mySphere = new osg::Sphere(osg::Vec3(0.0f, 0.0f, 0.0f), 
1.5f);
sd-setShape(mySphere);
sd-setColor(red);
MaGeode-addDrawable(sd);

//code to load and apply basic shader

osg::StateSet* rootState = rootNode-getOrCreateStateSet();
osg::ref_ptrosg::Program defaultProgramObject = new osg::Program;

//Read and attach the FRAGMENT shader
osg::Shader* shaderFrag = osgDB::readShaderFile(osg::Shader::FRAGMENT, 
C:\\hadrien\\point.frag);

if (shaderFrag == NULL)
{
   osg::notify(osg::NOTICE)  Effect(frag) Not Supported !  std::endl;
   return -1;
}
defaultProgramObject-addShader(shaderFrag);

//Read and attach the VERTEX shader
osg::Shader* shaderVert = osgDB::readShaderFile(osg::Shader::VERTEX, 
C:\\hadrien\\vertshader.vert);

if (shaderVert == NULL)
{
   osg::notify(osg::NOTICE)  Effect(vert) Not Supported !  std::endl;
   return -1;
}
defaultProgramObject-addShader(shaderVert);


//rootState-addUniform( new osg::Uniform( x, 50 ));
//rootState-addUniform( new osg::Uniform( y, 50 ));
//widgetState-addUniform(new osg::Uniform(drawWidth, 1));
//widgetState-addUniform(new osg::Uniform(drawColor, 
osg::Vec4(255,0,0,255)));

rootState-setAttributeAndModes(defaultProgramObject, 
osg::StateAttribute::ON);

viewer.setSceneData(rootNode);
viewer.run();

return (0);
}




vertshader.vert file:


Code:
void main ( )
{
glPosition=glProjectionMatrix*glModelViewMatrix*glVertex ;
}



point.frag file:


Code:
#version 110

uniform vec4 drawColor;
uniform int drawWidth;
uniform int x;
uniform int y;

void main(void)
{
gl_FragColor = gl_Color;
gl_FragColor.w = 1.0;
if (x = int(gl_FragCoord.x)-drawWidth  x = 
int(gl_FragCoord.x)+drawWidth  
y = int(gl_FragCoord.y)-drawWidth  y = 
int(gl_FragCoord.y)+drawWidth)
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
}



Is there something missing?

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





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


Re: [osg-users] OSG and shaders

2009-08-04 Thread Kim Bale
Hi Hadrien

0(3) : error C1008: undefined variable glPosition
0(3) : error C1008: undefined variable glProjectionMatrix
0(3) : error C1008: undefined variable glModelViewMatrix
0(3) : error C1008: undefined variable glVertex

GLSL functions all have the prefix gl_ not gl. i.e. glPosition should
be gl_Position.

Kim.



2009/8/4 Hadrien Thomas thomas.hadr...@gmail.com:
 Hi,


 I found this tutorial which was very convenient:

 http://www.openscenegraph.org/documentation/NPSTutorials/osgGL2ShaderIntro.htm

 But the problem was the path of my shader files.

 Now I have solved that, it compiles but there is still a problem remaining:


 Code:
 VERTEX glCompileShader  FAILED
 VERTEX Shader  infolog:
 0(3) : error C1008: undefined variable glPosition
 0(3) : error C1008: undefined variable glProjectionMatrix
 0(3) : error C1008: undefined variable glModelViewMatrix
 0(3) : error C1008: undefined variable glVertex

 glLinkProgram  FAILED
 Program  infolog:
 Vertex info
 ---
 0(3) : error C1008: undefined variable glPosition
 0(3) : error C1008: undefined variable glProjectionMatrix
 0(3) : error C1008: undefined variable glModelViewMatrix
 0(3) : error C1008: undefined variable glVertex




 I give you my new code:



 Code:

 #include osgViewer/Viewer
 #include osgViewer/ViewerEventHandlers
 #include osgGA/StateSetManipulator
 #include osgDB/ReadFile
 #include osg/Uniform
 #include osg/Geode
 #include osg/Node
 #include osg/Group
 #include osg/Vec3
 #include osg/Vec4
 #include osg/ShapeDrawable
 #include osg/Shader
 #include osg/Program
 #include osg/ref_ptr

 int     main(int ac, char **av)
 {
        osg::Vec4 red(1.0, 0.0, 0.0, 1.0);
        osg::setNotifyLevel(osg::NOTICE);

        // Viewer init
        osgViewer::Viewer viewer;

        viewer.addEventHandler(new 
 osgGA::StateSetManipulator(viewer.getCamera()-getOrCreateStateSet()));
    viewer.addEventHandler(new osgViewer::StatsHandler());
        //viewer.addEventHandler(new osgViewer::ThreadingHandler);
    viewer.addEventHandler(new osgViewer::WindowSizeHandler);
        viewer.setUpViewInWindow(100, 100, 800, 600);

        //root
        osg::Group* rootNode = new osg::Group();

        //objet de la scene
        osg::Geode* MaGeode = new osg::Geode();
        rootNode-addChild(MaGeode);
        // Sphere
        osg::ShapeDrawable* sd = new osg::ShapeDrawable;
        osg::Sphere* mySphere = new osg::Sphere(osg::Vec3(0.0f, 0.0f, 0.0f), 
 1.5f);
        sd-setShape(mySphere);
        sd-setColor(red);
        MaGeode-addDrawable(sd);

        //code to load and apply basic shader

        osg::StateSet* rootState = rootNode-getOrCreateStateSet();
    osg::ref_ptrosg::Program defaultProgramObject = new osg::Program;

        //Read and attach the FRAGMENT shader
    osg::Shader* shaderFrag = osgDB::readShaderFile(osg::Shader::FRAGMENT, 
 C:\\hadrien\\point.frag);

    if (shaderFrag == NULL)
    {
       osg::notify(osg::NOTICE)  Effect(frag) Not Supported !  std::endl;
       return -1;
    }
        defaultProgramObject-addShader(shaderFrag);

        //Read and attach the VERTEX shader
    osg::Shader* shaderVert = osgDB::readShaderFile(osg::Shader::VERTEX, 
 C:\\hadrien\\vertshader.vert);

    if (shaderVert == NULL)
    {
       osg::notify(osg::NOTICE)  Effect(vert) Not Supported !  std::endl;
       return -1;
    }
        defaultProgramObject-addShader(shaderVert);


        //rootState-addUniform( new osg::Uniform( x, 50 ));
        //rootState-addUniform( new osg::Uniform( y, 50 ));
        //widgetState-addUniform(new osg::Uniform(drawWidth, 1));
    //widgetState-addUniform(new osg::Uniform(drawColor, 
 osg::Vec4(255,0,0,255)));

        rootState-setAttributeAndModes(defaultProgramObject, 
 osg::StateAttribute::ON);

        viewer.setSceneData(rootNode);
        viewer.run();

        return (0);
 }




 vertshader.vert file:


 Code:
 void main ( )
 {
 glPosition=glProjectionMatrix*glModelViewMatrix*glVertex ;
 }



 point.frag file:


 Code:
 #version 110

 uniform vec4 drawColor;
 uniform int drawWidth;
 uniform int x;
 uniform int y;

 void main(void)
 {
        gl_FragColor = gl_Color;
        gl_FragColor.w = 1.0;
        if (x = int(gl_FragCoord.x)-drawWidth  x = 
 int(gl_FragCoord.x)+drawWidth 
                y = int(gl_FragCoord.y)-drawWidth  y = 
 int(gl_FragCoord.y)+drawWidth)
        {
                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
        }
 }



 Is there something missing?

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





 ___
 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] OSG and shaders

2009-08-04 Thread Hadrien Thomas
Thank you very much!
I think I copied an error... what a big mistake :P

That works! I can finally begin to see the effects of shaders! Fantastic! :P

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





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


Re: [osg-users] OSG and shaders

2009-08-04 Thread Hadrien Thomas
Good afternoon,

It's me again ^^

I tried some available shaders and i'm afraid that i don't understand at all 
how it works.

It blows away all the textures and the lighting. Am I supposed to put them in 
the shaders?

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





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



Re: [osg-users] OSG and shaders

2009-08-04 Thread Kim Bale
If you add a shader to an object it removes all of the effects of
OpenGL's fixed pipeline rendering. As a result if you want any of that
fixed pipeline rendering back (such as lighting, texture mapping etc.)
you will have to write an equivalent implementation within the shader.

K.


2009/8/4 Hadrien Thomas thomas.hadr...@gmail.com:
 Good afternoon,

 It's me again ^^

 I tried some available shaders and i'm afraid that i don't understand at all 
 how it works.

 It blows away all the textures and the lighting. Am I supposed to put them in 
 the shaders?

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





 ___
 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] OSG and shaders

2009-08-04 Thread Hadrien Thomas
Ok.
It's going to be a lot of work for me I guess :P

Thank you for your help!

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





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


Re: [osg-users] OSG and shaders

2009-08-04 Thread Thrall, Bryan
Hadrien Thomas wrote on Tuesday, August 04, 2009 10:57 AM:

 Ok.
 It's going to be a lot of work for me I guess :P
 
 Thank you for your help!

Perhaps osgUtil::ShaderGenVisitor and the osgshadergen example can help
you out? They were designed to reproduce the fixed functionality
pipeline in shaders.

-- 
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] OSG and shaders

2009-08-03 Thread Hadrien Thomas
Hi!

I just registered to this forum. I hope I am not a kind of intruder or 
something.

I am starting right now a 6 month internship.
I have to build a library of effects with GLSL and OSG.

The problem is that I'm not used to OSG (but I had some courses for 
OpenInventor which has the same system of graphs) at all and worst: I've never 
used shaders before.

What do you recommand me to do?

I don't understand any results of my searchs on openscenegraph.org about 
shaders. The search engine may have some issues, or I don't know how it works.

Perhaps can you enlight me on some tutorials about how to use shaders from A to 
Z (just simple, I'm not begging for a complex thing but just how it works!) or 
where I can find any documentation.

Thank you very much for your help.

Hadrien.

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





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


Re: [osg-users] OSG and shaders

2009-08-03 Thread Martin Großer

Hello Hadrien,

You can find a basic introduction in the OSG Tutorials:

http://www.openscenegraph.org/projects/osg/wiki/Support/Tutorials

Another Tutorials about GLSL-Shaders can you find on the lighthouse website:

http://www.lighthouse3d.com/opengl/glsl/

And the Quickref-Doc of GLSL is very useful.

www.opengl.org/sdk/libs/OpenSceneGraph/glsl_quickref.pdf

Cheers,

Martin

Am 03.08.2009 12:28, schrieb Hadrien Thomas:

Hi!

I just registered to this forum. I hope I am not a kind of intruder or 
something.

I am starting right now a 6 month internship.
I have to build a library of effects with GLSL and OSG.

The problem is that I'm not used to OSG (but I had some courses for 
OpenInventor which has the same system of graphs) at all and worst: I've never 
used shaders before.

What do you recommand me to do?

I don't understand any results of my searchs on openscenegraph.org about 
shaders. The search engine may have some issues, or I don't know how it works.

Perhaps can you enlight me on some tutorials about how to use shaders from A to 
Z (just simple, I'm not begging for a complex thing but just how it works!) or 
where I can find any documentation.

Thank you very much for your help.

Hadrien.

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





___
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] OSG and shaders

2009-08-03 Thread Simon Hammett
http://www.typhoonlabs.com/

Download chapters 1 through 5 and ShaderDesigner.

Very very handy.

There's also the orange book: (though I've not read it myself)

http://www.amazon.com/OpenGL-Shading-Language-Randi-Rost/dp/0321637631

2009/8/3 Hadrien Thomas thomas.hadr...@gmail.com:
 Hi!

 I just registered to this forum. I hope I am not a kind of intruder or 
 something.

 I am starting right now a 6 month internship.
 I have to build a library of effects with GLSL and OSG.

 The problem is that I'm not used to OSG (but I had some courses for 
 OpenInventor which has the same system of graphs) at all and worst: I've 
 never used shaders before.

 What do you recommand me to do?

 I don't understand any results of my searchs on openscenegraph.org about 
 shaders. The search engine may have some issues, or I don't know how it works.

 Perhaps can you enlight me on some tutorials about how to use shaders from A 
 to Z (just simple, I'm not begging for a complex thing but just how it 
 works!) or where I can find any documentation.

 Thank you very much for your help.

 Hadrien.

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





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




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


Re: [osg-users] OSG and shaders

2009-08-03 Thread Hadrien Thomas
Thank you very much. I'll visit your links this afternoon!

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





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


Re: [osg-users] OSG and shaders

2009-08-03 Thread Maxime BOUCHER

Simon Hammett wrote:
 http://www.typhoonlabs.com/
 
 Download chapters 1 through 5 and ShaderDesigner.
 
 Very very handy.
 
 There's also the orange book: (though I've not read it myself)
 
 http://www.amazon.com/OpenGL-Shading-Language-Randi-Rost/dp/0321637631
 
 


That's exactly what I've done, these tutorials are really good.
From the osg's shaders' example, I would say the most important is learning 
how to set the shaders in the scene graph.

Have fun!


Max

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





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


Re: [osg-users] OSG and shaders

2009-08-03 Thread Hadrien Thomas
Good evening ^^

I tried to paste some code from a co-worker but it doesnt seem to work and I 
dont know why:

Main.cpp:

Code:

#include osgViewer/Viewer
#include osgViewer/ViewerEventHandlers
#include osgGA/StateSetManipulator
#include osgDB/ReadFile
#include osg/Uniform
#include osg/Geode
#include osg/Node
#include osg/Group
#include osg/Vec3
#include osg/Vec4
#include osg/ShapeDrawable
#include osg/Shader
#include osg/Program
#include osg/ref_ptr
#include iostream

int main(int ac, char **av)
{
osg::Vec4 red(1.0, 0.0, 0.0, 1.0);
osg::setNotifyLevel(osg::NOTICE);

// Viewer init
osgViewer::Viewer viewer;

viewer.addEventHandler(new 
osgGA::StateSetManipulator(viewer.getCamera()-getOrCreateStateSet()));
viewer.addEventHandler(new osgViewer::StatsHandler());
//viewer.addEventHandler(new osgViewer::ThreadingHandler);
viewer.addEventHandler(new osgViewer::WindowSizeHandler);
viewer.setUpViewInWindow(100, 100, 800, 600);

//root
osg::Group* root = NULL;
root = new osg::Group();

//objet de la scene
osg::Geode* MaGeode=new osg::Geode();

// Sphere
osg::ShapeDrawable* sd = new osg::ShapeDrawable;
osg::Sphere* sphere = new osg::Sphere(osg::Vec3(0.0f, 0.0f, 0.0f), 
1.5f);
sd-setShape(sphere);
sd-setColor(red);
MaGeode-addDrawable(sd);

//code to load and apply basic shader

osg::StateSet* widgetState = MaGeode-getOrCreateStateSet();
osg::ref_ptrosg::Program pgm = new osg::Program;

//Read the shader
osg::Shader* magnifierFrag = osgDB::readShaderFile(osg::Shader::FRAGMENT, 
point.frag);

if (magnifierFrag == NULL)
{
   osg::notify(osg::NOTICE)  Effect Not Supported !  std::endl;
   return 0;
}
pgm-addShader(magnifierFrag);
widgetState-addUniform( new osg::Uniform( x, 50 ));
widgetState-addUniform( new osg::Uniform( y, 50 ));
widgetState-addUniform(new osg::Uniform(drawWidth, 1));
widgetState-addUniform(new osg::Uniform(drawColor, 
osg::Vec4(255,0,0,255)));
widgetState-setAttributeAndModes(pgm, osg::StateAttribute::ON );
root-addChild(MaGeode);
viewer.setSceneData(root);
viewer.run();

return (0);
}



I thought it was the includes but I have included everything.

The program runs without the part on the shaders.
I have my red Sphere.

But as soon as i input the shader part, i have the error Effect Not Supported 
!

Here is the shader:


Code:
#version 110

uniform vec4 drawColor;
uniform int drawWidth;
uniform int x;
uniform int y;

void main(void)
{
gl_FragColor = gl_Color;
gl_FragColor.w = 1.0;
if (x = int(gl_FragCoord.x)-drawWidth  x = 
int(gl_FragCoord.x)+drawWidth  
y = int(gl_FragCoord.y)-drawWidth  y = 
int(gl_FragCoord.y)+drawWidth)
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
}




Sorry if my mistake is so obvious, but it's out of my range for the moment.
Thank you if you can help!

I'll come back tomorrow.

Have a nice evening!

Ps: I just noticed that i dont know what are: drawWidth and drawColor. But if 
it's not the main problem, can you tell me?

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





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


Re: [osg-users] OSG and shaders

2009-08-03 Thread Simon Hammett

 Ps: I just noticed that i dont know what are: drawWidth and drawColor. But if 
 it's not the main problem, can you tell me?


You're missing a vertex shader. Your program isn't linking.

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