[Radiance-general] Generating alpha channels using vwrays and rtrace

Jack de Valpine jedev at visarc.com
Sat Feb 25 11:08:31 PST 2012


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
>
>> From: Jack de Valpine<jedev at visarc.com>
>> 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
> _______________________________________________
> Radiance-general mailing list
> Radiance-general at radiance-online.org
> http://www.radiance-online.org/mailman/listinfo/radiance-general



More information about the Radiance-general mailing list