POV-Ray : Newsgroups : povray.newusers : Trace with pigments Server Time
1 Nov 2024 14:17:48 EDT (-0400)
  Trace with pigments (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: Gyscos
Subject: Trace with pigments
Date: 5 Jul 2008 03:45:00
Message: <web.486f25958f0468281ba56a630@news.povray.org>
Hello !
Is there a way to use the trace function (or another one) to get the color
vector, and even maybe the texture value of an object in one point, a bit like
the trace function works ?


Post a reply to this message

From: Tim Attwood
Subject: Re: Trace with pigments
Date: 5 Jul 2008 04:10:37
Message: <486f2c7d$1@news.povray.org>
> Is there a way to use the trace function (or another one) to get the color
> vector, and even maybe the texture value of an object in one point, a bit 
> like
> the trace function works ?

There's eval_pigment in functions.inc, but there's no way to get
a final textured color except to render the scene.


Post a reply to this message

From: Gyscos
Subject: Re: Trace with pigments
Date: 5 Jul 2008 04:40:00
Message: <web.486f32aec03ce0661ba56a630@news.povray.org>
But how would I do if I don't know the pigment of the object ?
I only have an object "Obj", with a texture that I don't know...


Post a reply to this message

From: Chris B
Subject: Re: Trace with pigments
Date: 5 Jul 2008 05:13:40
Message: <486f3b44$1@news.povray.org>
"Gyscos" <gys### [at] gmailcom> wrote in message 
news:web.486f32aec03ce0661ba56a630@news.povray.org...
> But how would I do if I don't know the pigment of the object ?
> I only have an object "Obj", with a texture that I don't know...

I can't think of anything that would give you that.

The 'trace' function can give you a point on a the surface of an object and, 
as Tim mentioned, the 'eval_pigment' function can give you the pigment's 
colour value at that point. However, as you pointed out, you need to be able 
to pass it a copy of the pigment or a pigment identifier (in the same way 
that you need to pass the 'trace' function a copy of the object or an object 
identifier).

As POV-Ray files are generally human-readable, can't you find the object 
definition and extract a copy of the pigment component of that object's 
texture? This could of course be difficult with layered textures.

Otherwise, what are you ultimately trying to achieve? It may be that someone 
can recommend a different approach that works around this particular 
problem.

Regards,
Chris B.


Post a reply to this message

From: Gyscos
Subject: Re: Trace with pigments
Date: 5 Jul 2008 06:25:00
Message: <web.486f4b04c03ce0661ba56a630@news.povray.org>
Well, i was trying to do a macro that puts spheres on the surface of an object,
with many trace. And I w as trying to give the spheres the color of the object
in this point... But if that's not possible, well, too bad :(


Post a reply to this message

From: Chris B
Subject: Re: Trace with pigments
Date: 5 Jul 2008 10:28:27
Message: <486f850b@news.povray.org>
"Gyscos" <gys### [at] gmailcom> wrote in message 
news:web.486f4b04c03ce0661ba56a630@news.povray.org...
> Well, i was trying to do a macro that puts spheres on the surface of an 
> object,
> with many trace. And I w as trying to give the spheres the color of the 
> object
> in this point... But if that's not possible, well, too bad :(
>

Well here's my bestest smartass hack of the day:

If you use the inverse of the object and difference the spheres from it you 
can use the 'cutaway_textures' keyword to give the spheres the same pigment, 
normal and finish as the object (even if you don't know what they are). The 
downside to this hack is that your camera ends up technically 'inside' the 
object which will mess up interior features like media if you want to use 
them in the same scene. The upside is that it should do what you asked.

The following example illustrates the technique using a simple CSG object, 
but I think it should work with more complex objects.

Regards,
Chris B.

camera {location <0,0,-4> look_at 0 }
light_source {<-1,0 ,-4>, rgb 3}

#declare MyObject = intersection {
  box {-1,1 pigment {agate scale 2} }
  sphere {0,1.25 pigment {agate scale 2}}
}

#declare MyObjectWithSpheres = difference {
  object {MyObject inverse}
  sphere {<0,-0.3,-1.04>,0.04}
  sphere {<0.5,0.5,-1.04>,0.04}
  cutaway_textures
}

object {MyObjectWithSpheres}


Post a reply to this message

From: Chris B
Subject: Re: Trace with pigments
Date: 5 Jul 2008 10:35:04
Message: <486f8698$1@news.povray.org>
"Chris B" <nom### [at] nomailcom> wrote in message 
news:486f850b@news.povray.org...
> The downside to this hack is that your camera ends up technically 'inside' 
> the object which will mess up interior features like media if you want to 
> use them in the same scene.

Actually I just realised that the following small change should remove or 
minimalise the impact of that downside:

Regards,
Chris B.


camera {location <0,0,-4> look_at 0 }
light_source {<-1,0 ,-4>, rgb 3}

#declare MyObject = intersection {
  box {-1,1 pigment {agate scale 2} }
  sphere {0,1.25 pigment {agate scale 2}}
}

