Ok, after alot of digging I found the problem. It seems that none of the new unstructured volume renderers properly support Mesa. My best guess is that it was setting up the scene with mangled-mesa contexts, and then the Volume Rendering was using true OpenGL. Every command probably returned an error (no GL context), but nothing checks it, so it rendering blindly & ignorant of what was going on.
<br><br>After alot of work, I managed to apply the same structure as the other objects to the vtkProjectedTetrahedraMapper successfully. There is now a vtkProjectedTetrahedraMapper that, with the help of the vtkVolumeRenderingFactory, can properly instantiate either a vtkOpenGLProjectedTetrahedraMapper or a vtkMesaProjectedTetrahedraMapper. From the testing I've done here (with the hello-world code shown originally), I've been able to switch between the two pretty easily and get almost identical results. There are a few discrepancies, but since this is a hardware accelerated version it's very susceptible to the fine variations between how Mesa emulates the hardware and various hardware platforms actually work.
<br><br>So, who @Kitware do I need to talk to to get this patch back to mainstream? I plan to file a bug on it, with code attached, tomorrow morning when I return to the office. This is a little larger patch that I usually deal with (4 new files, extensive changes to a few others), so what's the preferred format for a patch this size? I know there's a command with 'cvs diff' to get "patch"-style diffs, which seems the best option, but I always forget it...
<br><br><div><span class="gmail_quote">On 4/3/06, <b class="gmail_sendername">Randall Hand</b> <<a href="mailto:randall.hand@gmail.com">randall.hand@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="direction: ltr;">I've got a dataset in legacy VTK format with several fields, and i'm trying to do a volume rendering of it. I've been having alot of trouble with it, so I finally boiled it down to the following sample:
<br><div style="margin-left: 40px; font-family: courier new,monospace;">
<br>#include <vtkDataSetReader.h><br>#include <vtkDataSetTriangleFilter.h><br>#include <vtkProjectedTetrahedraMapper.h><br>#include <vtkVolumeProperty.h><br>#include <vtkColorTransferFunction.h
>
<br>#include <vtkPiecewiseFunction.h><br>#include <vtkVolume.h><br>#include <vtkRenderWindow.h><br>#include <vtkRenderer.h><br>#include <vtkRenderWindowInteractor.h><br>#include <vtkDataSet.h
><br>#include <vtkPNGWriter.h><br>#include <vtkRenderLargeImage.h><br>#include <vtkWindowToImageFilter.h><br>#include <vtkGraphicsFactory.h><br>#include <vtkImagingFactory.h><br>int main(void) {
<br>#ifdef _USE_MESA_<br> vtkGraphicsFactory *factGraphics = vtkGraphicsFactory::New();<br> factGraphics->SetUseMesaClasses(1);<br> factGraphics->SetOffScreenOnlyMode(1);<br> factGraphics->Delete();<br>
vtkImagingFactory *factImage = vtkImagingFactory::New();<br> factImage->SetUseMesaClasses(1);<br> factImage->Delete();<br><br>#endif<br><br> vtkDataSetReader *in = vtkDataSetReader::New();<br> in->SetFileName("
output.vtk");<br> in->ReadAllFieldsOn();<br> in->ReadAllScalarsOn();<br> in->ReadAllVectorsOn();<br> in->ReadAllTensorsOn();<br> in->ReadAllNormalsOn();<br> in->ReadAllColorScalarsOn();
<br> in->ReadAllTCoordsOn();<br> in->Update();<br><br> vtkDataSetTriangleFilter *tri = vtkDataSetTriangleFilter::New();<br> tri->SetInput(in->GetOutput());<br> tri->Update();<br><br> vtkProjectedTetrahedraMapper *projTet = vtkProjectedTetrahedraMapper::New();
<br> projTet->SetInput(tri->GetOutput());<br> projTet->SelectScalarArray("Function0");<br><br> vtkVolumeProperty *volProp = vtkVolumeProperty::New();<br> volProp->ShadeOff();<br><br> vtkColorTransferFunction *cmap = vtkColorTransferFunction::New();
<br> cmap->AddHSVPoint(0.0, 0.6667,1,1);<br> cmap->AddHSVPoint(0.001, 0.3333,1,1);<br> cmap->AddHSVPoint(0.002, 0.0,1,1);<br><br> vtkPiecewiseFunction *omap = vtkPiecewiseFunction::New();<br> omap->AddPoint(
0.0, 1.0);<br> omap->AddPoint(0.001, 1.0);<br> omap->AddPoint(0.002, 1.0);<br><br> volProp->SetColor(cmap);<br> volProp->SetScalarOpacity(omap);<br><br> vtkVolume *volume = vtkVolume::New();<br>
volume->SetMapper(projTet);<br> volume->SetProperty(volProp);<br><br> vtkRenderWindow *renWin = vtkRenderWindow::New();<br> vtkRenderer *ren1 = vtkRenderer::New();<br><br> renWin->OffScreenRenderingOn();
<br> renWin->AddRenderer(ren1);<br> ren1->AddVolume(volume);<br> renWin->SetSize(800,600);<br><br> renWin->Modified();<br> vtkWindowToImageFilter *w2if = vtkWindowToImageFilter::New();<br> w2if->SetInput(renWin);
<br> //vtkRenderLargeImage *w2if = vtkRenderLargeImage::New();<br> //w2if->SetInput(ren1);<br> //w2if->SetMagnification(1);<br><br> vtkPNGWriter *png = vtkPNGWriter::New();<br> png->SetFileName("
frame.png");<br> png->SetInput(w2if->GetOutput());<br> png->Write();<br><br>}<br><br><br></div>When _USE_MESA_ is disabled, then it momentarily flashes a window on the screen, and the resulting PNG on disk is correct (pretty much). When _USE_MESA_ is enabled, then it takes noticably longer to process and no window appears, but the resulting PNG on disk is a big empty blackness. Any idea what's going on here?
<br></div><div style="direction: ltr;"><span class="sg">-- <br>Randall Hand<br>Visualization Scientist, <br>ERDC-MSRC Vicksburg, MS<br>Homepage: <a href="http://www.yeraze.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://www.yeraze.com</a>
</span></div></blockquote></div><br><br clear="all"><br>-- <br>Randall Hand<br>Visualization Scientist, <br>ERDC-MSRC Vicksburg, MS<br>Homepage: <a href="http://www.yeraze.com">http://www.yeraze.com</a>