POV-Ray : Newsgroups : povray.newusers : color modulation in textures Server Time
29 Jul 2024 16:34:01 EDT (-0400)
  color modulation in textures (Message 1 to 10 of 17)  
Goto Latest 10 Messages Next 7 Messages >>>
From: tahoma
Subject: color modulation in textures
Date: 11 May 2005 10:00:00
Message: <web.42820fb76e48ea57d1428acf0@news.povray.org>
I started with povray some days ago to convert some realtime scenes to
povray files. After reading the documentation again and again i wondered if
it would be possible to define materials or textures just like in OpenGL,
3dsMax and so on.

E.g. the modulation of an image_map color with a constant color:
pigment = <image_map[u,v].red * color.red, image_map[u,v].green *
color.green, image_map[u,v].blue * color.blue>

Furthermore i wondered why it is possible to define an ambient "reflection"
as rgb but a diffuse and specular reflection just as scalar. If it would be
possible i would not need to modulate the image_map anymore.
Are there any workarounds to do that?

I want to use the commonly used lighting equation:
Result = Ambient(rgb) +
DiffuseMap(rgb)*DiffuseReflection(rgb)*DiffuseCoefficient(scalar) +
SpecularMap(rgb)*SpecularReflection(rgb)*SpecularCoefficient(scalar)

Thanks,
Jan


Post a reply to this message

From: Loki
Subject: Re: color modulation in textures
Date: 11 May 2005 10:10:01
Message: <web.4282122f9d44ff21b8197a8e0@news.povray.org>
"tahoma" <nomail@nomail> wrote:
> I started with povray some days ago to convert some realtime scenes to
> povray files. After reading the documentation again and again i wondered if
> it would be possible to define materials or textures just like in OpenGL,
> 3dsMax and so on.
>
> E.g. the modulation of an image_map color with a constant color:
> pigment = <image_map[u,v].red * color.red, image_map[u,v].green *
> color.green, image_map[u,v].blue * color.blue>
>
> Furthermore i wondered why it is possible to define an ambient "reflection"
> as rgb but a diffuse and specular reflection just as scalar. If it would be
> possible i would not need to modulate the image_map anymore.
> Are there any workarounds to do that?
>
> I want to use the commonly used lighting equation:
> Result = Ambient(rgb) +
> DiffuseMap(rgb)*DiffuseReflection(rgb)*DiffuseCoefficient(scalar) +
> SpecularMap(rgb)*SpecularReflection(rgb)*SpecularCoefficient(scalar)
>
> Thanks,
> Jan

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. (but that's all water under the bridge.)  There is no easy
way to implement different image maps for different illumination channels,
i.e. having a diffuse map separate from a specular map in the same texture.
 However, you can (with a bit of work) create multiple textures which blend
together the required aspects.  It is still not as versatile as mapping to
different channels, and with complex textures it can be a real brain-ache
to get it right, but it does offer some of the functionality that it sounds
like you're used to.  Oh for a truly world-class hypergraph. ;)

L
-


Post a reply to this message

From: tahoma
Subject: Re: color modulation in textures
Date: 11 May 2005 10:30:00
Message: <web.428216a39d44ff21d1428acf0@news.povray.org>
>  However, you can (with a bit of work) create multiple textures which blend
> together the required aspects.  It is still not as versatile as mapping to
> different channels, and with complex textures it can be a real brain-ache
> to get it right, but it does offer some of the functionality that it sounds
> like you're used to.  Oh for a truly world-class hypergraph. ;)

Thank you.
Ok, assuming i just have 1 diffuse map (image_map). How can i modulate this
image_map with a constant color with povray? I tried the "texture_map" with
all different modes but i could not manage to modulate all textures. I dont
want to fetch the pigment just from an image_map.
A really ugly workaround i can image of is to modulate the original
image_map with the color, save it to disk and give it povray to render. But
as i said, really ugly.

Example:

texture {
  average   // why not 'modulate'?
  texture_map {
    [0.0
      pigment {
        color rgb <1.0, 0.0, 0.0>
      }
    ]
    [1.0
      pigment {
        image_map {
          uv_mapping
          jpeg "texture01.jpg"
          interpolate 2
        }
      }
    ]
  }
}


Post a reply to this message

From: Warp
Subject: Re: color modulation in textures
Date: 11 May 2005 10:59:02
Message: <42821db6@news.povray.org>
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


Post a reply to this message

From: Mike Williams
Subject: Re: color modulation in textures
Date: 11 May 2005 11:01:39
Message: <5mjNmBAw4hgCFwmk@econym.demon.co.uk>
Wasn't it tahoma who wrote:
>I started with povray some days ago to convert some realtime scenes to
>povray files. After reading the documentation again and again i wondered if
>it would be possible to define materials or textures just like in OpenGL,
>3dsMax and so on.
>
>E.g. the modulation of an image_map color with a constant color:
>pigment = <image_map[u,v].red * color.red, image_map[u,v].green *
>color.green, image_map[u,v].blue * color.blue>

This can be achieved with pigment functions, but it's a bit tricky.

Let there be a colour "C".

We first have to split the colour into its components, because the parser
doesn't like the syntax "C.red" in the next stage.

#declare Cr = C.red;
#declare Cg = C.green;
#declare Cb = C.blue;

Now define a pigment function from the image_map.

#declare IM = function {pigment {image_map {jpeg "tex.jpg" interpolate 2}}}

Then calculate three pigments that will be the components of the modulated
pigment. In this case the calculation is IM.red * C.red, which gives you the
pattern of the pigment. The pattern is then colour_mapped to the range black-
to-red (otherwise it ends up greyscale).

#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]
    }
  }
}

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: tahoma
Subject: Re: color modulation in textures
Date: 11 May 2005 11:55:01
Message: <web.42822a7c9d44ff21929af40a0@news.povray.org>
Mike Williams <nos### [at] econymdemoncouk> wrote:
> Wasn't it tahoma who wrote:
> >I started with povray some days ago to convert some realtime scenes to
> >povray files. After reading the documentation again and again i wondered if
> >it would be possible to define materials or textures just like in OpenGL,
> >3dsMax and so on.
> >
> >E.g. the modulation of an image_map color with a constant color:
> >pigment = <image_map[u,v].red * color.red, image_map[u,v].green *
> >color.green, image_map[u,v].blue * color.blue>
>
> This can be achieved with pigment functions, but it's a bit tricky.
>
> Let there be a colour "C".
>
> We first have to split the colour into its components, because the parser
> doesn't like the syntax "C.red" in the next stage.
>
> #declare Cr = C.red;
> #declare Cg = C.green;
> #declare Cb = C.blue;
>
> Now define a pigment function from the image_map.
>
> #declare IM = function {pigment {image_map {jpeg "tex.jpg" interpolate 2}}}
>
> Then calculate three pigments that will be the components of the modulated
> pigment. In this case the calculation is IM.red * C.red, which gives you the
> pattern of the pigment. The pattern is then colour_mapped to the range black-
> to-red (otherwise it ends up greyscale).
>
> #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]
>     }
>   }
> }

