POV-Ray : Newsgroups : povray.general : Modifying an image_map color? Server Time
4 Nov 2024 23:19:57 EST (-0500)
  Modifying an image_map color? (Message 1 to 7 of 7)  
From: CShake
Subject: Modifying an image_map color?
Date: 14 Oct 2009 12:27:51
Message: <4ad5fc07$1@news.povray.org>
I'm currently doing some rendering of game models by exporting through 
MilkShape, and while the basic textures work fine, I'm having some color 
issues. I've found that in the game itself, the same image can be loaded 
for multiple textures, then multiplied by a solid color to give it a 
different hue/brightness.

Is there any way to do this in povray, without having to manually edit 
the .tga files in gimp/photoshop? (I've converted them from .dds to 
.tga, but could use other formats if it would make it easier). The 
majority are multiplied by a <0.6,0.6,0.6> color which at first glance 
is the same as applying 'diffuse 0.6', except many textures also have 
ambient and this doesn't affect the color of that. Also, some have 
non-gray colors, which I can't do with a simple diffuse statement.

Thanks!
Cshake

An example of the textures generated by the exporter:
-----------------------------------------------------
#declare uvtexture_0 = texture{
   uv_mapping pigment{
     image_map{
       tga "hw_p2_fr1.tga"
       map_type 0
       interpolate 2
       transmit all 0.000000
     }
   }
   finish{
     ambient rgb <0.200000 0.200000 0.200000>
     specular 0.100000
     roughness 0.000781
   }
}


Post a reply to this message

From: Christian Froeschlin
Subject: Re: Modifying an image_map color?
Date: 14 Oct 2009 14:51:56
Message: <4ad61dcc$1@news.povray.org>
CShake wrote:

> Is there any way to do this in povray, without having to manually edit 
> the .tga files in gimp/photoshop?

You can convert between pigments and functions, which should allow
you to do arbitrary color transformations on an image_map, e.g.

#macro from_black(COLOR)
color_map
{
   [0 color rgb 0]
   [1 color COLOR]
}
#end

#macro pigment_scale(PIGMENT, SCALE)
#local F = function { pigment {PIGMENT} }
#local R = pigment {function {F(x,y,z).red}   from_black(3*SCALE*Red)  }
#local G = pigment {function {F(x,y,z).green} from_black(3*SCALE*Green)}
#local B = pigment {function {F(x,y,z).blue}  from_black(3*SCALE*Blue) }
pigment {average pigment_map {[R] [G] [B]} }
#end


Post a reply to this message

From: Alain
Subject: Re: Modifying an image_map color?
Date: 14 Oct 2009 15:21:29
Message: <4ad624b9$1@news.povray.org>

> I'm currently doing some rendering of game models by exporting through 
> MilkShape, and while the basic textures work fine, I'm having some color 
> issues. I've found that in the game itself, the same image can be loaded 
> for multiple textures, then multiplied by a solid color to give it a 
> different hue/brightness.
> 
> Is there any way to do this in povray, without having to manually edit 
> the .tga files in gimp/photoshop? (I've converted them from .dds to 
> .tga, but could use other formats if it would make it easier). The 
> majority are multiplied by a <0.6,0.6,0.6> color which at first glance 
> is the same as applying 'diffuse 0.6', except many textures also have 
> ambient and this doesn't affect the color of that. Also, some have 
> non-gray colors, which I can't do with a simple diffuse statement.
> 
> Thanks!
> Cshake
> 
> An example of the textures generated by the exporter:
> -----------------------------------------------------
> #declare uvtexture_0 = texture{
>   uv_mapping pigment{
>     image_map{
>       tga "hw_p2_fr1.tga"
>       map_type 0
>       interpolate 2
>       transmit all 0.000000
>     }
>   }
>   finish{
>     ambient rgb <0.200000 0.200000 0.200000>
>     specular 0.100000
>     roughness 0.000781
>   }
> }
If you use that texture in a radiosity scene, you must replace the 
ambient by ambient 0. Otherwise, it will actualy illuminate it's 
surrounding.

In some cases, you can use a layered texture.
Use a fully transparent uper texture with some transmit or filter, like:
pigment{rgbf <1, 0.5, 0.1, 1>}
This will add an orange cast to the underlying pigment.
You can use a filter or transmit larger than 1 to create some 
interesting effect.
You can use a negative filter or transmit. It result in a negative effect.


Alain


Post a reply to this message

From: CShake
Subject: Re: Modifying an image_map color?
Date: 14 Oct 2009 21:09:40
Message: <4ad67654$1@news.povray.org>
Alain wrote:
> In some cases, you can use a layered texture.
> Use a fully transparent uper texture with some transmit or filter, like:
> pigment{rgbf <1, 0.5, 0.1, 1>}
> This will add an orange cast to the underlying pigment.
> You can use a filter or transmit larger than 1 to create some 
> interesting effect.
> You can use a negative filter or transmit. It result in a negative effect.
> 
> 
> Alain

