Page 1 of 1

exploring 3D textures

Posted: Fri Sep 26, 2014 7:28 pm
by hugox
Hi,


I'm currently developping a simple volume rendering shader based on different tutorial met on the web.
I'm using raycasting method.
It works fine but when i'm trying to zoom to see inside the volume (so basicaly entering the 3D texture) all the volume diseapears!

I've put an infinite bounding box on my cube and the distance field of the camera seems to works because i can explore the inside of my mesh.
I've disabled
cull_hardware none
cull_software none

1) creation of the cube

Code: Select all

createCubeUV(){
    Ogre::ColourValue color(1.0f, 0.75f, 0.5f,0.3);//orange
    _cube = _sceneManager->createManualObject();
    _cube->begin("BaseWhiteNoLighting",Ogre::RenderOperation::OT_TRIANGLE_LIST);
    _cube->colour(color);

    _cube->position(-1,-1,1);
    _cube->normal(0,0,1);
    _cube->textureCoord(0,1);
    _cube->position(1,-1,1);
    _cube->normal(0,0,1);
    _cube->textureCoord(1,1);     //BLUE FACE (gauche ou droite)
    _cube->position(1,1,1);
    _cube->normal(0,0,1);
    _cube->textureCoord(1,0);
    _cube->position(-1,1,1);
    _cube->normal(0,0,1);
    _cube->textureCoord(0,0);
    _cube->quad(0,1,2,3);


    _cube->position(1,-1,-1);
    _cube->normal(0,0,-1);
    _cube->textureCoord(0,1);
    _cube->position(-1,-1,-1);
    _cube->normal(0,0,-1);
    _cube->textureCoord(1,1);
    _cube->position(-1,1,-1);     //premiere red face
    _cube->normal(0,0,-1);
    _cube->textureCoord(1,0);
    _cube->position(1,1,-1);
    _cube->normal(0,0,-1);
    _cube->textureCoord(0,0);
    _cube->quad(4,5,6,7);


    _cube->position(1,-1,1);
    _cube->normal(1,0,0);
    _cube->textureCoord(0,1);
    _cube->position(1,-1,-1);
    _cube->normal(1,0,0);
    _cube->textureCoord(1,1);
    _cube->position(1,1,-1);        //RED FACE 1 et2
    _cube->normal(1,0,0);
    _cube->textureCoord(1,0);
    _cube->position(1,1,1);
    _cube->normal(1,0,0);
    _cube->textureCoord(0,0);
    _cube->quad(8,9,10,11);


    _cube->position(-1,-1,-1);
    _cube->normal(-1,0,0);
    _cube->textureCoord(0,1);
    _cube->position(-1,-1,1);
    _cube->normal(-1,0,0);
    _cube->textureCoord(1,1);
    _cube->position(-1,1,1);
    _cube->normal(-1,0,0);
    _cube->textureCoord(1,0);
    _cube->position(-1,1,-1);
    _cube->normal(-1,0,0);
    _cube->textureCoord(0,0);
    _cube->quad(12,13,14,15);

    _cube->position(-1,1,1);
    _cube->normal(0,1,0);
    _cube->textureCoord(0,1);
    _cube->position(1,1,1);
    _cube->normal(0,1,0);
    _cube->textureCoord(1,1);
    _cube->position(1,1,-1);      //GREEN FACE
    _cube->normal(0,1,0);
    _cube->textureCoord(1,0);
    _cube->position(-1,1,-1);
    _cube->normal(0,1,0);
    _cube->textureCoord(0,0);
    _cube->quad(16,17,18,19);


    _cube->position(-1,-1,-1);
    _cube->normal(0,-1,0);
    _cube->textureCoord(0,1);
    _cube->position(1,-1,-1);
    _cube->normal(0,-1,0);
    _cube->textureCoord(1,1);
    _cube->position(1,-1,1);
    _cube->normal(0,-1,0);
    _cube->textureCoord(1,0);
    _cube->position(-1,-1,1);
    _cube->normal(0,-1,0);
    _cube->textureCoord(0,0);
    _cube->quad(20,21,22,23);
    _cube->end();

     _cube->setBoundingBox(Ogre::AxisAlignedBox::BOX_INFINITE);;
    _cube->convertToMesh(_nameCube);
    _entityCube = _sceneManager->createEntity(_nameEntityCube, _nameCube);
    _volumeNode->attachObject(_entityCube);

and my material

Code: Select all



vertex_program VolumeMapping_VS cg
{
    source directVolumeRendering.cg          
    entry_point main_vp
    profiles vp40
    default_params
    {        		
        param_named_auto eyePosition camera_position_object_space
        param_named_auto worldViewProj worldviewproj_matrix
        param_named_auto cameraPosition inverse_transpose_worldview_matrix
    }
}

fragment_program DVR_post_Phong_PS cg
{
    source directVolumeRendering.cg          
    entry_point directVolumeRendering_postClassification_PhongShading
    profiles fp40
}

material directVolumeRendering_postClassification_NoShading
{
    technique 
    {
        pass 
        {         
	      
            cull_hardware none
            cull_software none  

          
            scene_blend alpha_blend
            vertex_program_ref VolumeMapping_VS
            {
 		
            } 
            fragment_program_ref DVR_post_PS
            {           

               //Les 10 lumieres
                param_named_auto lightPosition[0] light_position_object_space 0
                param_named_auto lightPosition[1] light_position_object_space 1
                param_named_auto lightPosition[2] light_position_object_space 2
                param_named_auto lightPosition[3] light_position_object_space 3
                param_named_auto lightPosition[4] light_position_object_space 4
                param_named_auto lightPosition[5] light_position_object_space 5
                param_named_auto lightPosition[6] light_position_object_space 6
                param_named_auto lightPosition[7] light_position_object_space 7
                param_named_auto lightPosition[8] light_position_object_space 8
                param_named_auto lightPosition[9] light_position_object_space 9

                //le nombre de lumieres
                param_named numLights int 1

                //Les parametres customs
                // map diffuse from custom renderable param 1
                param_named_auto param_LightShader custom 1
                // map diffuse from custom renderable param 2
                param_named_auto param_Contrast custom 2
                // map diffuse from custom renderable param 3
                param_named_auto param_Windowing custom 3
                // map diffuse from custom renderable param 4
                param_named_auto param_Values custom 4
                // map diffuse from custom renderable param 5
                param_named_auto param_VolumeSize custom 5
            
            } 	      
	  
    	    texture_unit 
    	    {    
                  //map 3D texture
            }  
            texture_unit
            {
                  //map 2D texture
            }
        }
    }
}

i can't find where my problem is?

thanks!
regards!