Generating alpha channels using vwrays and rtrace

Hi Iebele,

Wouldn't it be simpler to introduce an alias for the material you want and set it to "glow" with the desired high brightness? Take out any other light sources, turn off ambient bounces and ambient value, and render the image. It would be a lot faster that way.

Barring that, you can do what you want like so:

vwrays -ff -vf test.vp -pa 0 -x $XRES -y $YRES | rtrace -h -x $XRES -y $YRES -ffa -om test.oct \
  > sed -e 's/^window$/1/' -e 's/^[^1].*$/0/' | pvalue -h -r -b -d -y $YRES +x $XRES > mask.hdr

You need to set your x and y resolution explicitly because pvalue needs them in a form other than the one vwrays -d produces. This also assumes you have sed and none of your material names starts with the numeral '1'.

Cheers,
-Greg

P.S. Seems Jack beat me to this....

···

From: Iebele Abel <[email protected]>
Date: February 24, 2012 11:24:43 AM PST

Hi group,

Whilst finding a method to create alpha channels for my rendered image, I'm playing with vwrays and rtrace. What I intend is to create an image in which
geometry modified by a particular modifier is rendered white, whilst the geometry modified otherwise is rendered black. The command below comes close to this, it has as output the modifiers for each surface hit:

vwrays -ff -vf test.vp -x 100 -y 100 | rtrace `vwrays -d -vf test.vp -x 100 -y 100` -ffa -om test.oct | more

Output of this command is like:
...
floor
floor
floor
window
window
etc...

Now I want that, for example, each occurrence of "window" sends 3 "bright" RGBE primaries to stdout, and every other string sends 3 "dark" RGBE primaries to stdout. I can do this by writing a small program (instead of piping to 'more' as in the example above), but I wondered if there is a method using native Radiance tools to do it.

In pseudo code (bold) I think about something like this (where 1 represents a value considered as white in the output, and 0 represents black) :

vwrays -ff -vf test.vp -x 100 -y 100 | rtrace `vwrays -d -vf test.vp -x 100 -y 100` -ffa -om test.oct | if (stdin == "window") fprintf(stdout, "1 1 1" ); else fprintf ( stdout, "0,0,0"); | ra_tiff - alpha.tif

So my questions are:
1. how do I format the output of stdout as Radiance RGBE?
2. can I do this using native Radiance tools?

Thanks for any hints.

-Iebele

must disagree (oi oi oi!)

glow is normal sensitive so not an option most of the time.

better to use black and white and av 1 1 1 (no sky to cut reflections)

G

···

On 24 Feb 2012, at 19:54, Greg Ward wrote:

Hi Iebele,

Wouldn't it be simpler to introduce an alias for the material you want and set it to "glow" with the desired high brightness? Take out any other light sources, turn off ambient bounces and ambient value, and render the image. It would be a lot faster that way.

Barring that, you can do what you want like so:

vwrays -ff -vf test.vp -pa 0 -x $XRES -y $YRES | rtrace -h -x $XRES -y $YRES -ffa -om test.oct \
  > sed -e 's/^window$/1/' -e 's/^[^1].*$/0/' | pvalue -h -r -b -d -y $YRES +x $XRES > mask.hdr

You need to set your x and y resolution explicitly because pvalue needs them in a form other than the one vwrays -d produces. This also assumes you have sed and none of your material names starts with the numeral '1'.

Cheers,
-Greg

P.S. Seems Jack beat me to this....

From: Iebele Abel <[email protected]>
Date: February 24, 2012 11:24:43 AM PST

Hi group,

Whilst finding a method to create alpha channels for my rendered image, I'm playing with vwrays and rtrace. What I intend is to create an image in which
geometry modified by a particular modifier is rendered white, whilst the geometry modified otherwise is rendered black. The command below comes close to this, it has as output the modifiers for each surface hit:

vwrays -ff -vf test.vp -x 100 -y 100 | rtrace `vwrays -d -vf test.vp -x 100 -y 100` -ffa -om test.oct | more

Output of this command is like:
...
floor
floor
floor
window
window
etc...

