POV-Ray : Newsgroups : povray.unofficial.patches : Mesh2 uv_vectors problem : Re: Mesh2 uv_vectors problem Server Time
2 Sep 2024 00:14:10 EDT (-0400)
  Re: Mesh2 uv_vectors problem  
From: Nicolas Calimet
Date: 16 Jan 2001 11:11:10
Message: <3A64841C.D5456350@free.fr>
Hmmm, I think there are misunderstanding somewhere.
	Okay, let's try to give a summary:


1) At first a reminder (for Rune):

#declare Tex = texture {pigment {color rgb 1} translate x}
mesh {triangle {x, y, z texture {Tex}}}

this is of course valid as you said, and

#declare Tex = texture {pigment {color rgb 1}}
mesh {triangle {x, y, z texture {Tex translate x}}}

is not valid because the texture wants only the 'Tex' identifier when
defined in meshes. POV docs say that only an identifier is allowed due
to optimisation purposes (I didn't check the exact words).


2) General case:

#declare t = texture{... tranform{...}}

mesh{
  triangle{...}              // No texture explicitely defined.
  triangle{...}
  triangle{... texture{t} }  // Will copy the texture from 't'.
                             // Only an identifier is allowed, not
                             // anything else like 'transform'.
  triangle{...}
  triangle{...}
  ...
  texture{...}               // Anything allowed in this global texture.
                             // If not defined, you get a 'no pigment
                             // given' for your mesh; say it's black:
                             // the 2 last triangle will be black too.
}

Here the global texture is affecting all but the third triangle
which carries its own texture. This global texture acts like a
reference but is actually not promoted to each triangle. Those
triangles have no texture at all, only the mesh object has one
and this is the one you see. The third triangle has its own texture
which supersedes the global one of the mesh. This is a copy of the
texture data contained in the variable t, this is not a pointer to t.
So the following exemple will work.


3) What you can do to save memory:

// Don't declare here thousands of textures, even in an array,
// because it would require "lots" of memory for almost nothing.
// Maybe the mesh parsing is then a little bit longer.

mesh{
  #declare Tex = texture{ whatever translate x }
  triangle{... texture{Tex}}  // Copy of Tex is used.
  // now we overwrite Tex
  #declare Tex = texture{ whatever2 rotate z }
  triangle{... texture{Tex}}  // Another copy of the new Tex;
                              // the triangles have different textures.
  triangle{...}               // No texture.
  triangle{...}               // No texture.
  texture{...}                // Global texture that will affect the
                              // two last triangle (but no copied nor
                              // referenced).
}

The general form for the required memory is then:
o  n + m triangles (explicitly textured + not textured)
o  1 global texture for the whole mesh

and
o  n + 1 textures (triangles + Tex variable)

while with declared textures outside the mesh, you would have
o  2n textures (#declare'd variables + copies for the triangles)

hence twice the memory required for the explicitely textured triangles.
Believe me, it's BAD for hundreds of thousands of triangles.


4) The last point is related to mesh2 in MegaPOV 0.6a for now:

When you copy a mesh2 object, you also copy every textures carried by
individual triangles. So if every triangle has its own texture, as this
is the case with UV vectors maps, you do have huge memory requirements;
mesh2 variable + every of its copies have almost the same size because
of the copied textures (the mesh geometry is almost nothing compared to
the memory used by textures in most cases).


Sorry for this long post, I hope it is clear enough.
Maybe it's even not useful to anybody :_(



*** Nicolas Calimet
*** http://pov4grasp.free.fr


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.