Whoa, pretty nice :)

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!". Nevertheless, I never was so close
to the solution, thank you so far.

Is there another way or do i have to wait for a new povray version? Is this
a features already put on the roadmap of development?
This little feature seems so easy to implement and i wonder if nobody else
needed it in the past 10 years :o

Regards,
Jan


Post a reply to this message

From: Mike Williams
Subject: Re: color modulation in textures
Date: 11 May 2005 13:59:47
Message: <jzMbTKANgkgCFw1Q@econym.demon.co.uk>
Wasn't it tahoma who wrote:
>Mike Williams <nos### [at] econymdemoncouk> wrote:
>> Wasn't it tahoma who wrote:
>> >I started with povray some days ago to convert some realtime scenes to
>> >povray files. After reading the documentation again and again i wondered if
>> >it would be possible to define materials or textures just like in OpenGL,
>> >3dsMax and so on.
>> >
>> >E.g. the modulation of an image_map color with a constant color:
>> >pigment = <image_map[u,v].red * color.red, image_map[u,v].green *
>> >color.green, image_map[u,v].blue * color.blue>
>>
>> This can be achieved with pigment functions, but it's a bit tricky.
>>
>> Let there be a colour "C".
>>
>> We first have to split the colour into its components, because the parser
>> doesn't like the syntax "C.red" in the next stage.
>>
>> #declare Cr = C.red;
>> #declare Cg = C.green;
>> #declare Cb = C.blue;
>>
>> Now define a pigment function from the image_map.
>>
>> #declare IM = function {pigment {image_map {jpeg "tex.jpg" interpolate 2}}}
>>
>> Then calculate three pigments that will be the components of the modulated
>> pigment. In this case the calculation is IM.red * C.red, which gives you the
>> pattern of the pigment. The pattern is then colour_mapped to the range black-
>> to-red (otherwise it ends up greyscale).
>>
>> #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]
>>     }
>>   }
>> }
>
>Whoa, pretty nice :)
>
>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!". Nevertheless, I never was so close
>to the solution, thank you so far.

