PDA

View Full Version : RenderOpts Problem



xchrisx
02-08-2013, 10:02 AM
I am starting to make the transition over to python however I find the docs confusing at best regarding certain commands. For example I want to query renderOpts however the python implementation doesn't seem to be working in which the same way Lscript does. I understand not a lot of highlevel access has been implemented yet, but I don't see how the current information can related to the values it should. For example:



@warnings
@version 2.7
@script generic

generic
{
info(Scene().renderopts[12]);
}


In the above code, my scene returns 0 since my SaveRGB is unchecked. However I now run the closest equivalent command in Python :



import lwsdk
lwsdk.LWSceneInfo().renderOpts


And now I receive a long integer, 270286855. So I see that the data is now stored into an integer rather than to an array. This is frustrating because I have no idea what to do with this number. If I check the SaveRGB and rerun the same command my value is 270288903 which I don't see how it relates to the first value. My main question is in this case, using this integer how do I extract the appropriate data out of it? I also dont know if I am even invoking the command properly, as I also tried to use the get property in various ways to no avail.


Any insights would be greatly appreciated.
-Chris


Information from PCore about this command:


renderOpts
LWSceneInfo_renderOpts_get(LWSceneInfo self) -> int

the C sdk describes renderOpts as follows:

#define LWROPT_SHADOWTRACE (1<<0)
#define LWROPT_REFLECTTRACE (1<<1)
#define LWROPT_REFRACTTRACE (1<<2)
#define LWROPT_FIELDS (1<<3)
#define LWROPT_EVENFIELDS (1<<4)
#define LWROPT_MOTIONBLUR (1<<5)
#define LWROPT_DEPTHOFFIELD (1<<6)
#define LWROPT_LIMITEDREGION (1<<7)
#define LWROPT_PARTICLEBLUR (1<<8)
#define LWROPT_ENHANCEDAA (1<<9)
#define LWROPT_SAVEANIM (1<<10)
#define LWROPT_SAVERGB (1<<11)
#define LWROPT_SAVEALPHA (1<<12)
#define LWROPT_ZBUFFERAA (1<<13) /* added 12/29/2004 */
#define LWROPT_RTTRANSPARENCIES (1<<14) /* added 11/01/2006 */
#define LWROPT_RADIOSITY (1<<15)
#define LWROPT_CAUSTICS (1<<16)
#define LWROPT_OCCLUSION (1<<17)
#define LWROPT_RENDERLINES (1<<18)
#define LWROPT_INTERPOLATED (1<<19)
#define LWROPT_BLURBACKGROUND (1<<20)
#define LWROPT_USETRANSPARENCY (1<<21)
#define LWROPT_VOLUMETRICRADIOSITY (1<<22)
#define LWROPT_USEAMBIENT (1<<23)
#define LWROPT_DIRECTIONALRAYS (1<<24)
#define LWROPT_LIMITDYNAMICRANGE (1<<25)
#define LWROPT_CACHERADIOSITY (1<<26)
#define LWROPT_USEGRADIENTS (1<<27)
#define LWROPT_USEBEHINDTEST (1<<28)
#define LWROPT_CAUSTICSCACHE (1<<29)
#define LWROPT_RENDERINSTANCES (1<<30)
#define LWROPT_UNPREMULTIPLIEDALPHA (1<<31)

BigHache
02-08-2013, 06:47 PM
Taking a quick look at this, what's interesting to me is I don't even get the same values you get. With Save RGB unchecked I return 1344028679, checked I return 1344030727. Are you using LW 32 bit or 64? I hope you're using 32, I'm on 64, at least that would account for the change.

Using other methods in LWSceneInfo() I'd say you are using it correctly. I would just check to see if that int is returned or not.

There are some seemingly odd values in Python, like OPSEL_MODIFY = 32768. The other selection values are 0, 1, and 2. Where 32768 comes from is beyond me.

xchrisx
02-08-2013, 07:01 PM
The values take into consideration all of the different settings that are checked on and off in the scene. That is my guess why you got different numbers than I did. I am using LW1102 64bit though as we havent installed 11.5 here at work yet.

On a side note, I have noticed that "RayTraceEffects" in the lightwave scene file uses a weird way of storing the values all of the different raytrace checkbox settings (transparency, shadows, reflection, etc). I have deduced the following and suspect that renderOpts is doing something similar.

When the checkboxes for raytracing are checked ON in the scene:
Shadows = 1
Reflections = 2
Refraction = 4
Transparecny = 8
Occlusion = 16

So if you have Shadow and Refraction on, RayTraceEffects equals 5. If you turn on Occlusion, RayTraceEffects = 21, and so on. So I am curious if this type of value system is what is being used in other areas of LW behind the scenes.

clintonman
02-08-2013, 07:21 PM
I believe you use the & operator to test for values. If I have save rgb checked I get 1344028679 as the value from renderOpts but if I and it I get 2048 when it's active and 0 otherwise. You might be able to use the result in an if statement directly, but I'm not sure if python sees 0 as false and everything else as true.


import lwsdk
lwsdk.LWSceneInfo().renderOpts & lwsdk.LWROPT_SAVERGB

I get the "lwsdk.LWROPT_SAVERGB" from the python docs.

xchrisx
02-08-2013, 10:03 PM
thanks for the info Clinton I very much appreciate it. I searched my docs but didnt find the savergb. Perhaps I need to regenerate my pycore help.

One more quick question is, why the & sign? I would have thought if anything it would have been a parameter or property rather than something that gets appended on at the end.

clintonman
02-09-2013, 10:49 AM
thanks for the info Clinton I very much appreciate it. I searched my docs but didnt find the savergb. Perhaps I need to regenerate my pycore help.

One more quick question is, why the & sign? I would have thought if anything it would have been a parameter or property rather than something that gets appended on at the end.
The information can be found in the installation. A typical install on windows will put it here "C:\Program Files\NewTek\LightWave11.5\sdk". The C and the new python docs are there.

You need the &(bitwise and) to filter out the flag because the renderOpts is a bunch of flags all together as one. That's why everyone is getting different values for it. The only way to get identical values is if all the render settings are identical.

xchrisx
02-09-2013, 11:29 AM
Thanks for the info Clinton. I am running 11.02 so maybe that info isnt in my version of the sdk, or at least I didnt see it.

clintonman
02-09-2013, 12:06 PM
I see. In that case you can get the same documentation for 11.5 here:

https://www.lightwave3d.com/lightwave_sdk/