POV-Ray : Newsgroups : povray.general : Polygon masking possibility? Server Time
31 Jul 2024 16:29:31 EDT (-0400)
  Polygon masking possibility? (Message 1 to 8 of 8)  
From: Vaclav Cermak
Subject: Polygon masking possibility?
Date: 27 Oct 2006 04:09:55
Message: <4541bed3$1@news.povray.org>
Hello,

   I'am now working on some bitmap based grass, bush etc. I'am trying to 
place a lot of rectangles with bitmap grass patches on the groud. 
Bitmaps are partially transparent. The result is, that I have a lot of 
rectangles on every ray hittng the ground, so I must set very high 
max_trace_level to render it correctly...

My idea is to create some "masked_polygon", or to add a "mask" into the 
polygon and use this mask when determing, if some ray hits the polygon. 
When the ray hits completely transparent part of the polygon, consider 
it as "no hit" and return hits only with full opaque or semi-transparent 
parts. Something like

#declare BitmapPig = pigment {
   image_map {png "something.png"}
}

polygon {
   5, <0, 0>, <1, 0>, <1, 1>, <0, 1>, <0, 0>
   mask {BitmapPig}
   pigment {BitmapPig}
}

This will remove the neccesasrity of high max_trace_level and I think, 
that it can be faster, than shooting new ray from every hitted, but 
completely transparent part of polygons.

What do you think about this?

Regards

Vaclav


Post a reply to this message

From: KalleK
Subject: Re: Polygon masking possibility?
Date: 27 Oct 2006 07:08:08
Message: <4541e898$1@news.povray.org>
Vaclav Cermak schrieb:
> 
> Hello,
> 
> My idea is to create some "masked_polygon", or to add a "mask" into the 
> polygon and use this mask when determing, if some ray hits the polygon. 
> When the ray hits completely transparent part of the polygon, consider 
> it as "no hit" and return hits only with full opaque or semi-transparent 
> parts. Something like
> 
> #declare BitmapPig = pigment {
>   image_map {png "something.png"}
> }
> 
> polygon {
>   5, <0, 0>, <1, 0>, <1, 1>, <0, 1>, <0, 0>
>   mask {BitmapPig}
>   pigment {BitmapPig}
> }
> 
> This will remove the neccesasrity of high max_trace_level and I think, 
> that it can be faster, than shooting new ray from every hitted, but 
> completely transparent part of polygons.
> 
> What do you think about this?

Not the answer, but you might consider bounding boxes (see "bounded_by" 
pov-help 3.4.9.2), if your bitmap doesn't vary much. So you can clip 
parts of the polygons that are always transparent. But you have to 
declare a nice bounding-shape...


KK


Post a reply to this message

From: John VanSickle
Subject: Re: Polygon masking possibility?
Date: 27 Oct 2006 20:06:27
Message: <45429f03$1@news.povray.org>
Vaclav Cermak wrote:

> 
> Hello,
> 
>   I'am now working on some bitmap based grass, bush etc. I'am trying to 
> place a lot of rectangles with bitmap grass patches on the groud. 
> Bitmaps are partially transparent. The result is, that I have a lot of 
> rectangles on every ray hittng the ground, so I must set very high 
> max_trace_level to render it correctly...

Make a mesh for each unique piece of bitmap.  Don't put triangles except 
where there's grass.

Color the ground like dirt.

When I want to do grass, I generally make a mesh (or a few meshes), 
representing a patch of grass.  The I copy it a bunch of times, with 
rotation and skewing, to eliminate a tiled appearance.

Regards,
John


Post a reply to this message

From: Tek
Subject: Re: Polygon masking possibility?
Date: 28 Oct 2006 05:15:24
Message: <45431fac$1@news.povray.org>
Speaking from a technical point of view I don't think it's possible. It's a 
good idea but pov can only check the mask for a polygon after computing a 
ray intersection with that polygon, meaning it's doing exactly the same 
amount of work as just having a high max_trace_level.

-- 
Tek
http://evilsuperbrain.com

