[comp.graphics] ray tracing transparent images and color

brianm@sco.COM (Brian Moffet) (06/02/89)

Hi, me again

Just a quick (hah!) question regarding percieved color.
I was doing some thought experiments on how one would
do a ray trace of a transparent object.   Ignore everything
except tint of the object.  So, no refraction or reflection 
involved.

I am going to work in a simple color scheme, where colors
will be defined as scales of red-green-blue with 0 being
lowest (ie off) and 16 being highest.

Given an object whose tint is { 2, 0, 4 } (r,g,b)  in front of
a background whose solid color is { 14, 15, 10 }.
So, a different color will be shown for the object due to the
interaction of the transparent object and the solid background.
I also assume that the color will tend toward black.

Given this, I would say that I can take the two objects and combine them
in the following equation:

	Rfinal = Rback - Gobject - Bobject
	Gfinal = GBack - Robject - Bobject
	Bfinal = Bback - Gobject - Robject

for a final shown color of  { 10, 9, 8 }.

The reason I think this wa is it does produce blak on opposing colors
like red object and blue background.

Does this make sense?  Any good references?

thanks.

brian moffet

Please excuse spelling errors, This machine doesn't have spell!
-- 
Brian Moffet			{uunet,decvax!microsoft,ucscc}!sco!brianm
 -or-				...sco!alar!brian
"I was everything you wanted me to be.  You were afraid, I was frightening."
My fish and company have policies.  I have opinions.

markv@tillamook.uucp (Mark VandeWettering) (06/03/89)

In article <2809@scolex.sco.COM> brianm@sco.COM (Brian Moffet) writes:
>Just a quick (hah!) question regarding percieved color.
>I was doing some thought experiments on how one would
>do a ray trace of a transparent object.   Ignore everything
>except tint of the object.  So, no refraction or reflection 
>involved.

	Aha.  Great (and reasonably complex) topic you have accidentally
	stumbled upon.  I recently have been thinking about precisely
	the problem you describe.

>I am going to work in a simple color scheme, where colors
>will be defined as scales of red-green-blue with 0 being
>lowest (ie off) and 16 being highest.
	
	Good ole RGB color scheme.....

>Given an object whose tint is { 2, 0, 4 } (r,g,b)  in front of
>a background whose solid color is { 14, 15, 10 }.
>So, a different color will be shown for the object due to the
>interaction of the transparent object and the solid background.
>I also assume that the color will tend toward black.

	There is actually no reason to believe that the color will tend
	toward black at all.   More on this later.

>Given this, I would say that I can take the two objects and combine them
>in the following equation:
>
>	Rfinal = Rback - Gobject - Bobject
>	Gfinal = GBack - Robject - Bobject
>	Bfinal = Bback - Gobject - Robject

	This is a strange set of equations, noticeably because you are
	using subtraction.  The operator you wish to use is
	multiplication.

	Imagine that your colors are in the range 0-1 (the math is
	easier).  Further imagine that you RGB are specific wavelengths
	of light.   The color you perceive is due to the relative
	contribution of each frequency to the overall spectrum.

	Your transparent object acts as a filter.  In order to determine
	the outgoing intensities after the filter, you MULTIPLY the
	filter at each frequency by the input frequency.

	For example,  a perfectly clear object would have RGB like 
	(1.0, 1.0, 1.0), and a red object would have (1.0, 0.0, 0.0).


	If we take your example, and normalize into the 0-1 range:

	{2, 0, 4} = (0.125, 0, .25)
	{14, 16, 10} = (0.875, .937, .625)

	output = (.1093, 0, .1562) = {2, 0, 2}

>Does this make sense?  Any good references?
	
	You method doesn't make sense, but that is because color is kind
	of hard to do properly.  The truth is, you can't really get away
	with just using RGB if you want a reasonably accurate color
	model.   Good Reference of the Day:  Roy Hall's new book,
	published by Springer Verlag.  The title... um.... help me out
	people, my copy is at home.  Something like "Color and
	Illumination Models in Computer Graphics".

Mark VandeWettering

z8my@vax5.CIT.CORNELL.EDU (06/10/89)

In article <2809@scolex.sco.COM> brianm@sco.COM (Brian Moffet) queries
about transmitted light colors:

>I was doing some thought experiments on how one would
>do a ray trace of a transparent object.   Ignore everything
>except tint of the object.  So, no refraction or reflection 
>involved.

>I am going to work in a simple color scheme, where colors
>will be defined as scales of red-green-blue with 0 being
>lowest (ie off) and 16 being highest.