Now I want that, for example, each occurrence of "window" sends 3 "bright" RGBE primaries to stdout, and every other string sends 3 "dark" RGBE primaries to stdout. I can do this by writing a small program (instead of piping to 'more' as in the example above), but I wondered if there is a method using native Radiance tools to do it.

In pseudo code (bold) I think about something like this (where 1 represents a value considered as white in the output, and 0 represents black) :

vwrays -ff -vf test.vp -x 100 -y 100 | rtrace `vwrays -d -vf test.vp -x 100 -y 100` -ffa -om test.oct | if (stdin == "window") fprintf(stdout, "1 1 1" ); else fprintf ( stdout, "0,0,0"); | ra_tiff - alpha.tif

So my questions are:
1. how do I format the output of stdout as Radiance RGBE?
2. can I do this using native Radiance tools?

Thanks for any hints.

-Iebele

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

yes, this was :slight_smile:
(sorry missed your reply)
G

···

On 24 Feb 2012, at 19:45, Jack de Valpine wrote:

Hi Iebele,

I have done a few different things to achieve this over the years. The one that come most readily to mind is to prep an alternate material file with a black (0 0 0) and white (1 1 1) material assigned as needed. This is one reason the "alias" material option can be quite handy when assigning materials to geometry! With the correct black/white materials this can be rendered out very quickly with -ab 0 and -av 1 1 1.

I have also done something where (with scripting) you can specify a material name that then get white and everything else gets black. It has been a while so I do not quite remember off hand, but I think that this can also be setup as a big pipe in radiance and using radiance's functional language.

The first way is pretty easy and if you need to do lots of it then it is possible to script the switching of material assignments. One challenge though is that if you use instances (frozen octrees) you need to remember to assign a material accordingly. Another challenge is thinking about transparencies that might need to be captured in the process...

Regards,

-Jack
--
# Jack de Valpine
# president
#
# visarc incorporated
# http://www.visarc.com
#
# channeling technology for superior design and construction

On 2/24/2012 2:24 PM, Iebele Abel wrote:

Hi group,

Whilst finding a method to create alpha channels for my rendered image, I'm playing with vwrays and rtrace. What I intend is to create an image in which
geometry modified by a particular modifier is rendered white, whilst the geometry modified otherwise is rendered black. The command below comes close to this, it has as output the modifiers for each surface hit:

vwrays -ff -vf test.vp -x 100 -y 100 | rtrace `vwrays -d -vf test.vp -x 100 -y 100` -ffa -om test.oct | more

Output of this command is like:
...
floor
floor
floor
window
window
etc...

Now I want that, for example, each occurrence of "window" sends 3 "bright" RGBE primaries to stdout, and every other string sends 3 "dark" RGBE primaries to stdout. I can do this by writing a small program (instead of piping to 'more' as in the example above), but I wondered if there is a method using native Radiance tools to do it.

In pseudo code (bold) I think about something like this (where 1 represents a value considered as white in the output, and 0 represents black) :

vwrays -ff -vf test.vp -x 100 -y 100 | rtrace `vwrays -d -vf test.vp -x 100 -y 100` -ffa -om test.oct | if (stdin == "window") fprintf(stdout, "1 1 1" ); else fprintf ( stdout, "0,0,0"); | ra_tiff - alpha.tif

So my questions are:
1. how do I format the output of stdout as Radiance RGBE?
2. can I do this using native Radiance tools?

Thanks for any hints.

-Iebele

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

You mean glow isn't visible from the back side, right? The output from the front side is the same in all directions, but the back side emits 0. I didn't think of this issue, but I suppose it matters for a lot of scenes... Good point!

-Greg

···

From: giulio antonutto <[email protected]>
Date: February 24, 2012 1:29:20 PM PST

must disagree (oi oi oi!)

glow is normal sensitive so not an option most of the time.

better to use black and white and av 1 1 1 (no sky to cut reflections)

G

On 24 Feb 2012, at 19:54, Greg Ward wrote:

Hi Iebele,

Wouldn't it be simpler to introduce an alias for the material you want and set it to "glow" with the desired high brightness? Take out any other light sources, turn off ambient bounces and ambient value, and render the image. It would be a lot faster that way.