You're probably just putting the "uv_mapping" keyword in the wrong
place. Don't do the uv_mapping when you define the pigment functions, do
it when you apply the complete texture to the object.

sphere {0,1
  texture {uv_mapping
    pigment {average
      pigment_map {
        [1 R]
        [1 G]
        [1 B]
      }
    }
  }
}


-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Christoph Hormann
Subject: Re: color modulation in textures
Date: 11 May 2005 14:00:01
Message: <d5th3g$8a6$1@chho.imagico.de>
tahoma wrote:
> 
> E.g. the modulation of an image_map color with a constant color:
> pigment = <image_map[u,v].red * color.red, image_map[u,v].green *
> color.green, image_map[u,v].blue * color.blue>

If you want to change the colors in an image map this should be done 
with an imaging program.  Mike also explained how you can do this 
internally (which is a good example for how POV-SDL can be used to do 
things it was never intended for).

> Furthermore i wondered why it is possible to define an ambient "reflection"
> as rgb but a diffuse and specular reflection just as scalar.

The ambient finish component in POV-Ray is a color, diffuse and specular 
are scalar.  This is explained in the manual.  So you can use:

finish {
   ambient <0.1, 0.2, 0.3>
}

to 'modulate' the ambient finish.  Note the color of specular highlights 
can be influenced with the 'metallic' keyword.  Apart from that you can 
also use layered textures to have more detailed control.

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

From: Christoph Hormann
Subject: Re: color modulation in textures
Date: 11 May 2005 14:05:01
Message: <d5thb9$8el$1@chho.imagico.de>
tahoma wrote:
> 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? Is 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 is 
easy to implement.

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

From: tahoma
Subject: Re: color modulation in textures
Date: 11 May 2005 14:13:32
Message: <opsqmh8wctx5erxw@leningrad>
On Wed, 11 May 2005 18:59:41 +0100, Mike Williams  

<nos### [at] econymdemoncouk> wrote:

> Wasn't it tahoma who wrote:
>> Mike Williams <nos### [at] econymdemoncouk> wrote:
>>> Wasn't it tahoma who wrote:
>>> >I started with povray some days ago to convert some realtime scenes
 to
>>> >povray files. After reading the documentation again and again i  

>>> wondered if
>>> >it would be possible to define materials or textures just like in  

>>> OpenGL,
>>> >3dsMax and so on.
>>> >
>>> >E.g. the modulation of an image_map color with a constant color:
>>> >pigment = <image_map[u,v].red * color.red, image_map[u,v].green *

>>> >color.green, image_map[u,v].blue * color.blue>
>>>
>>> This can be achieved with pigment functions, but it's a bit tricky.
>>>
>>> Let there be a colour "C".
>>>
>>> We first have to split the colour into its components, because the  

>>> parser
>>> doesn't like the syntax "C.red" in the next stage.
>>>
>>> #declare Cr = C.red;
>>> #declare Cg = C.green;
>>> #declare Cb = C.blue;
>>>
>>> Now define a pigment function from the image_map.
>>>
>>> #declare IM = function {pigment {image_map {jpeg "tex.jpg" interpo
late  

>>> 2}}}
>>>
>>> Then calculate three pigments that will be the components of the  

>>> modulated
>>> pigment. In this case the calculation is IM.red * C.red, which gives
  

>>> you the
>>> pattern of the pigment. The pattern is then colour_mapped to the ran
ge  

>>> black-
>>> to-red (otherwise it ends up greyscale).
>>>
>>> #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]
>>>     }
>>>   }
>>> }
>>
>> Whoa, pretty nice :)
>>
>> 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!". Nevertheless, I never was so
  

>> close
>> to the solution, thank you so far.
>
> You're probably just putting the "uv_mapping" keyword in the wrong
> place. Don't do the uv_mapping when you define the pigment functions, 
do
> it when you apply the complete texture to the object.
>
> sphere {0,1
>   texture {uv_mapping
>     pigment {average
>       pigment_map {
>         [1 R]
>         [1 G]
>         [1 B]
>       }
>     }
>   }
> }

That did the trick. Thanks.


Post a reply to this message

Goto Latest 10 Messages Next 7 Messages >>>

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