material problem issue

Discussions about LuxRender's materials, and how to make the most of them.

Moderator: coordinators

Re: material problem issue

Postby patro » Mon Sep 13, 2010 4:42 pm

max + lxs.rar
(277.74 KiB) Downloaded 62 times


the attachment contain 2 max files.... both are the same file... difference is... only some geometries are rotated.
the lxs are the exported scene from both files

edited....
when you orbit the camera... you will see always a dark silhouette on the far edges of the chamferbox... if you open the image in photoshop.. you can draw lines and you will notice that black edges describe a +/- perpendicular line to camera.
like I due in the attached image
luxout.png

that's why a say that it must be related to the camera
User avatar
patro
 
Posts: 1801
Joined: Fri Feb 29, 2008 9:06 pm
Location: mount Etna

Re: material problem issue

Postby jeanphi » Tue Sep 14, 2010 1:30 am

Hi patro,

The lxs files you posted are absolutely identical except one has a sun and the other not. However the odd thing is the uv data of the triangle: the values are really huge and that might cause numerical accuracy issues in the shading. Also if you're using a post v0.7 version of LuxRender, the glossiness is so high (exponent around 1e6) that it's probably causing numerical errors.

Jeanphi
jeanphi
Developer
 
Posts: 6624
Joined: Mon Jan 14, 2008 7:21 am

Re: material problem issue

Postby patro » Tue Sep 14, 2010 2:05 am

hi Jeanphi,

you are right about the glossiness value... but with, for example, matte material the issue is less visible... but still present.
I wrote this just in my first topic: the more the material become shiny the more the issue is to see.......
see image: download/file.php?id=10133&t=1
you will notice the issue on all rotated objs, like the pot, the torus and so on.

I use mirror or metal with high exponent just because the issue is high contrasted in render.
with the weekly build is the issue on rotated obj more visible... I mean that the obj are near by completely black.

again thank you, I will check the 2 lxs files.

edit:
I'm not a coder.... but what I notice is related to "rotation" and to "camera"..... you can notice what I mean by looking this image download/file.php?id=10197&mode=view
it's like that the black silhouette is drawn like by following the world horizon..

do you want that I try other attempt and post the lxs? suggestion?

--
patro
User avatar
patro
 
Posts: 1801
Joined: Fri Feb 29, 2008 9:06 pm
Location: mount Etna

Re: material problem issue

Postby patro » Tue Sep 14, 2010 8:06 am

hi Jeanphi,
I have reexported the triangle.
the difference are only in camera view.
I hope you can help!
Attachments
rotated.lxs
(2.5 KiB) Downloaded 19 times
normal.lxs
(2.5 KiB) Downloaded 18 times
User avatar
patro
 
Posts: 1801
Joined: Fri Feb 29, 2008 9:06 pm
Location: mount Etna

Re: material problem issue

Postby jeanphi » Tue Sep 14, 2010 9:17 am

Hi,