Barring that, you can do what you want like so:

vwrays -ff -vf test.vp -pa 0 -x $XRES -y $YRES | rtrace -h -x $XRES -y $YRES -ffa -om test.oct \
  > sed -e 's/^window$/1/' -e 's/^[^1].*$/0/' | pvalue -h -r -b -d -y $YRES +x $XRES > mask.hdr

You need to set your x and y resolution explicitly because pvalue needs them in a form other than the one vwrays -d produces. This also assumes you have sed and none of your material names starts with the numeral '1'.

Cheers,
-Greg

P.S. Seems Jack beat me to this....

Yes, that is it.
Because most of the time people building the 3d do not pay attention to normals…
so if you are using radiance and rely on model coming from elsewhere, either you have to spend a long time flipping polygons or you use another route.
which sometimes is running two things (one xform'ed -I) and add them up or simply use the black/white and av trick
:slight_smile:
G

···

On 24 Feb 2012, at 21:45, Greg Ward wrote:

You mean glow isn't visible from the back side, right? The output from the front side is the same in all directions, but the back side emits 0. I didn't think of this issue, but I suppose it matters for a lot of scenes... Good point!

-Greg

From: giulio antonutto <[email protected]>
Date: February 24, 2012 1:29:20 PM PST

must disagree (oi oi oi!)

glow is normal sensitive so not an option most of the time.

better to use black and white and av 1 1 1 (no sky to cut reflections)

G

On 24 Feb 2012, at 19:54, Greg Ward wrote:

Hi Iebele,

Wouldn't it be simpler to introduce an alias for the material you want and set it to "glow" with the desired high brightness? Take out any other light sources, turn off ambient bounces and ambient value, and render the image. It would be a lot faster that way.

Barring that, you can do what you want like so:

vwrays -ff -vf test.vp -pa 0 -x $XRES -y $YRES | rtrace -h -x $XRES -y $YRES -ffa -om test.oct \
  > sed -e 's/^window$/1/' -e 's/^[^1].*$/0/' | pvalue -h -r -b -d -y $YRES +x $XRES > mask.hdr

You need to set your x and y resolution explicitly because pvalue needs them in a form other than the one vwrays -d produces. This also assumes you have sed and none of your material names starts with the numeral '1'.

Cheers,
-Greg

P.S. Seems Jack beat me to this....

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

I kinda like Iebele's method approach better than using black and white materials. Using rtrace -om you can create alpha channels using the same octree that you use for a rendering. And you can also create many alpha images for different materials with the same model. It just seems less work than fussing with material files.

Iebele, the main thing you're missing is pvalue to convert the data stream to image format. I also used awk for the if statement. Here's a complete command:

vwrays -ff -vf test.vp -x 100 -y 100 | \
  rtrace `vwrays -d -vf test.vp -x 100 -y 100` -ffa -om test.oct | \
  awk '{if($1=="window") print 1.0; else print 0.0;}' | \
  pvalue +x 500 -y 500 -h -da -b -r | \
  ra_tiff - alpha.tif

Andy

···

On Feb 24, 2012, at 1:29 PM, giulio antonutto wrote:

yes, this was :slight_smile:
(sorry missed your reply)
G

On 24 Feb 2012, at 19:45, Jack de Valpine wrote:

Hi Iebele,

I have done a few different things to achieve this over the years. The one that come most readily to mind is to prep an alternate material file with a black (0 0 0) and white (1 1 1) material assigned as needed. This is one reason the "alias" material option can be quite handy when assigning materials to geometry! With the correct black/white materials this can be rendered out very quickly with -ab 0 and -av 1 1 1.

I have also done something where (with scripting) you can specify a material name that then get white and everything else gets black. It has been a while so I do not quite remember off hand, but I think that this can also be setup as a big pipe in radiance and using radiance's functional language.

The first way is pretty easy and if you need to do lots of it then it is possible to script the switching of material assignments. One challenge though is that if you use instances (frozen octrees) you need to remember to assign a material accordingly. Another challenge is thinking about transparencies that might need to be captured in the process...

Regards,

-Jack
--
# Jack de Valpine
# president
#
# visarc incorporated
# http://www.visarc.com
#
# channeling technology for superior design and construction

On 2/24/2012 2:24 PM, Iebele Abel wrote:

Hi group,

Whilst finding a method to create alpha channels for my rendered image, I'm playing with vwrays and rtrace. What I intend is to create an image in which
geometry modified by a particular modifier is rendered white, whilst the geometry modified otherwise is rendered black. The command below comes close to this, it has as output the modifiers for each surface hit:

vwrays -ff -vf test.vp -x 100 -y 100 | rtrace `vwrays -d -vf test.vp -x 100 -y 100` -ffa -om test.oct | more

Output of this command is like:
...
floor
floor
floor
window
window
etc...

Now I want that, for example, each occurrence of "window" sends 3 "bright" RGBE primaries to stdout, and every other string sends 3 "dark" RGBE primaries to stdout. I can do this by writing a small program (instead of piping to 'more' as in the example above), but I wondered if there is a method using native Radiance tools to do it.

In pseudo code (bold) I think about something like this (where 1 represents a value considered as white in the output, and 0 represents black) :

vwrays -ff -vf test.vp -x 100 -y 100 | rtrace `vwrays -d -vf test.vp -x 100 -y 100` -ffa -om test.oct | if (stdin == "window") fprintf(stdout, "1 1 1" ); else fprintf ( stdout, "0,0,0"); | ra_tiff - alpha.tif

So my questions are:
1. how do I format the output of stdout as Radiance RGBE?
2. can I do this using native Radiance tools?

Thanks for any hints.

-Iebele

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

Andy -still- rules
:slight_smile:

···

On 24 Feb 2012, at 22:25, Andy McNeil wrote:

I kinda like Iebele's method approach better than using black and white materials. Using rtrace -om you can create alpha channels using the same octree that you use for a rendering. And you can also create many alpha images for different materials with the same model. It just seems less work than fussing with material files.

Iebele, the main thing you're missing is pvalue to convert the data stream to image format. I also used awk for the if statement. Here's a complete command:

vwrays -ff -vf test.vp -x 100 -y 100 | \
  rtrace `vwrays -d -vf test.vp -x 100 -y 100` -ffa -om test.oct | \
  awk '{if($1=="window") print 1.0; else print 0.0;}' | \
  pvalue +x 500 -y 500 -h -da -b -r | \
  ra_tiff - alpha.tif

Andy

On Feb 24, 2012, at 1:29 PM, giulio antonutto wrote:

yes, this was :slight_smile:
(sorry missed your reply)
G

On 24 Feb 2012, at 19:45, Jack de Valpine wrote:

Hi Iebele,

I have done a few different things to achieve this over the years. The one that come most readily to mind is to prep an alternate material file with a black (0 0 0) and white (1 1 1) material assigned as needed. This is one reason the "alias" material option can be quite handy when assigning materials to geometry! With the correct black/white materials this can be rendered out very quickly with -ab 0 and -av 1 1 1.

I have also done something where (with scripting) you can specify a material name that then get white and everything else gets black. It has been a while so I do not quite remember off hand, but I think that this can also be setup as a big pipe in radiance and using radiance's functional language.

The first way is pretty easy and if you need to do lots of it then it is possible to script the switching of material assignments. One challenge though is that if you use instances (frozen octrees) you need to remember to assign a material accordingly. Another challenge is thinking about transparencies that might need to be captured in the process...

Regards,

-Jack
--
# Jack de Valpine
# president
#
# visarc incorporated
# http://www.visarc.com
#
# channeling technology for superior design and construction

On 2/24/2012 2:24 PM, Iebele Abel wrote:

Hi group,

Whilst finding a method to create alpha channels for my rendered image, I'm playing with vwrays and rtrace. What I intend is to create an image in which
geometry modified by a particular modifier is rendered white, whilst the geometry modified otherwise is rendered black. The command below comes close to this, it has as output the modifiers for each surface hit:

vwrays -ff -vf test.vp -x 100 -y 100 | rtrace `vwrays -d -vf test.vp -x 100 -y 100` -ffa -om test.oct | more

Output of this command is like:
...
floor
floor
floor
window
window
etc...

Now I want that, for example, each occurrence of "window" sends 3 "bright" RGBE primaries to stdout, and every other string sends 3 "dark" RGBE primaries to stdout. I can do this by writing a small program (instead of piping to 'more' as in the example above), but I wondered if there is a method using native Radiance tools to do it.

In pseudo code (bold) I think about something like this (where 1 represents a value considered as white in the output, and 0 represents black) :

vwrays -ff -vf test.vp -x 100 -y 100 | rtrace `vwrays -d -vf test.vp -x 100 -y 100` -ffa -om test.oct | if (stdin == "window") fprintf(stdout, "1 1 1" ); else fprintf ( stdout, "0,0,0"); | ra_tiff - alpha.tif

So my questions are:
1. how do I format the output of stdout as Radiance RGBE?
2. can I do this using native Radiance tools?

Thanks for any hints.

-Iebele

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

Oops! The resolution I gave to pvalue doesn't match the resolution in vwrays and rtrace. I was testing a higher resolution so I could see detail in the image, but forgot to change it back to 100 after pasting into the email. Here's the correct command:

vwrays -ff -vf test.vp -x 100 -y 100 | \
  rtrace `vwrays -d -vf test.vp -x 100 -y 100` -ffa -om test.oct | \
  awk '{if($1=="window") print 1.0; else print 0.0;}' | \
  pvalue +x 100 -y 100 -h -da -b -r | \
  ra_tiff - alpha.tif

Also, you might be able to use rcalc in place of awk. It depends on whether rcalc can compare strings in an if statement. I don't know enough about rcalc to know if it's possible.

Andy

···

On Feb 24, 2012, at 2:25 PM, Andy McNeil wrote:

I kinda like Iebele's method approach better than using black and white materials. Using rtrace -om you can create alpha channels using the same octree that you use for a rendering. And you can also create many alpha images for different materials with the same model. It just seems less work than fussing with material files.

Iebele, the main thing you're missing is pvalue to convert the data stream to image format. I also used awk for the if statement. Here's a complete command:

vwrays -ff -vf test.vp -x 100 -y 100 | \
  rtrace `vwrays -d -vf test.vp -x 100 -y 100` -ffa -om test.oct | \
  awk '{if($1=="window") print 1.0; else print 0.0;}' | \
  pvalue +x 500 -y 500 -h -da -b -r | \
  ra_tiff - alpha.tif

Andy

On Feb 24, 2012, at 1:29 PM, giulio antonutto wrote:

yes, this was :slight_smile:
(sorry missed your reply)
G

On 24 Feb 2012, at 19:45, Jack de Valpine wrote:

Hi Iebele,

I have done a few different things to achieve this over the years. The one that come most readily to mind is to prep an alternate material file with a black (0 0 0) and white (1 1 1) material assigned as needed. This is one reason the "alias" material option can be quite handy when assigning materials to geometry! With the correct black/white materials this can be rendered out very quickly with -ab 0 and -av 1 1 1.

I have also done something where (with scripting) you can specify a material name that then get white and everything else gets black. It has been a while so I do not quite remember off hand, but I think that this can also be setup as a big pipe in radiance and using radiance's functional language.

The first way is pretty easy and if you need to do lots of it then it is possible to script the switching of material assignments. One challenge though is that if you use instances (frozen octrees) you need to remember to assign a material accordingly. Another challenge is thinking about transparencies that might need to be captured in the process...

Regards,

-Jack
--
# Jack de Valpine
# president
#
# visarc incorporated
# http://www.visarc.com
#
# channeling technology for superior design and construction

On 2/24/2012 2:24 PM, Iebele Abel wrote:

Hi group,

Whilst finding a method to create alpha channels for my rendered image, I'm playing with vwrays and rtrace. What I intend is to create an image in which
geometry modified by a particular modifier is rendered white, whilst the geometry modified otherwise is rendered black. The command below comes close to this, it has as output the modifiers for each surface hit:

vwrays -ff -vf test.vp -x 100 -y 100 | rtrace `vwrays -d -vf test.vp -x 100 -y 100` -ffa -om test.oct | more

Output of this command is like:
...
floor
floor
floor
window
window
etc...

Now I want that, for example, each occurrence of "window" sends 3 "bright" RGBE primaries to stdout, and every other string sends 3 "dark" RGBE primaries to stdout. I can do this by writing a small program (instead of piping to 'more' as in the example above), but I wondered if there is a method using native Radiance tools to do it.

In pseudo code (bold) I think about something like this (where 1 represents a value considered as white in the output, and 0 represents black) :

vwrays -ff -vf test.vp -x 100 -y 100 | rtrace `vwrays -d -vf test.vp -x 100 -y 100` -ffa -om test.oct | if (stdin == "window") fprintf(stdout, "1 1 1" ); else fprintf ( stdout, "0,0,0"); | ra_tiff - alpha.tif

So my questions are:
1. how do I format the output of stdout as Radiance RGBE?
2. can I do this using native Radiance tools?

Thanks for any hints.

-Iebele

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

Well, thanks a lot folks, for your comments on this. Jacks suggestion has
been used over years, but recently we started using tmeshes, and because of
that parts of the octree is frozen. So we had to find some other solution,
without messing around with multiple material files for each tmesh. I've
tried both Gregs and Andys suggestions and they both work really smooth.
When running the command in a bash script I found awk performing about
25-30% faster as sed. See below how the commands are put in bash (not
checking argument values etc.) and their timed outputs pasted thereafter.

There remain some issues in the script when rendering non-square images
(like 1920x1080 HD), but that will be worked out. All together this has all
been very helpful,

Cheers,

Iebele

--- ralpha script ---

#!/bin/bash

if ( ! getopts ":v:m:x:y:o:" opt ); then
        echo "Usage: `basename $0` -v viewfile -m modifier -x xres -y yres
-o octree" >&2
        exit
fi

while getopts "v:m:x:y:o:" opt; do
        case $opt in
        v) viewfile=$OPTARG
                ;;
        m) modifier=$OPTARG
                ;;
        x) xres=$OPTARG
                ;;
        y) yres=$OPTARG
                ;;
        o) octree=$OPTARG
                ;;
        esac
done

echo "using awk" >&2
time vwrays -ff -vf $viewfile -x $xres -y $yres | \
        rtrace `vwrays -d -vf $viewfile -x $xres -y $yres` -ffa -om
$octree | \
        awk -v v1=$modifier '{if( $1 == v1 ) print 1.0; else print 0.0;}'
> \
        pvalue +x $xres -y $yres -h -da -b -r

echo "using sed" >&2
time vwrays -ff -vf $viewfile -pa 0 -x $xres -y $yres | \
        rtrace -h -x $xres -y $yres -ffa -om $octree | \
        sed -e "s/^$modifier/1/" -e "s/^[^1].*$/0/" | \
        pvalue -h -r -b -d -x $xres -y $yres

--- output --

./ralpha -v hermitage_brug01.vp -m water -x 16000 -y 16000 -o export.oct >
/dev/null

using awk
real 5m21.743s
user 8m51.873s
sys 0m7.116s

using sed
real 7m55.060s
user 13m41.563s
sys 0m5.199s

···

2012/2/25 Andy McNeil <[email protected]>

Oops! The resolution I gave to pvalue doesn't match the resolution in
vwrays and rtrace. I was testing a higher resolution so I could see detail
in the image, but forgot to change it back to 100 after pasting into the
email. Here's the correct command:

