POV-Ray : Newsgroups : povray.general : Override textures and materials? : Re: Override textures and materials? Server Time
26 Jun 2024 01:26:45 EDT (-0400)
  Re: Override textures and materials?  
From: William F Pokorny
Date: 17 Jan 2016 11:53:27
Message: <569bc707@news.povray.org>
On 01/17/2016 09:28 AM, clipka wrote:
> Am 17.01.2016 um 09:39 schrieb Kenneth:
>> Mike Horvath <mik### [at] gmailcom> wrote:
>>>
>>> Is it possible to create an empty texture? In this case, I could swap
>>> out the current textures and instead apply one texture to the entire
>>> scene. Without too much effort on my part if it works.
>>
>> Yes, you can create an empty texture, like this...  texture{}  .... which, as
>> far as I know, is the same as having no texture statement at all-- in which case
>> POV-Ray substitutes it's own default texture (the common black color which we've
>> all seen.)  BUT, if you create your *own* #default{....} texture, then the
>> 'empty texture' statement will use that instead. Which leads to something
>> interesting...
>
> There are some differences between explicitly specifying "texture{}",
> and not specifying any texture at all.
>
> The first difference is in what version of the default you get: If you
> specify "texture{}", you will get whatever the default is set to when
> you /construct/ the object, whereas if you don't specify any texture at
> all, you will get whatever the default is when you actually /insert/ the
> object into the scene.
>
> The second difference is in what happens if the object is used in a CSG
> with an explicit texture: If you specify "texture{}", the object will
> stubbornly cling to the default texture, whereas if you specify no
> texture at all, the object will inherit any texture set on the parent.
>
> Take the following example:
>
> //==============================================
>
> #version 3.7;
>
> camera {
>    location  <3,5,-7>
>    right     x*image_width/image_height
>    look_at   <0,1,0>
> }
>
> light_source{ <1,2,-3>*3000 colour rgb 1 }
>
> //----------------------------------------------
> #default { pigment { colour red 1 } }
> //----------------------------------------------
>
> // The plane and box have no texture at all,
> // and will remain "open to new suggestions":
> #declare Plane  = plane  { <0,1,0>, 0 }
> #declare Box    = box    { <-2,0,-1>, <0,2,1> }
>
> // The sphere's texture is fixed forever to red here:
> #declare Sphere = sphere { <1,1,0>, 1 texture {} }
>
> //----------------------------------------------
> #default { pigment { colour green 1 } }
> //----------------------------------------------
>
> // The front union per se has no texture either,
> // and will remain "open to new suggestions"
> // (except for the sphere, which is fixed to red):
> #declare Front = union {
>    object { Sphere }
>    object { Box }
>    translate <0,0,-2>
> }
>
> // The back union's texture is fixed forever to green here
> // (except for the sphere, which is fixed to red):
> #declare Back = union {
>    object { Sphere }
>    object { Box }
>    translate <0,0,2>
>    texture {}
> }
>
> //----------------------------------------------
> #default { pigment { colour rgb 1 } }
> //----------------------------------------------
>
> // All unfixed textures are fixed to white now:
> object { Front }
> object { Back }
> object { Plane }
>
> //----------------------------------------------
> #default { pigment { colour blue 1 } }
> //----------------------------------------------
>
> // Changing the default yet again to blue has
> // no further effect.
>
> //==============================================
>
> There is also a third difference, which I'll leave as an exercise to the
> reader to verify experimentally, and which is of vital importance to the
> original problem:
>
> If you specify "texture{}", the default texture applied to the object
> will be subject to any subsequent transformations applied to that
> object, whereas if you specify no texture at all, a default texture
> applied to the object will remain entirely untransformed (and a texture
> inherited from a parent CSG object will only be subject to
> transformations of that parent).
>
>
> Thus, defining all textures as empty and using a gradient default will
> most likely not achieve the desired results, as many objects will
> probably include some transformation or the other.
>
>
> The only currently viable solution I can imagine is to alway use some
> macro to apply textures, and have it evaluate to /nothing at all/ when
> rendering a depth-coded version of the scene, like so:
>
>    #if (DepthRender)
>      default { /* some gradient-based texture */ }
>      #macro Texture(t) #end
>    #else
>      #macro Texture(t)
>        texture { t }
>      #end
>    #end
>

Thanks for the texture inheritance tutorial & example code. Got me 
thinking. I believe we can use the interior_texture feature something 
like so using your example scene to get what folks want :

...
// All unfixed textures are fixed to white now:
// object { Front }  // Comment this line and following 2
// object { Back }
// object { Plane }

// Then insert the following lines.
#declare AllObjects = union {
  object { Front }
  object { Back  }
  object { Plane }
  box { <2,2,2> <3.1,3.1,3.1> pigment { rgb <0.7,0.8,0> } } // added
  inverse
}

intersection {
    box { <-10,-10,-10> <10,10,10> }
    object { AllObjects }
    hollow on
    texture { pigment { rgbft <1,1,1,1,0> } }
    interior_texture {
       pigment { gradient z triangle_wave scale <1,1,20>
          color_map {
              [0.0 rgb <1,0,0>]
              [0.5 rgb <1,1,0>]
              [1.0 rgb <0,1,0>]
          }
       }
    }
    finish { ambient 1 diffuse 0 }
}
...

Bill P.


Post a reply to this message

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