"Vaclav Cermak" <dis### [at] disnelcom> wrote in message 
news:4541bed3$1@news.povray.org...
>
> Hello,
>
>   I'am now working on some bitmap based grass, bush etc. I'am trying to 
> place a lot of rectangles with bitmap grass patches on the groud. Bitmaps 
> are partially transparent. The result is, that I have a lot of rectangles 
> on every ray hittng the ground, so I must set very high max_trace_level to 
> render it correctly...
>
> My idea is to create some "masked_polygon", or to add a "mask" into the 
> polygon and use this mask when determing, if some ray hits the polygon. 
> When the ray hits completely transparent part of the polygon, consider it 
> as "no hit" and return hits only with full opaque or semi-transparent 
> parts. Something like
>
> #declare BitmapPig = pigment {
>   image_map {png "something.png"}
> }
>
> polygon {
>   5, <0, 0>, <1, 0>, <1, 1>, <0, 1>, <0, 0>
>   mask {BitmapPig}
>   pigment {BitmapPig}
> }
>
> This will remove the neccesasrity of high max_trace_level and I think, 
> that it can be faster, than shooting new ray from every hitted, but 
> completely transparent part of polygons.
>
> What do you think about this?
>
> Regards
>
> Vaclav
>


Post a reply to this message

From: Vaclav Cermak
Subject: Re: Polygon masking possibility?
Date: 28 Oct 2006 07:00:16
Message: <45433840@news.povray.org>
But then there is no need to have high max_trace_level at all, this can 
lead to faster rendering of other parts of the scene.

I don't know POV internal structure well, but probably you are right, 
POV must first determine, if the ray intersects that polygon and then 
look, if the polygon is transparent at the intersection point or not. 
But all overhead caused by need of shooting new ray is removed (I don't 
know, how much it is, can be saved some work with etc bounding??).

V.

Tek wrote:
> Speaking from a technical point of view I don't think it's possible. It's a 
> good idea but pov can only check the mask for a polygon after computing a 
> ray intersection with that polygon, meaning it's doing exactly the same 
> amount of work as just having a high max_trace_level.
>


Post a reply to this message

From: Vaclav Cermak
Subject: Re: Polygon masking possibility?
Date: 28 Oct 2006 07:04:45
Message: <4543394d$1@news.povray.org>
> Make a mesh for each unique piece of bitmap.  Don't put triangles except 
> where there's grass.

Godd idea, will try it.

> 
> Color the ground like dirt.
> 
> When I want to do grass, I generally make a mesh (or a few meshes), 
> representing a patch of grass.  The I copy it a bunch of times, with 
> rotation and skewing, to eliminate a tiled appearance.

Also good idea, but such a grass is very slow with radiosity, bitmap one 
looks promising in my current tests. It is also slow, but acceptable ;-))

> 
> Regards,
> John


Post a reply to this message

From: Daniel Hulme
Subject: Re: Polygon masking possibility?
Date: 28 Oct 2006 07:11:18
Message: <20061028121119.2ef3e731@mekanori.mon.istic.org>
>I don't know POV internal structure well, but probably you are right, 
>POV must first determine, if the ray intersects that polygon and then 
>look, if the polygon is transparent at the intersection point or not. 
>But all overhead caused by need of shooting new ray is removed (I
>don't know, how much it is, can be saved some work with etc
>bounding??).

The only cost saved is that of initializing a new RAY structure in
memory, which is tiny. However, your scheme would mean that every
time a ray-object intersection is performed, POV-Ray has to check
whether there is a mask object, and of course it increases code size
slightly. This would slow down the general case (where there is no
mask) just as much as it speeds up this particular case, and as the
general case is more common, it results in an overall slow-down.

-- 
Sufficiently advanced humour is indistinguishable from tedium.
corollary:
Humour distinguishable from tedium is insufficiently advanced.
http://surreal.istic.org/          Calm down, it's only ones and zeroes.


Post a reply to this message

From: Alain
Subject: Re: Polygon masking possibility?
Date: 28 Oct 2006 17:27:19
Message: <4543cb37$1@news.povray.org>
Vaclav Cermak nous apporta ses lumieres en ce 28/10/2006 07:03:

> But then there is no need to have high max_trace_level at all, this can 
> lead to faster rendering of other parts of the scene.

> I don't know POV internal structure well, but probably you are right, 
> POV must first determine, if the ray intersects that polygon and then 
> look, if the polygon is transparent at the intersection point or not. 
> But all overhead caused by need of shooting new ray is removed (I don't 
> know, how much it is, can be saved some work with etc bounding??).

> V.

> Tek wrote:
>> Speaking from a technical point of view I don't think it's possible. 
>> It's a good idea but pov can only check the mask for a polygon after 
>> computing a ray intersection with that polygon, meaning it's doing 
>> exactly the same amount of work as just having a high max_trace_level.

In that case, you can use adc_bailout with a slightly smaller value than the 
default (about 1/256).
That way, you don't always go to the max_trace_level. Also, if there is no 
reflection nor refraction, or only refraction or only reflection, you stay with 
only one ray, meaning minimal slowdown.

-- 
Alain
-------------------------------------------------
If you choke a Smurf, what colour does he go!


Post a reply to this message

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