vwrays -ff -vf test.vp -x 100 -y 100 | \
rtrace `vwrays -d -vf test.vp -x 100 -y 100` -ffa -om test.oct | \
awk '{if($1=="window") print 1.0; else print 0.0;}' | \
pvalue +x 100 -y 100 -h -da -b -r | \
ra_tiff - alpha.tif

Also, you might be able to use rcalc in place of awk. It depends on
whether rcalc can compare strings in an if statement. I don't know enough
about rcalc to know if it's possible.

Andy

On Feb 24, 2012, at 2:25 PM, Andy McNeil wrote:

I kinda like Iebele's method approach better than using black and white
materials. Using rtrace -om you can create alpha channels using the same
octree that you use for a rendering. And you can also create many alpha
images for different materials with the same model. It just seems less
work than fussing with material files.

Iebele, the main thing you're missing is pvalue to convert the data stream
to image format. I also used awk for the if statement. Here's a complete
command:

vwrays -ff -vf test.vp -x 100 -y 100 | \
rtrace `vwrays -d -vf test.vp -x 100 -y 100` -ffa -om test.oct | \
* awk '{if($1=="window") print 1.0; else print 0.0;}' *| \
* pvalue +x 500 -y 500 -h -da -b -r *| \
ra_tiff - alpha.tif

