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

Home » Public Forums » archive » Re: iSurface lighting questions
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: iSurface lighting questions [message #44500] Wed, 22 June 2005 09:48 Go to next message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <MPG.1d23403db047fe3f989695@news.frii.com>,
David Fanning <david@dfanning.com> wrote:

> Rick Towler writes:
>
>> Is your monitor upside down?
>>
>> I admit I am not an iTools user but if I create a surface in iTools
>> 2.0.1 the directional light is above the surface and the surface is
>> illuminated from above (as you would expect if the light was above the
>> surface).
>>
>> Maybe that is why all of your text is upside down too?
>>
>> Can you post an example?
>
> I had this problem, too. My damn monitor is a rectangle
> and nowhere did it have a "this side up" label on it. :-(

Except my text is right side up. :-)

Ken
Re: iSurface lighting questions [message #44504 is a reply to message #44500] Wed, 22 June 2005 11:26 Go to previous messageGo to next message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <pan.2005.06.22.17.55.59.969000@rsinc.com>,
Karl Schultz <k____schultz@rsinc.com> wrote:

> On Wed, 22 Jun 2005 09:40:56 -0500, Kenneth Bowman wrote:
>
>> Why does the default lighting for iSurface illuminate the *bottom* of the
>> surface?
>>
>> And if I want to add a light manually to illuminate the top, why do I have
>> to
>> drag it to the *bottom* of the window?
>>
>
> Exactly what command are you using?
>
> What happens if you jsut do something simple like
>
> isurface, dist(40)
>
> Does it look different if you force software rendering?

The problem appears to be that my z-coordinate decreases upward. Here is a
simple example.

x = 10*FINDGEN(37)
y = -90 + 10*FINDGEN(19)
z = REPLICATE(500.0, 37, 19) + 100.0*RANDOMN(seed, 37*19)
ISURFACE, z, x, y, /NO_SAVEPROMPT, $
/SHADING, $
XTITLE = 'Longitude', $
XRANGE = [0.0, 360.0], $
XMAJOR = 5, $
XMINOR = 2, $
YTITLE = 'Latitude', $
YRANGE = [-90.0, 90.0], $
YMAJOR = 7, $
YMINOR = 2, $
ZTITLE = 'Pressure', $
ZRANGE = [1000.0, 0.0], $
ZMAJOR = 6, $
ZMINOR = 1

I would consider this to be a bug, but perhaps it is a feature. :-( The way an
additional light behaves is, at least, unintuitive.

Ken
Re: iSurface lighting questions [message #44505 is a reply to message #44500] Wed, 22 June 2005 10:56 Go to previous messageGo to next message
Karl Schultz is currently offline  Karl Schultz
Messages: 341
Registered: October 1999
Senior Member
On Wed, 22 Jun 2005 09:40:56 -0500, Kenneth Bowman wrote:

> Why does the default lighting for iSurface illuminate the *bottom* of the
> surface?
>
> And if I want to add a light manually to illuminate the top, why do I have to
> drag it to the *bottom* of the window?
>

Exactly what command are you using?

What happens if you jsut do something simple like

isurface, dist(40)

Does it look different if you force software rendering?
Re: iSurface lighting questions [message #44579 is a reply to message #44500] Wed, 22 June 2005 15:26 Go to previous message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <pan.2005.06.22.21.19.08.312000@rsinc.com>,
Karl Schultz <k____schultz@rsinc.com> wrote:

> Another way to attack the problem is to realize that you are flipping your
> scene, effectively, in iSurface and need to move the position of the
> lights to adapt to the change. I'm pretty sure that they are ways to
> locate the visualization objects programmatically. You could find all the
> lights and move them to where you want them.
>
> Karl

Or RSI could add a keyword to let me indicate that I am working in a left-handed
coordinate system. ;-)

I'm right-handed myself, but sometimes we have to accommodate lefties (... a
blatant troll).

Thanks, Ken
Re: iSurface lighting questions [message #44581 is a reply to message #44504] Wed, 22 June 2005 14:19 Go to previous message
Karl Schultz is currently offline  Karl Schultz
Messages: 341
Registered: October 1999
Senior Member
On Wed, 22 Jun 2005 13:26:10 -0500, Kenneth Bowman wrote:

> In article <pan.2005.06.22.17.55.59.969000@rsinc.com>,
> Karl Schultz <k____schultz@rsinc.com> wrote:
>
>> On Wed, 22 Jun 2005 09:40:56 -0500, Kenneth Bowman wrote:
>>
>>> Why does the default lighting for iSurface illuminate the *bottom* of
>>> the surface?
>>>
>>> And if I want to add a light manually to illuminate the top, why do I
>>> have to
>>> drag it to the *bottom* of the window?
>>>
>>>
>> Exactly what command are you using?
>>
>> What happens if you jsut do something simple like
>>
>> isurface, dist(40)
>>
>> Does it look different if you force software rendering?
>
> The problem appears to be that my z-coordinate decreases upward. Here
> is a simple example.
>
> x = 10*FINDGEN(37)
> y = -90 + 10*FINDGEN(19)
> z = REPLICATE(500.0, 37, 19) + 100.0*RANDOMN(seed, 37*19) ISURFACE, z,
> x, y, /NO_SAVEPROMPT, $
> /SHADING, $
> XTITLE = 'Longitude', $
> XRANGE = [0.0, 360.0], $
> XMAJOR = 5, $
> XMINOR = 2, $
> YTITLE = 'Latitude', $
> YRANGE = [-90.0, 90.0], $
> YMAJOR = 7, $
> YMINOR = 2, $
> ZTITLE = 'Pressure', $
> ZRANGE = [1000.0, 0.0], $
> ZMAJOR = 6, $
> ZMINOR = 1
>
> I would consider this to be a bug, but perhaps it is a feature. :-(
> The way an additional light behaves is, at least, unintuitive.

OK, thanks for the example - it helps a lot.

I'm fairly sure that this effect is related to the normals that IDL
computes for the surface.

When the graphics system (OpenGL) computes the color of each vertex in
your surface, it does so by doing a calculation using the light source
direction vector(s), the surface normal at the vertex, and your eye
position. This varies the color of the surface at each vertex according to
this illumination model and then each surface facet is drawn with color
interpolation using these computed vertex colors.

It sort of looks like the normals for the surface are pointing "down" in
this example, away from the light, which would tend to make the top of the
surface look dark, which is what you are seeing.

These surface normals are computed by IDL in the IDLgrSurface object. When
you give IDLgrSurface a bunch of Z values, it generates a surface mesh
which actually ends up in something a lot like an IDLgrPolygon. IDL
computes the vertex normals from the mesh it generated from your Z data.

IDLgrSurface (and by extension, iSurface) is a sort of convenience object
that makes some assumptions about what direction is "up" for your surface.
It generates the mesh with vertex ordering and normal direction in concert
with these assumptions. These steps and assumptions work well for most
cases.

One could gain more control over all this by using IDLgrPolygon and
generating your own mesh, with your own vertex ordering (clockwise or
counter-clockwise) and normal direction.

I'm not yet certain if this is a bug. With respect to the surface
normals, if you accept the condition that the surface normals are always
going to be oriented so that the "top" of the surface faces in a positive
Z (world) direction, then you are getting exactly what you asked for.
IDLgrSurface could support a property that controls what side of the
surface is the "top", from a lighting perspective.

Another way to attack the problem is to realize that you are flipping your
scene, effectively, in iSurface and need to move the position of the
lights to adapt to the change. I'm pretty sure that they are ways to
locate the visualization objects programmatically. You could find all the
lights and move them to where you want them.

Karl
Re: iSurface lighting questions [message #44590 is a reply to message #44500] Wed, 22 June 2005 09:31 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Rick Towler writes:

> Is your monitor upside down?
>
> I admit I am not an iTools user but if I create a surface in iTools
> 2.0.1 the directional light is above the surface and the surface is
> illuminated from above (as you would expect if the light was above the
> surface).
>
> Maybe that is why all of your text is upside down too?
>
> Can you post an example?

I had this problem, too. My damn monitor is a rectangle
and nowhere did it have a "this side up" label on it. :-(

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: iSurface lighting questions [message #44596 is a reply to message #44590] Wed, 22 June 2005 09:07 Go to previous message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
Kenneth Bowman wrote:
> Why does the default lighting for iSurface illuminate the *bottom* of the
> surface?
>
> And if I want to add a light manually to illuminate the top, why do I have to
> drag it to the *bottom* of the window?

Is your monitor upside down?

I admit I am not an iTools user but if I create a surface in iTools
2.0.1 the directional light is above the surface and the surface is
illuminated from above (as you would expect if the light was above the
surface).

Maybe that is why all of your text is upside down too?

Can you post an example?

-Rick
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: GUI interface update issues
Next Topic: How does IDL find functions?

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

Current Time: Wed Oct 08 19:01:58 PDT 2025

Total time taken to generate the page: 0.00478 seconds