Commit 7c9ad82a authored by Michele Bosi's avatar Michele Bosi

Vivid: improved depth buffer and rendering accuracy

parent ec7b5c45
...@@ -86,8 +86,8 @@ public: ...@@ -86,8 +86,8 @@ public:
mOutlineSlicePlane = new Uniform( "vl_Vivid.outline.slicePlane" ); mOutlineSlicePlane = new Uniform( "vl_Vivid.outline.slicePlane" );
mOutlineSlicePlane->setUniform( vec4( 1, 0, 0, 0 ) ); mOutlineSlicePlane->setUniform( vec4( 1, 0, 0, 0 ) );
#if 0 #if 1
initScene(); initScene2();
#else #else
std::vector<String> files; std::vector<String> files;
files.push_back(MODEL_FILENAME); files.push_back(MODEL_FILENAME);
...@@ -105,7 +105,7 @@ public: ...@@ -105,7 +105,7 @@ public:
} }
void initScene() { void initScene1() {
ref<Effect> fx1 = VividRendering::makeVividEffect(); ref<Effect> fx1 = VividRendering::makeVividEffect();
fx1->shader()->disable(EN_BLEND); fx1->shader()->disable(EN_BLEND);
fx1->shader()->enable(EN_DEPTH_TEST); fx1->shader()->enable(EN_DEPTH_TEST);
...@@ -150,6 +150,31 @@ public: ...@@ -150,6 +150,31 @@ public:
adjustScene(); adjustScene();
} }
void initScene2() {
ref<Effect> fx1 = VividRendering::makeVividEffect();
ref<Effect> fx2 = VividRendering::makeVividEffect();
fx1->shader()->gocUniform( "vl_Vivid.material.diffuse" )->setUniform( vl::vec4(1, 0, 0, .5f) );
fx2->shader()->gocUniform( "vl_Vivid.material.diffuse" )->setUniform( vl::vec4(1, 0, 0, .5f) );
const float size = 5000;
#if 1
ref< Geometry > box1 = makeBox( vl::vec3(0.0f), size, size, size, false );
#else
ref< Geometry > box1 = makeUVSphere( vl::vec3(0.0f), 100, 20, 20 );
#endif
ref< Geometry > box2 = makeBox( vl::vec3(0.0f), size * .8f, size * .8f, size * .8f, false );
box1->computeNormals();
box2->computeNormals();
Actor* a1 = mVividRendering->sceneManager()->tree()->addActor( box1.get(), fx1.get(), NULL );
Actor* a2 = mVividRendering->sceneManager()->tree()->addActor( box2.get(), fx2.get(), NULL );
a1->setEnableMask( vl::Vivid::VividEnableMask );
a2->setEnableMask( vl::Vivid::VividEnableMask );
adjustScene();
}
void adjustScene() { void adjustScene() {
// position the camera to nicely see the objects in the scene // position the camera to nicely see the objects in the scene
trackball()->adjustView( mVividRendering.get(), vec3(0,0,1), vec3(0,1,0), 1.0f ); trackball()->adjustView( mVividRendering.get(), vec3(0,0,1), vec3(0,1,0), 1.0f );
......
...@@ -37,7 +37,7 @@ using namespace vl; ...@@ -37,7 +37,7 @@ using namespace vl;
VividRendering::VividRendering() { VividRendering::VividRendering() {
VL_DEBUG_SET_OBJECT_NAME() VL_DEBUG_SET_OBJECT_NAME()
setNearFarClippingPlanesOptimized( true ); setNearFarClippingPlanesOptimized( false );
mVividRenderer = new VividRenderer( this ); mVividRenderer = new VividRenderer( this );
// mVividRenderer->setFramebuffer( framebuffer ); // set by the render() method. // mVividRenderer->setFramebuffer( framebuffer ); // set by the render() method.
...@@ -49,7 +49,9 @@ VividRendering::VividRendering() { ...@@ -49,7 +49,9 @@ VividRendering::VividRendering() {
mCalibratedCamera = new vl::CalibratedCamera; mCalibratedCamera = new vl::CalibratedCamera;
setCamera( mCalibratedCamera.get() ); setCamera( mCalibratedCamera.get() );
mCalibratedCamera->viewport()->setScissorEnabled( true ); mCalibratedCamera->viewport()->setScissorEnabled( true );
mCalibratedCamera->viewport()->setClearColor( vl::lightgray ); mCalibratedCamera->viewport()->setClearColor( vl::black );
mCalibratedCamera->setNearPlane( 10 );
mCalibratedCamera->setFarPlane( 50000 );
// Settings // Settings
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment