POV-Ray : Newsgroups : povray.general : Override textures and materials? : Re: Override textures and materials? Server Time
18 Jun 2024 06:25:43 EDT (-0400)
  Re: Override textures and materials?  
From: clipka
Date: 17 Jan 2016 09:28:04
Message: <569ba4f4$1@news.povray.org>
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


Post a reply to this message

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