RenderKit / ospray

An Open, Scalable, Portable, Ray Tracing Based Rendering Engine for High-Fidelity Visualization
http://ospray.org
Apache License 2.0
1k stars 182 forks source link

Rendering artifact for textured streamline with varied radius #315

Closed JimCR-Lin closed 4 years ago

JimCR-Lin commented 5 years ago

This issue is related to particular vertices. Y is negative number.

I narrow down to 2 vertex (x, y, z, radius): [37407.6 -151282 0 821.25 ; 37340.5 -151306 17656.4 821.25] Here are my codes to produce problem (no fixture):

       ldata = ospNewData(nvert, OSP_FLOAT3A, vertex);
       ospCommit(ldata);
       ospSetData(mLine, "vertex", ldata);
       ospRelease(ldata);
       ldata = ospNewData(nvert, OSP_FLOAT, radius.data());
       ospCommit(ldata);
       ospSetData(mLine, "vertex.radius", ldata);
       ospRelease(ldata);
   float colors[] = {
     1.f, 0.f, 0.f, 1.f,
     1.f, 0.f, 0.f, 1.f,
   };
   ldata = ospNewData(2, OSP_FLOAT4, colors);
   ospCommit(ldata);
   ospSetData(mLine, "vertex.color", ldata);

Hopefully, you can reproduce this bug.

johguenther commented 5 years ago

Hi, using the 4th component of a vec3fa for the radius does not work yet for "streamlines" (it works for "spheres", and we are currently working on making this more general). The radius is taken from the radius array (a std::vector<float> in your code snippet?). If this clarification did not address your issue, can you please say what you expect, and maybe add a screenshot of the artifacts?

Best regards, Johannes

carsonbrownlee commented 5 years ago

johannes, he is setting vertex.radius array explicitly. I tried to replicate his code but with different vertex positions (didn't want to figure out a correct camera). I will try it again with his vertex positions, though I'm not sure why that should matter. Possibly it would affect an epsilon.

carsonbrownlee commented 5 years ago

I put your code snippet in as best as I could figure out into our existing testing suite in tests/sources/ospray_test_geomoetry.cpp under ::getStreamlines(). It seems to run fine, what is the exact issue you are running into with this?

float vertex[] = {
      2.0f, -1.0f, 3.0f, 0.0f, 0.4f, 0.5f, 8.0f, -2.0f, 0.0f, 1.0f, 3.0f, 0.0f};
  float color[] = {
      0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f};
  int index[]   = {0, 1};
  float radii[] = {.1f, .3f, .5f};

  int nvert         = 2;
  OSPGeometry mLine = ospNewGeometry("streamlines");
  OSPData ldata     = ospNewData(nvert, OSP_FLOAT3A, vertex);
  ospCommit(ldata);
  ospSetData(mLine, "vertex", ldata);
  ospRelease(ldata);
  ldata = ospNewData(nvert, OSP_FLOAT, radii);
  ospCommit(ldata);
  ospSetData(mLine, "vertex.radius", ldata);
  ospRelease(ldata);
  ldata = ospNewData(2, OSP_FLOAT4, color);
  ospCommit(ldata);
  ospSetData(mLine, "vertex.color", ldata);
  ospRelease(ldata);
  ospSet1f(mLine, "radius", 0.5f);
  ldata = ospNewData(2, OSP_INT, index);
  EXPECT_TRUE(ldata);
  ospCommit(ldata);
  ospSetData(mLine, "index", ldata);
  ospRelease(ldata);
  ospCommit(mLine);
  return mLine;

this code returns the following image. Note that I did not use your exact vertex positions because I’m not sure what camera setup you were using, and I did not want to throw that into the mix.

carsonbrownlee commented 5 years ago

Screen Shot 2019-04-01 at 2 39 32 PM

JimCR-Lin commented 5 years ago

Rendering like a ghost tube. Capture

JimCR-Lin commented 5 years ago

I guess, it is related to the big negative "Y". Please use the vertices I put in this issue.

carsonbrownlee commented 5 years ago

I see thanks Jim. To be clear, does this still show up without the volume?

JimCR-Lin commented 5 years ago

Yes. I isolated problem to just use that 2 vertices streamline without anything else. Noticed that the radius was the same for these 2 vertices.

johguenther commented 4 years ago

Hi, in OSPRay v2 we considerably changed the implementation of streamlines (now "curve"). I cannot reproduce the issue, below a rendering with the faulty vertices from you ([37407.6 -151282 0; 37340.5 -151306 17656.4] radius 821.25): curve

So, please reopen if the problem still exists.