>Given an object whose tint is { 2, 0, 4 } (r,g,b)  in front of
>a background whose solid color is { 14, 15, 10 }.
>So, a different color will be shown for the object due to the
>interaction of the transparent object and the solid background.
>I also assume that the color will tend toward black.

For the scheme I will present below (which while probably not theoretically
correct, or even common usage in the computer graphic community) it would 
be much more convenient to keep colors using floats in the range 0..1.

>Given this, I would say that I can take the two objects and combine them
>in the following equation:
>
>	Rfinal = Rback - Gobject - Bobject
>	Gfinal = GBack - Robject - Bobject
>	Bfinal = Bback - Gobject - Robject
>
>for a final shown color of  { 10, 9, 8 }.

How about

        Rfinal = Rback*Robject
        Gfinal = Gback*Gobject
        Bfinal = Bback*Gobject

This is how I implemented transparency in my final project (a ray tracer)
for a computer graphics course here at Cornell (with Don Greenberg as
professor...)  Since I sort of drifted through the lectures on color science,
I can not attest to the correctness of this, but it seemed to produce
reasonable results.

>The reason I think this wa is it does produce blak on opposing colors
>like red object and blue background.

This scheme does too.  Purely blue objects transmit NO red light.

>Does this make sense?  Any good references?

What happens in your scheme when the color of the object is greater than
the color of the background?

>thanks.

You are completely welcoe.

>brian moffet

>Please excuse spelling errors, This machine doesn't have spell!

Ditto... well, I'm actually posting from a machine using the Eunice UNIX
emulator for VMS.  It breaks on a lot of things--I'm afriad to try spell,
at least right now.

Samuel Paik

Internet:  d65y@vax5.cit.cornell.edu
      note:^^^^ not z8my

kyriazis@rpics (George Kyriazis) (06/11/89)

In article <2809@scolex.sco.COM> brianm@sco.COM (Brian Moffet) queries
about transmitted light colors:
>I was doing some thought experiments on how one would
>do a ray trace of a transparent object.   Ignore everything
>except tint of the object.  So, no refraction or reflection 
>involved.
>

Ok, either I'm confused, or the whole net is confused!  When I think
of a transparent object, I automatically think of refracted rays.
How can you have a transparent object with no refraction effects and
still keep it transparent is something that my mind can't conprehend!!
In any raytracer that I've dealt with, if I set the refractive color to be
[ 0 0 0 ], I don't see any transparency effects.
If you mean the refraction index == 1, then I think that the wording
is wrong..

So, what is it?  Am I confused, or the net is confused?


  George Kyriazis
  kyriazis@turing.cs.rpi.edu
  kyriazis@rdrc.rpi.edu
------------------------------

afoiani@dante.nmsu.EDU (Anthony Foiani) (06/11/89)

hmm... sounds to me like he's talking about looking through a glass
window or something to that effect... 

alternatively, it could be translated as placing a certain filter over
an image;  the various multiplication schemes which have shown up on
this topic would make seem to work when it is considered a filter on
the "lens" of a compu-camera.  

that is, using the 0..1 scale that many people seem to like, having a
blue filter with <r,g,b> of {0,0,1}, this would work;  it would
transmit very little of the r and g objects, but would allow the blue
to pass essentially unhampered.

i'm by *NO* means an expert, but this seems to make a wierd sort of
sense.

hoped this helped,
--
tony foiani  (afoiani@nmsu.edu)         "And remember...don't lose your
             (mcsajf@nmsuvm1.bitnet)     head..." -The Kurgan, HIGHLANDER

kyriazis@rpics (George Kyriazis) (06/13/89)

In article <AFOIANI.89Jun10195149@dante.nmsu.EDU> afoiani@dante.nmsu.EDU (Anthony Foiani) writes:
>hmm... sounds to me like he's talking about looking through a glass
>window or something to that effect... 
>
>alternatively, it could be translated as placing a certain filter over
>an image;  the various multiplication schemes which have shown up on
>this topic would make seem to work when it is considered a filter on
>the "lens" of a compu-camera.  
>

Yes, I agree on that, but that certainly implies that there are some refracted
ray going THROUGH the glass.  If they weren't, simply you could just see
a solid blob.

>i'm by *NO* means an expert, but this seems to make a wierd sort of
>sense.
>

Me neither...




  George Kyriazis
  kyriazis@turing.cs.rpi.edu
  kyriazis@rdrc.rpi.edu
------------------------------