Re: [osg-users] Rendering a scene to texture

2018-03-19 Thread Jochen Maier
Okay, thank you.

I will study the examples und do some research for RTT in osg :)

Cheers,
Jochen

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





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


Re: [osg-users] Rendering a scene to texture

2018-03-18 Thread Jochen Maier
Thank you very much Robert :)

Okay, I'll take a look at the examples you had talked about.

I know that the way is to realize this is using different cameras and render to 
texture. But I don't know how to initiate the rendering-process; I only know 
this by calling Viewer::frame(). I thought there is another way.

btw:
I was thinking a little bit of this and my idea was:
There are different scene-roots (osg::group). Add all my scene childs to each 
osg::group.
Now I set for the RTT the sceneData which I want to render to texture 
(osgViewer::setSceneData(sceneToRenderToTexture)) and the camera which renders 
to texture and call osgViewer::frame().
Done!! I have a texture wich shows my scene (sceneToRenderToTexture).

Is this an option to solve my problem?

Cheers,
Jochen

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





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


[osg-users] Render a Scene to texture

2018-03-18 Thread Jochen Maier
Hi,

I want to do something like offscreen rendering.
What I want to do exactly:
I have one or more scenes (scene graphs) and one final scene.
The final scene contains a cube which has 6 different textures.
Now I have 6 different scenes (scene graphs).
I want to render all these 6 scenes in 6 textures and use this textures for the 
cube.

My problem is:
How is it possible to render one scene in a texture without render it in a 
seperatly window?

I hope you can understand my problem... because my english isn't very well^^

I've allready checked the compositeview example... but I don't understand it :/

Thank you!

Cheers,
Jochen

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





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


[osg-users] Textuiring a simple quad

2017-10-18 Thread Jochen Maier
Hi, all :)

I have so a simple quastion but I can solve the problem.

I want to draw a quad attach a simple Shader with a simple texture operation.
But I only get a black quad. The shader works when a color each fragmnent with 
the color red, but wen I want to get texture-colors... its only got black.

Some Code:

Code:

osg::Vec2Array* textureCoordinates = new osg::Vec2Array;
osg::Vec3Array* quadVertices = new osg::Vec3Array;
osg::Geometry* quadGeometry = new osg::Geometry();

// *** Vertices ***
quadVertices->push_back(osg::Vec3(x - rad, y - rad, 0.0));
quadVertices->push_back(osg::Vec3(x + rad, y - rad, 0.0));
quadVertices->push_back(osg::Vec3(x + rad, y + rad, 0.0));
quadVertices->push_back(osg::Vec3(x - rad, y + rad, 0.0));

quadGeometry->setVertexArray(quadVertices);
// *** Vertices - Ende ***

// *** Texturkorrdinaten ***
textureCoordinates->push_back(osg::Vec2(0, 0));
textureCoordinates->push_back(osg::Vec2(1, 0));
textureCoordinates->push_back(osg::Vec2(1, 1));
textureCoordinates->push_back(osg::Vec2(0, 1));

quadGeometry->setTexCoordArray(0, textureCoordinates, 
osg::Array::BIND_PER_VERTEX);
// *** Texturkorrdinaten-Ende ***


// *** Faces-Idizes ***
osg::DrawElementsUInt* gridFace = new 
osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
gridFace->push_back(0);
gridFace->push_back(1);
gridFace->push_back(2);
gridFace->push_back(3);

quadGeometry->addPrimitiveSet(gridFace);
// *** Faces-Idizes - Ende ***

//  Logo - Texture 
{
std::string path("Grafik\\");
std::string fileName = path + std::string("Skull.tga");

osg::Image *image = osgDB::readImageFile(fileName);
if (!image)
{
exit;
}

osg::TextureRectangle* texture = new 
osg::TextureRectangle(image);

osg::TexMat* texmat = new osg::TexMat;
texmat->setScaleByTextureRectangleSize(true);

// setup state
osg::StateSet* state = new osg::StateSet();
state->addUniform(new osg::Uniform("skull_Texture", 
SKULL_TEXTURE));
state->setTextureAttributeAndModes(SKULL_TEXTURE, texture, 
osg::StateAttribute::ON);
state->setTextureAttributeAndModes(SKULL_TEXTURE, texmat, 
osg::StateAttribute::ON);

state->setMode(GL_BLEND, osg::StateAttribute::ON);


quadGeometry->setStateSet(state);
}




Here I attech the shader

Code:

// Shader-Logo
{
osg::StateSet* stateSet = quadGeometry->getOrCreateStateSet();

mShaderProgramLogo = new osg::Program;
mShaderProgramLogo->setName("ProgramLogo");
mVertexShaderLogo = new osg::Shader(osg::Shader::VERTEX);
mFragmentShaderLogo = new osg::Shader(osg::Shader::FRAGMENT);

mShaderProgramLogo->addShader(mFragmentShaderLogo);
mShaderProgramLogo->addShader(mVertexShaderLogo);


mVertexShaderLogo->loadShaderSourceFromFile("Shader\\vertLogo.txt");

mFragmentShaderLogo->loadShaderSourceFromFile("Shader\\fragmentLogo.txt");
stateSet->setAttributeAndModes(mShaderProgramLogo, 
osg::StateAttribute::ON);

quadGeometry->setStateSet(stateSet);
}





and here the fragment-shader code:

Code:

#version 330

uniform sampler2D skull_Texture;

varying vec2 textCoord;

void main(void)
{
vec4 colSkull = texture2D(skull_Texture, textCoord);

//gl_FragColor = vec4(1.0,0,0,1.0); // => this works fine
gl_FragColor = colSkull;// => every fragment is black!!!
}




Can anybody help my.
OSG is such a nice library...but why it doesn't work? :(

Thank you!

Cheers,
JoseMan[/code]

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





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