PDA

View Full Version : How to check for RayTraceTransparency flag?



Jure
07-14-2008, 04:21 AM
Hi all,

I've been trying to write a little script that checks for raytrace flags. In renderopts i can only find reflection, refraction and shadow.

Where is transparency?

Thanks,

zapper1998
07-14-2008, 04:32 AM
No version of LightWave would be a true one if it didn't have some secret functions. LightWave 9.5 is "no exception"... So here's a little secret for you that is really helpful to wrap your head around and speed up radiosity settings for particular scenes:

A much requested feature was to be able to show sample positions, octree nodes, and other things to trouble shoot and setup scenes. These were actually added but were not implemented in the interface. You can enable them by adding the following line with a text editor into your layout config file:

RadiosityFlags <flags>



<flags> is an integer and is the sum of the following binary flags:



1 Show the octree nodes as random colors
2 Show the nearest sample cell shade (this is the preprocessing preview)
6 Show the nearest sample cell as random colors
8 Show the sample locations.
16 Show the samples that were missing during preprocessing
32 Show the samples that were missing during rendering
64 Show the secondary bounce illumination
128 Show samples that are in front or behind other samples (behind test)


Some flags work with each other and some do not. You can for example, combine #1 and #8 to show both samples and octree nodes at the same time. You cannot combine #1 and #2 or #6.



http://www.except.nl/menu.htm

Jure
07-14-2008, 06:07 AM
eem... not exactly what i need but thanks anyways... ;)

dpont
07-14-2008, 07:05 AM
CommandInput("RayTraceTransparency");
works in 9.3.1,
for a full exhaustive list run "Save Cmd List".

Denis.

Jure
07-14-2008, 07:08 AM
Yes thanks Denis that works.
But I first need to check weather the Raytrace transparency is set to ON or OFF in render globals. Otherwise it will just cycle it through...

renderopts should give access to this information (it does for shadows, refl and refractions) but it doesn't give for transparency it seems. At least it's not in lscript reference docs.

dpont
07-14-2008, 07:24 AM
As I see, renderopts has still no more than height values,
so still no RaytraceTransparency in the list,
could be a feature request,
..or parsing the scene file.

Denis.

dpont
07-14-2008, 07:36 AM
Even parsing the scene file,
not easy to read from lscript
this is "RayTraceEffects" bit flags.

Denis.

dpont
07-14-2008, 08:17 AM
...Works only if the scene has been saved with its render settings,


generic
{
found = 0;

scene = Scene();
filename = scene.filename;

file = File(filename,"r");

while(!file.eof())
{
line = file.read();
tokens = parse(" ",line);

if(tokens[1]=="RayTraceEffects")
{
raytraceflags = integer(tokens[2]);
found = 1;
break;
}
}

file.close();

if(found == 1)
{
bin = binary(raytraceflags);
binstring = string(bin);

if(integer(string(bin)) < 1000)
info("Ray Trace Transparency Off");
else
if(strleft(strright(binstring, 4), 1))
info("Ray Trace Transparency On");
else
info("Ray Trace Transparency Off");
}

}
//End of lscript


A bit complicated,
Denis.

dpont
07-14-2008, 09:46 AM
Just missed == "1"

if(strleft(strright(binstring, 4), 1)=="1")
info("Ray Trace Transparency On");

Denis.

Jure
07-14-2008, 10:07 AM
Thanks alot Denis.:bowdown:

It will take me a bit of time to wrap my head around this though...:stumped:

evenflcw
07-15-2008, 08:41 AM
Commonly when parsing a scene file for information not otherwise accessible one uses the SaveSceneCopy() function. This has the benefit of not messing with LWs "current file" state. It can all happen behind the scenes (*no pun intended*), unbeknownst to the user.

So here's my version. Might be shorter, but probably less legible because of the regular expression, less typical for-loop and bitmanipulation. More fun to write though. :)

I didn't bother to check whether the correct line was found or not, because if it wasn't in there, the script was used out of context. The only case this would happen is if the LWS format got an update where raytrace option was not saved as "RayTraceEffects XX". And in that case the script in it's entirety is invalid. Checking for EOF however is just good form. :)



/**
* Checks whether Raytrace Transparency is turned on or off.
* @return 0 if off, 1 if on.
* @author Dan Dulberger; [email protected]; July 2008; Use freely and at own risk.
*/
raytraceTransparency {

value = (1<<3); //binary 01000, decimal 8.
match = regexp("^RayTraceEffects");

filename = getdir(TEMPDIR)+"\\temp.lws";
SaveSceneCopy(filename);
file = File(filename, "r");
for(line = file.read(); line != match && !file.eof(); line = file.read())
{}
file.close();
filedelete(file);

return value == (value & integer(line));
}


/**
* Checks whether Raytrace Occlusion is turned on or off.
* @return 0 if off, 1 if on.
* @author Dan Dulberger; [email protected]; July 2008; Use freely and at own risk.
*/
raytraceOcclusion {

value = (1<<4); //binary 10000, decimal 16.
match = regexp("^RayTraceEffects");

filename = getdir(TEMPDIR)+"\\temp.lws";
SaveSceneCopy(filename);
file = File(filename, "r");
for(line = file.read(); line != match && !file.eof(); line = file.read())
{}
file.close();
filedelete(file);

return value == (value & integer(line));
}

dpont
07-15-2008, 09:08 AM
Directly shifting binary is perfect,
didn't know we have access to this,
just a minor thing to change in the UDF,
filedelete(filename);

Denis.

evenflcw
07-15-2008, 10:01 AM
Right you are!

I was also happily suprised that we had access to the bitmanipulation.

Jure
07-15-2008, 11:23 AM
Thanks guys, you rock! I just learned something new. :beerchug: