POV-Ray : Newsgroups : povray.newusers : color modulation in textures Server Time
25 Nov 2024 23:42:05 EST (-0500)
  color modulation in textures (Message 11 to 17 of 17)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: tahoma
Subject: Re: color modulation in textures
Date: 11 May 2005 14:23:11
Message: <opsqmio0xgx5erxw@leningrad>
>> I tried it and it works great but only with non uv mapped image_maps.
  

>> When
>> using "uv_mapping" povray complains with "The 'uv_mapping' pattern  

>> cannot
>> be used as part of a pigment function!".
>
> You can apply uv-mapping to the average pigment without problems.
>
>> Is there another way or do i have to wait for a new povray version? I
s  

>> this
>> a features already put on the roadmap of development?
>
> No (at least not in the form you suggested).
>
>> This little feature seems so easy to implement and i wonder if nobody
  

>> else
>> needed it in the past 10 years :o
>
> The motivation for adding/changing something in POV-Ray is not if it i
s  

> easy to implement.

Ok, it was just a thought about this problem because it is important for
 me
at the moment. I know i am just a sandcorn in the desert :)

I come from the realtime part of the rendering world and all kind of 3D 
 

API's,
renderers and so on i worked with use that kind of material model:
define a diffuse color and modulate it by a diffuse image map or  

procedural map
optionally, define a specular color and modulate it by a specular image 
map
and so on.
So i would like to know what is the whole concept behind the povray  

material
model to avoid such questions.
If you have some links, documents or even the answer, i'm interested.


Post a reply to this message

From: tahoma
Subject: Re: color modulation in textures
Date: 12 May 2005 04:42:12
Message: <opsqnmsz0px5erxw@buddie.egoof>
> #declare R = pigment {function {IM(x,y,z).red * Cr}
>    colour_map {[0 rgb 0][1 rgb <1,0,0>]}}
> #declare G = pigment {function {IM(x,y,z).green * Cg}
>    colour_map {[0 rgb 0][1 rgb <0,1,0>]}}
> #declare B = pigment {function {IM(x,y,z).blue * Cb}
>    colour_map {[0 rgb 0][1 rgb <0,0,1>]}}
>
> Then assemble the three components using an average pigment_map
>
> sphere {0,1
>   pigment {average
>     pigment_map {
>       [1 R]
>       [1 G]
>       [1 B]
>     }
>   }
> }

The assembled colors are just 1/3 of the intensity as the original
one's. I replaced Cr/Cg/Cb by 1/1/1. The average function
calculates (1*<1,0,0> + 1*<0,1,0> + 1*<0,0,1>)/3 = <1/3,1/3,1/3>.
If i could use 'add' instead of 'average' of disable the division
by the weight sum ... any ideas?

I think, i understand the colour_map now :)


Post a reply to this message

From: Mike Williams
Subject: Re: color modulation in textures
Date: 12 May 2005 05:10:10
Message: <0G$OuCAD1xgCFwFp@econym.demon.co.uk>
Wasn't it tahoma who wrote:
>> #declare R = pigment {function {IM(x,y,z).red * Cr}
>>    colour_map {[0 rgb 0][1 rgb <1,0,0>]}}
>> #declare G = pigment {function {IM(x,y,z).green * Cg}
>>    colour_map {[0 rgb 0][1 rgb <0,1,0>]}}
>> #declare B = pigment {function {IM(x,y,z).blue * Cb}
>>    colour_map {[0 rgb 0][1 rgb <0,0,1>]}}
>>
>> Then assemble the three components using an average pigment_map
>>
>> sphere {0,1
>>   pigment {average
>>     pigment_map {
>>       [1 R]
>>       [1 G]
>>       [1 B]
>>     }
>>   }
>> }
>
>The assembled colors are just 1/3 of the intensity as the original
>one's. I replaced Cr/Cg/Cb by 1/1/1. The average function
>calculates (1*<1,0,0> + 1*<0,1,0> + 1*<0,0,1>)/3 = <1/3,1/3,1/3>.
>If i could use 'add' instead of 'average' of disable the division
>by the weight sum ... any ideas?

A safe place to multiply by 3 is in the colour_map, so that it
calculates (1*<3,0,0> + 1*<0,3,0> + 1*<0,0,3>)/3.

#declare R = pigment {function {IM(x,y,z).red * Cr}
   colour_map {[0 rgb 0][1 rgb <3,0,0>]}}
#declare G = pigment {function {IM(x,y,z).green * Cg}
   colour_map {[0 rgb 0][1 rgb <0,3,0>]}}
#declare B = pigment {function {IM(x,y,z).blue * Cb}
   colour_map {[0 rgb 0][1 rgb <0,0,3>]}}

(If you multiply Cr, Cb and Cg by 3 it almost works, but, since it's
used in the pattern calculation, when the pattern calculation gives 1.0
it gets truncated down to 0.0 which is not what we want.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: tahoma
Subject: Re: color modulation in textures
Date: 12 May 2005 05:18:54
Message: <opsqnoh4y3x5erxw@buddie.egoof>
I got it. After some time of twaeking i come up with my first macro in  
povray :)

Here it is:

#macro pigment_from_image_map(TextureName, r,g,b)
     #local imageMap =
     function {
         pigment {
             image_map {
                 jpeg TextureName
                 transmit all 0
                 interpolate 2
             }
         }
     }
     #local R = pigment {
         function {imageMap(x,y,z).red*r}
         colour_map {
             [0 rgb 0]
             [1 rgb <3,0,0>]
         }
     }
     #local G = pigment {
         function {imageMap(x,y,z).green*g}
         colour_map {
             [0 rgb 0]
             [1 rgb <0,3,0>]
         }
     }
     #local B = pigment {
         function {imageMap(x,y,z).blue*b}
         colour_map {
             [0 rgb 0]
             [1 rgb <0,0,3>]
         }
     }
     pigment {
         uv_mapping
	  average
         pigment_map {
             [1 R]
             [1 G]
             [1 B]
         }
     }
#end


The usage is quite nice for my purpose:

#declare MY_TEXTURE =
texture {
     pigment_from_image_map("texture01.jpg",1,0,0)	
	finish {
		diffuse 1 ambient 0.2
	}	
}

But when i want to use another imageformat (e.g. png), how can i send it
as a parameter to the macro?
Does anyone from the experienced users has some advices to make it even
more flexible?

Regards,
Jan


Post a reply to this message

From: Loki
Subject: Re: color modulation in textures
Date: 12 May 2005 05:25:00
Message: <web.4283200d9d44ff212e4c26f50@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> Loki <nomail@nomail> wrote:
> > I know what you're getting at.  In fact I suggested a similar change in
> > implementation a while ago and was roundly accused of trolling for
> > mentioning it.
>
>   People don't get accused of trolling because of posting a suggestion.
> People get accused of trolling if they use a certain tone of voice, a
> certain attitude. It's not what is said but how.
>   Please don't twist the facts.
>
> --
>                                                           - Warp

Oh please.  I got accused of trolling by numerous people in one of my first
ever posts here for nothing more than asking basically the same thing as
above: why are properties like 'specular' and 'diffuse' limited to a
non-mappable scalar value?  It's a simple enough question and I had good
reason to ask it.

L
-


Post a reply to this message

From: Tim Nikias
Subject: Re: color modulation in textures
Date: 12 May 2005 05:39:52
Message: <42832468$1@news.povray.org>
> But when i want to use another imageformat (e.g. png), how can i send it
> as a parameter to the macro?
> Does anyone from the experienced users has some advices to make it even
> more flexible?

You could use some of the string-functionality to clip off everything until
the "." in the filename. Note that you can't just clip to the last 3, as
some might save with "JPEG" instead of plain, 3-digit "JPG". Then again, you
could tell that someone did that if the remaining 3 digits showed "PEG"...

Anyways, once you have the last three digits, use
strcmp(One_String,Another_String) and check if they're equal (if they are,
strcmp returns the value 0). Use the proper format according to the results.
(e.g. #if (strcmp(TestThis,"png")) png #end).

Of course, this won't work when somebody doesn't supply an ending for their
images, but shame on those that do that! :-)

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Christoph Hormann
Subject: Re: color modulation in textures
Date: 12 May 2005 05:40:01
Message: <d5v86a$50l$1@chho.imagico.de>
tahoma wrote:
> 
> But when i want to use another imageformat (e.g. png), how can i send it
> as a parameter to the macro?

For a convenient way to do this have a look at the 
IC_ImageFName_Function() macro in IsoCSG:

http://www.tu-bs.de/%7Ey0013390/pov/ic/index.html

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 03 May. 2005 _____./\/^>_*_<^\/\.______


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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