[osg-users] OT: R3D/PRO-1000 knowledge

2016-10-31 Thread Chris Hanson
  This is off-topic, but this is the place with the highest-likelihood of
having someone with the knowledge in question.


  Anyone here ever work with a 90s vintage Lockheed-Martin R3D/PRO-1000?
Some guys working on emulators for it for running legacy code have some
questions about its behaviour and characteristics.

  Drop me a ping if you or anyone you know ever used this hardware.

-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com
http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 •
GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Code Forensics • Digital Imaging • GIS • GPS •
osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile •
iPhone/iPad/iOS • Android
@alphapixel  facebook.com/alphapixel (775)
623-PIXL [7495]
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Embed in SFML window, rendering problem

2016-10-31 Thread Cem Aydin
Hello

Thanks for your reply.

The OpenMW example though is a bit complex for my current knowledge level and I 
really want to keep things simple for now.

However I found another example using SFML that is actually rendering fine.
en. sfml-dev. org/forums/index.php?topic=20866.0 (can't post link)

Ok, based on this example I just figured that replacing the sfml window call by:

Code:

sf::Window window(sf::VideoMode(800, 600),
  "FOOBAR",
  sf::Style::Default,
  sf::ContextSettings(24));
//window.create(sf::VideoMode(800, 600), "My window");



fixes the rendering issue. I guess it might be sf::Style::Default.

Thanks anyway![/code]

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





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


Re: [osg-users] Embed in SFML window, rendering problem

2016-10-31 Thread Nickolai Medvedev
Hi, rebootl.

I think, you need create SFML graphic context, then set he to camera.

I advise you to make normal support of a SFML window, like a SDL-window in 
OpenMW.

https://github.com/OpenMW/openmw/blob/master/components/sdlutil/sdlgraphicswindow.hpp
https://github.com/OpenMW/openmw/blob/master/components/sdlutil/sdlgraphicswindow.cpp

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





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


[osg-users] Embed in SFML window, rendering problem

2016-10-31 Thread Cem Aydin
Hello

I'm trying to embed osg in an SFML window. I found some examples and managed to 
include an osgViewer. However there is a problem with the rendering. I'm not 
sure what exactly is happening but it looks like if the normals get messed up 
or so, see the attached image.

According to examples and posts I found it should work. Also since ATM I'm not 
rendering anything with SFML. I also found this post indicating some problems, 
but since I'm a beginner I'm not sure if it matters: "Notify OSG when OpenGL 
state gets modified externally (e.g. by SFML)" (can't post links)
Also I don't have the push/popGLStates..

Here's my test code:


Code:
// compile e.g.:
// g++ sfml-test.cpp -o sfml-test -lsfml-window -lsfml-graphics -lsfml-system 
-losg -losgViewer -losgDB -losgGA

#include 

// SFML
#include 
//#include 

// OpenSceneGraph
#include 
//#include 

#include 
#include 
//#include 
#include 

using namespace std;

int main() {

// SFML Window

sf::Window window;
window.create(sf::VideoMode(800, 600), "My window");
window.setVerticalSyncEnabled(true);

sf::Vector2u size = window.getSize();

// OSG

// load model from file
osg::ref_ptr model (osgDB::readNodeFile("cessna.osgt"));
if (!model) {
cout << "3D model not found, leaving..." << endl;
return 1;
}

// create model position-attitude transformer
osg::ref_ptr model_pat (new 
osg::PositionAttitudeTransform);

// add the object geode as a child of the object PAT
model_pat->addChild(model.get());

// set up scene graph
//
// root --> model_pat --> model
//

// creating the root node
osg::ref_ptr root (new osg::Group);

root->addChild(model_pat.get());

//Creating the viewer
osgViewer::Viewer viewer;

osg::ref_ptr gw = 
viewer.setUpViewerAsEmbeddedInWindow(0, 0, size.x, size.y);

// set scene to render and run
viewer.setSceneData(root.get());

// attach a trackball manipulator to all user control of the view
// (needed when loop is used below)
//osgGA::OrbitManipulator* om = new osgGA::OrbitManipulator;
osgGA::TrackballManipulator* om = new osgGA::TrackballManipulator;
viewer.setCameraManipulator(om);
viewer.getCameraManipulator()->setHomePosition( osg::Vec3d(30,-50,30),  
// eye
osg::Vec3d(0,0,0),  
// center
osg::Vec3d(0,0,1)   
// up
);
viewer.home();

// instead of returning, use loop now
viewer.realize();

/*auto state = gw->getState();
state->setUseModelViewAndProjectionUniforms(true);
state->setUseVertexAttributeAliasing(true);*/

// GAME LOOP

while (window.isOpen()) {

// --> read input
sf::Event event;
while (window.pollEvent(event)) {
switch(event.type) {
case sf::Event::Closed:
window.close();
break;
case sf::Event::KeyPressed:
if (event.key.code == sf::Keyboard::Escape) {
window.close();
}
break;
case sf::Event::Resized:
gw->resized(0, 0, event.size.width, event.size.height);
break;
}
}


window.setActive();
//window.pushGLStates();
// OSG Viewer step
viewer.frame();
//window.popGLStates();
window.display();

}
return 0;
}




Any ideas ?
Thanks!

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




Attachments: 
http://forum.openscenegraph.org//files/screen_osg_150.jpg


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


Re: [osg-users] passing uniforms to compute shader

2016-10-31 Thread Mary-Ann Zorra
Hi,

ok, maybe it is easier in that way.

Here are the uniforms of the compute shader:

Code:

struct PointLight {
vec4 position;
vec4 color;
vec4 paddingAndRadius;
};

// Shader storage buffer objects
layout(std140) uniform LightBuffer {
PointLight data[1024];
} ;
layout (binding = 0, r32f) writeonly uniform  image2D targetTex;

// Uniforms
uniform sampler2D depthMap;
uniform vec2 screenSize;
uniform int lightCount;
uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;

// Shared values between all the threads in the group
shared uint minDepthInt;
shared uint maxDepthInt;
shared uint visibleLightCount;
shared vec4 frustumPlanes[6];
shared mat4 viewProjection;

#define TILE_SIZE 1
layout(local_size_x = TILE_SIZE, local_size_y = TILE_SIZE, local_size_z = 1) in;



And the uniforms of the fragment shader:

Code:


struct PointLight {
vec4 position;
vec4 color;
vec4 paddingAndRadius;
};

// Shader storage buffer objects
layout(std140) uniform LightBuffer{
PointLight data[1024];
} ;

uniform sampler2D VisibleLightIndicesBuffer;
uniform int numberOfTilesX;
uniform int totalLightCount;



And how I bind them to the compute shader: 

Code:

computeShaderStateset->addUniform(new osg::Uniform("depthMap",2));
computeShaderStateset->setTextureAttributeAndModes(2,depthTexture, 
osg::StateAttribute::ON);
computeShaderStateset->addUniform(new osg::Uniform("screenSize", 
osg::Vec2(windowWidth, windowHeight)));
computeShaderStateset->addUniform(new osg::Uniform("lightCount", (int) 
lights->size()));
computeShaderStateset->getOrCreateUniform("projectionMatrix", 
osg::Uniform::FLOAT_MAT4)->set(projectionMatrix);
computeShaderStateset->getOrCreateUniform("viewMatrix", 
osg::Uniform::FLOAT_MAT4)->set(viewMatrix);

//indices
osg::ref_ptr indexTexture = new osg::Texture2D;
indexTexture->setTextureSize(1024, 1024);
indexTexture->setFilter(osg::Texture::MIN_FILTER, osg::Texture2D::LINEAR);
indexTexture->setFilter(osg::Texture::MAG_FILTER, osg::Texture2D::LINEAR);
indexTexture->setInternalFormat(GL_R32F);
indexTexture->setSourceFormat(GL_RED);
indexTexture->setSourceType(GL_FLOAT);
indexTexture->bindToImageUnit(0, osg::Texture::WRITE_ONLY);
computeShaderStateset->addUniform(new osg::Uniform("targetTex", (int)0));
computeShaderStateset->setTextureAttributeAndModes(0, indexTexture.get());

//lights
std::vector byteLights = convertLightVector(lights);
osg::ByteArray* bytes = new osg::ByteArray([0], 
[sizeof(byteLights) * sizeof(char) * byteLights.size()]);
osg::UniformBufferObject* uboLights = new osg::UniformBufferObject;
uboLights->setUsage(GL_STATIC_DRAW);
uboLights->setDataVariance(osg::Object::STATIC);
bytes->setBufferObject(uboLights);
osg::UniformBufferBinding* ubbLights = new osg::UniformBufferBinding(10, 
uboLights, 0, bytes->size());
computeShaderStateset->setAttributeAndModes(ubbLights, 
osg::StateAttribute::ON);
computeShaderProgram->addBindUniformBlock("LightBuffer", 10);



And to the fragment shader:


Code:
 //Uniforms
mStateset->addUniform(new osg::Uniform("numberOfTilesX", (int) 
((windowWidth + (windowWidth % 16)) / 16) ));
mStateset->addUniform(new osg::Uniform("totalLightCount", (int) 
lights->size()));
//indices
mStateset->addUniform(new osg::Uniform("VisibleLightIndicesBuffer",1));
mStateset->setTextureAttributeAndModes(1,indices, osg::StateAttribute::ON | 
osg::StateAttribute::OVERRIDE);

 //lights
std::vector byteLights = convertLightVector(lights);
osg::ByteArray* bytes = new osg::ByteArray([0], 
[sizeof(byteLights) * sizeof(char) * byteLights.size()]);
osg::UniformBufferObject* uboLights = new osg::UniformBufferObject;
uboLights->setUsage(GL_STATIC_DRAW);
uboLights->setDataVariance(osg::Object::STATIC);
bytes->setBufferObject(uboLights);
osg::UniformBufferBinding* ubbLights = new osg::UniformBufferBinding(0, 
uboLights, 0, bytes->size());
mStateset->setAttributeAndModes(ubbLights, osg::StateAttribute::ON);
lightShader->addBindUniformBlock("LightBuffer", 0);



The part how I pass the lights is the same, but in the case of compute shader 
nothing happens, no light arrives. All uniforms have a reasonable value in the 
fragment shader, but they are always 0 (or empty), except the image2D targetTex 
object,  in the compute shader. I checked all variables in the code, and I 
know, that their value is ok, so the mistake is surely in binding, but I don't 
know where.

Thank you for any help!

Cheers,
Mary-Ann

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





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