Andy

On Feb 24, 2012, at 1:29 PM, giulio antonutto wrote:

yes, this was :slight_smile:
(sorry missed your reply)
G

On 24 Feb 2012, at 19:45, Jack de Valpine wrote:

Hi Iebele,

I have done a few different things to achieve this over the years. The one
that come most readily to mind is to prep an alternate material file with a
black (0 0 0) and white (1 1 1) material assigned as needed. This is one
reason the "alias" material option can be quite handy when assigning
materials to geometry! With the correct black/white materials this can be
rendered out very quickly with -ab 0 and -av 1 1 1.

I have also done something where (with scripting) you can specify a
material name that then get white and everything else gets black. It has
been a while so I do not quite remember off hand, but I think that this can
also be setup as a big pipe in radiance and using radiance's functional
language.

The first way is pretty easy and if you need to do lots of it then it is
possible to script the switching of material assignments. One challenge
though is that if you use instances (frozen octrees) you need to remember
to assign a material accordingly. Another challenge is thinking about
transparencies that might need to be captured in the process...

Regards,

-Jack

--
# Jack de Valpine
# president
#
# visarc incorporated
# http://www.visarc.com
#
# channeling technology for superior design and construction

On 2/24/2012 2:24 PM, Iebele Abel wrote:

Hi group,