I was hoping this would work since it's almost exactly what I want, but 
I get the error "Cannot layer over a patterned texture", which I assume 
comes from having an image_map.
On to try Christian's method now.

Chris


Post a reply to this message

From: CShake
Subject: Re: Modifying an image_map color?
Date: 15 Oct 2009 10:43:09
Message: <4ad734fd$1@news.povray.org>
Christian Froeschlin wrote:
> CShake wrote:
> 
>> Is there any way to do this in povray, without having to manually edit 
>> the .tga files in gimp/photoshop?
> 
> You can convert between pigments and functions, which should allow
> you to do arbitrary color transformations on an image_map, e.g.
> 
> #macro from_black(COLOR)
> color_map
> {
>   [0 color rgb 0]
>   [1 color COLOR]
> }
> #end
> 
> #macro pigment_scale(PIGMENT, SCALE)
> #local F = function { pigment {PIGMENT} }
> #local R = pigment {function {F(x,y,z).red}   from_black(3*SCALE*Red)  }
> #local G = pigment {function {F(x,y,z).green} from_black(3*SCALE*Green)}
> #local B = pigment {function {F(x,y,z).blue}  from_black(3*SCALE*Blue) }
> pigment {average pigment_map {[R] [G] [B]} }
> #end

Thanks, this seems to work perfectly. More code than I anticipated, but 
oh well. I'll have to see if I can modify the exporter to allow for it 
natively.

A new issue I'm finding is that all the uv_mapping textures seem to be 
mirrored in either u or v , so I'm having to go through and scale them 
with a bit of trial and error. I'm assuming this is the fault of the 
exporter not doing the right-handed coordinated (milkshape) to 
left-handed (povray) correctly.
I'm not holding my breath, but could there be a way of not needing to do 
this by hand, either through scaling the mesh or something? It seems 
that whichever direction is closest to being in-line with z (either u or 
v) needs to be mirrored for the texture to work correctly.


Post a reply to this message

From: clipka
Subject: Re: Modifying an image_map color?
Date: 15 Oct 2009 10:58:24
Message: <4ad73890$1@news.povray.org>
CShake schrieb:

> A new issue I'm finding is that all the uv_mapping textures seem to be 
> mirrored in either u or v , so I'm having to go through and scale them 
> with a bit of trial and error. I'm assuming this is the fault of the 
> exporter not doing the right-handed coordinated (milkshape) to 
> left-handed (povray) correctly.
> I'm not holding my breath, but could there be a way of not needing to do 
> this by hand, either through scaling the mesh or something? It seems 
> that whichever direction is closest to being in-line with z (either u or 
> v) needs to be mirrored for the texture to work correctly.

Mirroring the geometry will not help you there; you will need to mirror 
either (a) the original texture images, or (b) the textures.

This also has nothing to do with POV-Ray's left-handed world coordinate 
system (which is actually just the default, and can be changed by 
choosing appropriate camera parameters), but an incompatibility of the 
UV coordinate system. As this is clearly defined in POV-Ray and cannot 
be changed (except by messing with the textures), it must therefore be 
considered a bug in the exporter (unless you're going via an interim 
file format in which UV coordinate space is poorly defined).


Post a reply to this message

From: Thomas de Groot
Subject: Re: Modifying an image_map color?
Date: 16 Oct 2009 03:06:17
Message: <4ad81b69$1@news.povray.org>
"CShake" <cshake+pov### [at] gmailcom> schreef in bericht 
news:4ad67654$1@news.povray.org...
>
> I was hoping this would work since it's almost exactly what I want, but I 
> get the error "Cannot layer over a patterned texture", which I assume 
> comes from having an image_map.
> On to try Christian's method now.
>
>

No. Image_maps work fine with layered textures as Poseray (for instance) 
shows clearly. The error must come from something else.

Here is an example texture as Poseray generates:

//===start code===
#declare p_map6=pigment {image_map{png "MyImage.png" interpolate 2 transmit 
all 0 filter all 0.21} }

#declare LeftEyeWhite_1_=
material{
texture{ pigment {color rgb <0.79,0.79,0.79> transmit  0}
        finish{specular 0 roughness 1 ambient rgb <0.00,0.00,0.00> diffuse 
0.8 reflection{0} conserve_energy}}
texture{ pigment{uv_mapping p_map6}
        finish{specular 0.04266667 roughness 0.01484519 ambient rgb 
<0.00,0.00,0.00> diffuse 0.8   reflection{0 } conserve_energy}}
}
//===end code===

material{} is not strictly necessary for layering. Note also that here the 
image_map p_map6 is on top, which is possible as it has some filter. In the 
same way, you can inverse the textures, providing some filter or transmit to 
the top pigment.

Hope this helps.

Thomas


Post a reply to this message

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