comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: "Color vectors" & shading
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: "Color vectors" & shading [message #37741] Wed, 21 January 2004 10:41 Go to previous message
Karl Schultz is currently offline  Karl Schultz
Messages: 341
Registered: October 1999
Senior Member
"Neil" <nasalmon@onetel.net.uk> wrote in message
news:74039481.0401210024.11f5b707@posting.google.com...
> "Karl Schultz" <kschultz_no_spam@rsinc.com> wrote in message
news:<100rj8ksoii7b80@corp.supernews.com>...
>> "Neil" <nasalmon@onetel.net.uk> wrote in message
>> news:74039481.0401201339.d26efa4@posting.google.com...
>>> Does anyone know how i correctly implement "color vectors" in
>>> "setProperty" to give each polygon of an object its own predetermined
>>> intensity level or colour? It should be that setting "shading" = 0 in
>>> "setProperty" should make it so that the colour of each polygon is
>>> defined by the "colour vertex" of the first vertex of the polygon
>>> connectivity. However, generally the number of "first vertices" of a
>>> polygon of an object is actually less than the number of polygons.
>>> That means you cant use this method to give each polygon of an object
>>> a predetermined different colour - or have i missed something? It
>>> seems to me that what is really needed is a colour vector for the
>>> polygons not the vertices.
>>
>> There's no way to do this today if you have vertices that are shared
between
>> polygons. There isn't a polygon color vector.
>>
>> What you could do is make a vertex list and a connectivity list that
creates
>> a set of independent polygons and then set the color of all the vertices
>> belonging to each polygon to the same color. Actually, you would only
need
>> to set the first vertex of a polygon to an actual color; the rest are
>> ignored if you are doing flat shading.
>>
>> Obviously, if you have many polygons that used to share vertices, this
will
>> require more space.
>>
>> For example, if you have 4 vertices, A, B, C, D, that form 2 triangles
with
>> a shared edge, the triangles might be ABC, and DCB. If the vertices are
in
>> the vertex list as ABCD, the conn list would be 3 0 1 2 3 3 2 1. To
make
>> them independent triangles, your vertex list would be ABCDCB and the
conn
>> list 3 0 1 2 3 3 4 5. You would set the color of vert A (at 0) to the
>> desired color and the color of vert D (at 3) to the desired color. The
rest
>> of the vertex colors list can be left uninitialized.
>>
>> It isn't very efficient, but would work well if you don't have that many
>> polygons.
>>
>> Karl
>
> Karl,
>
> many thanks for your response.
>
> It's a shame there are no polygon colour vectors. If you think about
> nature and surfaces, it is the surface that has the colour. The vertex
> is just a manmade mathematical entity to descibe the surfaces. I am
> sure it would be the wish of graphics programmes to mimic nature as
> cloesly as possible in the most efficient way.

I suppose. But objects can vary in color across the extents of a single
polygon. It would be cool to be able to specify the color of every pixel on
an object, but that is what texture mapping is all about. So, the next best
thing is to specify the color at each vertex and allow interpolation between
vertices. This is a pretty effective way of handling lighting models. I
guess this is all pretty debatable.

> Is the absence of polygon colour vectors a fundamental limitation of
> IDL?

Yes. It is just a limitation of the IDLgrPolygon object.

> Does OpenGL have this limitation?

No. OpenGL has the concept of "current color" as IDL passes each vertex to
it. IDL would simply set the color of the first vertex before sending the
first vertex to OpenGL, and then not change the color for subsequent
vertices. IDL would just have to fetch the color from the polygon color
list instead of the vertex color list.

> Would there be any plans for
> RSI to introduce an efficient method in IDL to enable each polygon to
> have a predetermined and unique colour/intensity?

I can write a feature request.

The same sort of argument also applies to normals. If you are doing smooth
shading, IDL uses the vertex normals you pass or computes them, based on the
average geometric normal of polygons that use each vertex. If you are doing
flat shading, IDL computes the geometric normal of each polygon and uses
that. So, there is no way to pass in polygon normals directly. You'd have
to do the same expansion trick we have discussed for the polygon colors and
make all the vertex normals the same as the polygon normal you'd like to
have for the polygon.

> I can certainly create an artificial polygon_connectivity for
> unconnected polygons allows each polygon to have a different
> intensity.

Yes, this should work just fine, except for the efficiency issue already
discussed.

Karl
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Extract data from HDF VGroup
Next Topic: Re: again strsplit

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 23:47:08 PDT 2025

Total time taken to generate the page: 0.16363 seconds