Whilst finding a method to create alpha channels for my rendered image,
I'm playing with vwrays and rtrace. What I intend is to create an image in
which
geometry modified by a particular modifier is rendered white, whilst the
geometry modified otherwise is rendered black. The command below comes
close to this, it has as output the modifiers for each surface hit:

vwrays -ff -vf test.vp -x 100 -y 100 | rtrace `vwrays -d -vf test.vp -x
100 -y 100` -ffa -om test.oct | more

Output of this command is like:
...
floor
floor
floor
window
window
etc...

Now I want that, for example, each occurrence of "window" sends 3
"bright" RGBE primaries to stdout, and every other string sends 3 "dark"
RGBE primaries to stdout. I can do this by writing a small program (instead
of piping to 'more' as in the example above), but I wondered if there is a
method using native Radiance tools to do it.

In pseudo code (bold) I think about something like this (where 1
represents a value considered as white in the output, and 0 represents
black) :

vwrays -ff -vf test.vp -x 100 -y 100 | rtrace `vwrays -d -vf test.vp -x
100 -y 100` -ffa -om test.oct | *if (stdin == "window") fprintf(stdout,
"1 1 1" ); else fprintf ( stdout, "0,0,0"); *| ra_tiff - alpha.tif

So my questions are:
1. how do I format the output of stdout as Radiance RGBE?
2. can I do this using native Radiance tools?

Thanks for any hints.

-Iebele

_______________________________________________
Radiance-general mailing [email protected]://www.radiance-online.org/mailman/listinfo/radiance-general

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

Hi Jack,

It would be nice if rcalc were smart about strings, but all it can really do is pass them from one place in the input to another place in the output. It never looks at them, really, and none of the operations supports strings.

Regarding your second idea of including the material along with the value, you can do this with rcalc as written. You would have to go for an ascii output, like so:

vwrays -ff [args] | rtrace -h `vwrays -d [args]` -ffa -omv [rargs] octree | sed -f alphas.txt > alphaval.txt

The file "alphas.txt" would contain something like:

s/^mat1 /0.35 /
s/^mat2 /1.0 /
s/^mat3 /0.0 /
s/^mat4 /0.75 /
[etc.]

This would replace each material with an associated alpha value. From there, you would have to convert to 16-bit RGBA or something if you wanted to load it into Photoshop, and I think you would need a C program for that. Alternately, you could split the file using rcalc and pvalue like so:

rcalc -e '$1=$1' -of alphaval.txt | pvalue -h -y $YRES +x $XRES -df -b > alpha.hdr
rcalc -e '$1=$2;$2=$3;$3=$4' -of alphaval.txt | pvalue -h -y $YRES +x $XRES -df > image.hdr

Photoshop can load, convert, and combine HDR files, though you probably have to change from 32-bit to 16-bit mode when you do. Just make sure not to use any of the fancy tone-mappers when you do....

I'm not sure the above would be any faster than Iebele's current method, but it would avoid separate rtrace steps. This permits you to use the -pj option of vwrays safely, as you won't risk sampling one object in one run and another object in another. (Pseudorandom sequences should guarantee this in any case, but I'm not sure they do on all systems.)

Cheers,
-Greg

···

From: Jack de Valpine <[email protected]>
Date: February 25, 2012 6:23:33 AM PST

Hi Iebele,

I understand about the tmeshes... I also concur with Andy (and my second suggestion) which is in line with what you are doing. I think what would be nice to figure out is if this could all be done using native radiance tools (eg NOT sed/awk) by including a call to rcalc. It has been too long so I just do not remember if there is a way to get rcalc to do any type of string comparison. If there is not this could be a nice feature as this would allow great flexibility processing other scene data. Note my desire for doing it all natively in radiance is more from elegance than anything else.

Another neat feature would be if there was a way to generate an "alpha" file in process of the rendering, where each pixel location also includes the material name. This would be sort of like the option to include z-buffer data per pixel. I suppose this starts to generate huge files though. And may only have utility for a small subset of users.

Regards,

-Jack

That's the general idea. I suppose you could try to generate it automatically. You could also have a final substitution that matches anything non-numeric as a catch-all for materials you don't name in a regex. E.g:

s/^mat1 /0.35 /
s/^mat2 /1.0 /
s/^mat3 /0.0 /
s/^mat4 /0.75 /
s/^[^.0-9][^ ]* /0.0 /

Note that what appear to be spaces above are actually tabs, including the "[^ ]" bit in the last line (very important).

Make sense?
-Greg

···

From: Jack de Valpine <[email protected]>
Date: February 25, 2012 11:08:31 AM PST

Hey Greg,

Many thank! So in this method alphas.txt is a file that you generate by hand of material names and values using regex notation?

-Jack

On 2/25/2012 12:28 PM, Greg Ward wrote:

Hi Jack,

It would be nice if rcalc were smart about strings, but all it can really do is pass them from one place in the input to another place in the output. It never looks at them, really, and none of the operations supports strings.

Regarding your second idea of including the material along with the value, you can do this with rcalc as written. You would have to go for an ascii output, like so:

vwrays -ff [args] | rtrace -h `vwrays -d [args]` -ffa -omv [rargs] octree | sed -f alphas.txt> alphaval.txt

The file "alphas.txt" would contain something like:

s/^mat1 /0.35 /
s/^mat2 /1.0 /
s/^mat3 /0.0 /
s/^mat4 /0.75 /
[etc.]

This would replace each material with an associated alpha value. From there, you would have to convert to 16-bit RGBA or something if you wanted to load it into Photoshop, and I think you would need a C program for that. Alternately, you could split the file using rcalc and pvalue like so:

rcalc -e '$1=$1' -of alphaval.txt | pvalue -h -y $YRES +x $XRES -df -b> alpha.hdr
rcalc -e '$1=$2;$2=$3;$3=$4' -of alphaval.txt | pvalue -h -y $YRES +x $XRES -df> image.hdr

Photoshop can load, convert, and combine HDR files, though you probably have to change from 32-bit to 16-bit mode when you do. Just make sure not to use any of the fancy tone-mappers when you do....

I'm not sure the above would be any faster than Iebele's current method, but it would avoid separate rtrace steps. This permits you to use the -pj option of vwrays safely, as you won't risk sampling one object in one run and another object in another. (Pseudorandom sequences should guarantee this in any case, but I'm not sure they do on all systems.)

Cheers,
-Greg