Ok, that confirms my guess: the vertices are rotated but not the normals, no wonder you get inconsistent normals and strange shading, but everything looks ok in 3DS. The exporter should either output a transform and keep the geometry unchanged, or it should transform both the vertices and the normals (don't apply translation to the normals though).

Jeanphi
jeanphi
Developer
 
Posts: 6624
Joined: Mon Jan 14, 2008 7:21 am

Re: material problem issue

Postby patro » Tue Sep 14, 2010 9:22 am

jeanphi wrote:Hi,

Ok, that confirms my guess: the vertices are rotated but not the normals, no wonder you get inconsistent normals and strange shading, but everything looks ok in 3DS. The exporter should either output a transform and keep the geometry unchanged, or it should transform both the vertices and the normals (don't apply translation to the normals though).

Jeanphi

these are good news... and new work for Hedphelym :lol:
finally you resolve our problem!
thank you!
--
Patro
User avatar
patro
 
Posts: 1801
Joined: Fri Feb 29, 2008 9:06 pm
Location: mount Etna

Re: material problem issue

Postby hedphelym » Tue Sep 14, 2010 9:29 am

So this means it's a mesh problem? correct?

code for meshes is:
Do any of you see something obvious? (I have not coded \ modified anything in this part of the code before)
and I understand what you say, but I cannot understand exactly what goes wrong.


Code: Select all
int i, c;

   // init
   numfaces = 0;
   isPortal = false;
   isTriMesh = false;

   faces = NULL;
   vertices = NULL;
   verticesIndex = NULL;
   normals = NULL;
   uvs = NULL;

   Object*   obj;
   ObjectState os = p_node->EvalWorldState(0);
   obj = os.obj;

   switch(os.obj->SuperClassID())
   {
   case GEOMOBJECT_CLASS_ID:

      TSTR s_nName(p_node->GetName());

      // Convert the node geometry to a triangle based mesh

      TriObject *p_triobj;

      BOOL fConvertedToTriObject = obj->CanConvertToType(triObjectClassID) && (p_triobj = (TriObject*)obj->ConvertToType(0, triObjectClassID)) != NULL;

      if (!fConvertedToTriObject)
         return;

      Mesh *p_trimesh = &p_triobj->mesh;
      p_trimesh->buildNormals();                           // just make sure we have vertex normals
      int i_faceCount = p_trimesh->getNumFaces();               // Check how many face we have to loop for
      Matrix3 m3_nodeTransform = p_node->GetObjectTM(0);         // Get the node transform at frame 0
      DWORD triIndex = 0;

      if (i_faceCount < 1)
         return;

      isTriMesh = true;

      name = s_nName;
      material = p_node->GetMtl();
      numfaces = i_faceCount;
      numvertices = i_faceCount * 3;
      numnormals = i_faceCount * 3;
      numuvs = i_faceCount * 3;

      faces = new Point3[i_faceCount];
      vertices = new Point3[i_faceCount * 3];
      verticesIndex = new bool[i_faceCount * 3];
      normals = new Point3[i_faceCount * 3];
      uvs = new Point3[i_faceCount * 3];

      isPortal = false;

      if (material)
      {
         if (material->ClassID() == LUXRENDER_PORTALMATERIAL_ID)
            isPortal = true;
      }

      c = 0;

      for (i = 0; i < i_faceCount; i++)
      {
         int vert;
         Point3 v;

         // fill face index
         faces[i] = Point3(c , c + 1, c + 2);
         
         Face* p_face = &p_trimesh->faces[i];
         TVFace*   p_tvface = &p_trimesh->tvFace[i];

         for(vert = 0; vert < 3; vert++)
         {
            int id = (c + vert);

            int i_vertex = p_face->getVert(vert);
            vertices[id] = (p_trimesh->getVert(i_vertex)) * m3_nodeTransform;

            normals[id] = GetVertexNormal(p_trimesh, i, p_trimesh->getRVertPtr(i_vertex));
            normals[id].Normalize();

            if (p_trimesh->numTVerts > 0)
               uvs[id] = p_trimesh->getTVert(p_tvface->getTVert(vert));
         }

         c += 3;
      }

      //OptimizeFaceIndices();
   
   }
User avatar
hedphelym
Developer
 
Posts: 805
Joined: Mon Aug 18, 2008 7:37 am
Location: Kristiansand Norway

Re: material problem issue

Postby patro » Tue Sep 14, 2010 9:34 am

I did a test on the fly....
by replacing the "normal N" value with the one of "float uv"
and it's working no shading problem on the rotated triangle mesh!

I also play in the same way with the chamfercylinder from this scene
download/file.php?id=10130&t=1
and here the resulting render
LuxRender 6 am.png.png
User avatar
patro
 
Posts: 1801
Joined: Fri Feb 29, 2008 9:06 pm
Location: mount Etna

Re: material problem issue

Postby hedphelym » Tue Sep 14, 2010 10:59 am

patro wrote:I did a test on the fly....
by replacing the "normal N" value with the one of "float uv"
and it's working no shading problem on the rotated triangle mesh!

I also play in the same way with the chamfercylinder from this scene
download/file.php?id=10130&t=1
and here the resulting render
LuxRender 6 am.png.png



When I try this in the lxs you posted I get this error all the time:
Code: Select all
[2010-09-14 17:58:15 Error: 43] Number of "N"s for mesh must match "P"s
User avatar
hedphelym
Developer
 
Posts: 805
Joined: Mon Aug 18, 2008 7:37 am
Location: Kristiansand Norway

Re: material problem issue

Postby patro » Tue Sep 14, 2010 11:02 am

right.
but I got this kind of error very often!
User avatar
patro
 
Posts: 1801
Joined: Fri Feb 29, 2008 9:06 pm
Location: mount Etna

PreviousNext

Return to Materials Help

Who is online

Users browsing this forum: No registered users and 1 guest