#declare MyObjectWithSpheres = difference {
  object {MyObject inverse}
  sphere {<0,-0.3,-1.04>,0.04}
  sphere {<0.5,0.5,-1.04>,0.04}
  cutaway_textures
}

intersection {
  sphere {0,1.33 pigment {rgbt 1}}
  object {MyObjectWithSpheres}
}


Post a reply to this message

From: Gyscos
Subject: Re: Trace with pigments
Date: 5 Jul 2008 11:05:04
Message: <web.486f8d6ec03ce0661ba56a630@news.povray.org>
Humm, on my PC it doens't work, the spheres are black (I use POV-ray v3.7 b27 so
maybe it doesn't support cutaway_textures...)

Are you sure the box stores the texture of every point of the space, not only on
its surface ?...

What I first wanted to do was to put spheres on the object without the object
itself (like a wireview with spheres instead of wires).

Would something like :

object {
  difference {
    union {
      object { MyObject }
      object { MyObject invert }
    }
    sphere { TheSpheresToPut }
    cutaway_texture
  }
invert
}

work ?


Post a reply to this message

From: Chris B
Subject: Re: Trace with pigments
Date: 5 Jul 2008 11:41:55
Message: <486f9643@news.povray.org>
"Gyscos" <gys### [at] gmailcom> wrote in message 
news:web.486f8d6ec03ce0661ba56a630@news.povray.org...
> Humm, on my PC it doens't work, the spheres are black (I use POV-ray v3.7 
> b27 so
> maybe it doesn't support cutaway_textures...)
>

Oh that's a pity. I'm on 3.6 on Windows and it works for me. I found that 
the spheres are black if they end up on the outside of the object, rather 
than inside it, hence having to use the inverse of the object. Do you get an 
error in the message stream saying that an there's a missing pigment?

> Are you sure the box stores the texture of every point of the space, not 
> only on
> its surface ?...

When a ray hits a surface it evaluates the texture to find the appropriate 
value for that point in 3D space using the texture that applies to that part 
of the object. It shouldn't really care where that surface is on the object.

>
> What I first wanted to do was to put spheres on the object without the 
> object
> itself (like a wireview with spheres instead of wires).
>

That would be easy if you could isolate the texture used for the object. 
Would that really be too difficult to do?

> Would something like :
>
> object {
>  difference {
>    union {
>      object { MyObject }
>      object { MyObject invert }
>    }
>    sphere { TheSpheresToPut }
>    cutaway_texture
>  }
> invert
> }
>
> work ?

No. I think you'd end up with a degenerate object.

Regards,
Chris B.


Post a reply to this message

From: Alain
Subject: Re: Trace with pigments
Date: 6 Jul 2008 12:00:33
Message: <4870ec21$1@news.povray.org>
Gyscos nous illumina en ce 2008-07-05 11:04 -->
> Humm, on my PC it doens't work, the spheres are black (I use POV-ray v3.7 b27 so
> maybe it doesn't support cutaway_textures...)
> 
> Are you sure the box stores the texture of every point of the space, not only on
> its surface ?...
The textures are defined in space. You can think of the objects as been carved 
out of the texture.
> 
> What I first wanted to do was to put spheres on the object without the object
> itself (like a wireview with spheres instead of wires).
If the object you defined and traced toward is not placed in the scene, it will 
never show.
> 
> Would something like :
> 
> object {
>   difference {
>     union {
>       object { MyObject }
>       object { MyObject invert }
>     }
>     sphere { TheSpheresToPut }
>     cutaway_texture
>   }
> invert
> }
> 
> work ?
> 
> 
The difference of any object with it's inverse is empty.
The union of any object with it's inverse is the whole space.
In your example, the union is useless and the whole thing is the same as:
sphere { TheSpheresToPut hollow}
but more complicated, and slower as you get an unbound object.

If you want to get rid of the warning about the camera been inside an object 
and/or use some media, just add the "hollow" keyword to your object.

A thing that you can do, is to define your object larger by the radius of your 
spheres and allpy the pigment. As you trace, you use eval_pigment at the points 
returned by the trace. This will return the pigment at the traced location. 
Place your sphere there and apply the returned pigment to that sphere, repeat 
for each sphere. This will give you spheres that are a solid colour. You need 
all your spheres to have the same radius. It will require more memory as each 
sphere will have it's own texture block. It will be fast as the bounding will be 
effecient, one tight and distinct bounding box for each sphere.

Another way is to define a box that is the dimention of the bounding box of your 
object plus the diameter of the largest sphere. Use an intersection of that box 
and all your spheres. Apply your texture to the whole intersection. It will use 
less memory, and the spheres will show some gradient. The rendering will be 
slower as you will have many overlaping bounding boxes, each bounding box will 
cover the whole thing and overlap every other.


-- 
Alain
-------------------------------------------------
Methodist: It's not so bad if shit happens, as long as you serve grape juice 
with it.


Post a reply to this message

Goto Latest 10 Messages Next 2 Messages >>>

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