Forum

#1 2017-02-10 22:17:30

bonovasitch
Member

RenderPass in python vs lua

I'm simply trying to use the "isrenderable" function on a render pass using python.  I noticed the docs are a little different and just wanted to confirm what to expect.

From the lua docs the hierarchy of the RenderPass class is,
class RenderPass < class Shader < class Pass ...
So this returns a bool as expected,

Code:

p = _"RenderPass"
print (p:isrenderable())

From the python docs and looking through the guerrilla module it appears that the hierarchy of RenderPass is,
RenderPass < Shader < Node ...
and the hierarchy of Pass is,
Pass < RenderOutput < Node

Since the Pass class contains "isrenderable" then the RenderPass class cannot call that function with python since it does not have the Pass class in it's hierarchy. 

Code:

render_pass = pynode("RenderPass")
render_pass.isrenderable()

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/mnt/software/guerilla/linux/2.0.0a14/python/guerilla.py", line 1441, in __getattr__
    raise AttributeError("unknown node or plug '%s'" % value)    
AttributeError: unknown node or plug 'isrenderable'

Is this intentional?  If so, is there another way of producing the same result as "isrenderable" with python?

Offline

 

#2 2017-02-13 10:58:58

Shioon
Member

Re: RenderPass in python vs lua

hi bonovasitch,

you could try :

Code:

import guerilla

doc = guerilla.Document()
rp = guerilla._("RenderPass")

def checkSolo():
    solo = []
    for render_pass in doc.children(type='RenderPass'):
        if render_pass.Solo.get():
            solo.append(render_pass.name)
    return solo


def isrenderable(renderPass):
    rp = guerilla._(renderPass)
    solo = checkSolo()

    if len(solo):
        if rp.name in solo:
            if not rp.Disabled.get():
                return True
            else:
                return False
        else:
            return False
    elif not rp.Disabled.get():
        return True
    else:
        return False

print isrenderable("RenderPass")

Last edited by Shioon (2017-02-13 11:10:20)


Jeremy TAN
TD Junior chez OnyxLux3D

Offline

 

#3 2017-02-13 16:43:00

bonovasitch
Member

Re: RenderPass in python vs lua

Jeremy,

Thank you for doing the leg work I was lazily trying to avoid with this inquiry smile

Fundamentally, though, I'm still curious about the python <-> lua commands so I know what to expect going forward.  This "missing" command strays from what I would expect as,

The Docs :

Is the Python API different from Lua API?
The Python and Lua API are really close.

Moreover,

The Docs :

Most Lua functions or methods have a direct equivalent in Python.

Offline

 

#4 2017-02-13 17:09:24

Shioon
Member

Re: RenderPass in python vs lua

if I'm not wrong, guerilla is coded with lua (because lua is faster than python) and they add the python api afterward, and some function may not work well

but you could instead use

Code:

import lua

lua.execute (" YOUR LUA CMD ")

it may be easier ^^

Last edited by Shioon (2017-02-13 17:10:29)


Jeremy TAN
TD Junior chez OnyxLux3D

Offline

 

#5 2017-02-14 17:10:19

Ben
Guerilla dev, the guy to hug

Re: RenderPass in python vs lua

Hi,

Basically, Lua is the internal language of Guerilla (historically, we already had a good experience with Lua from video games, and Python was not so spread at the time we started.)
Python is wrapped around Lua, and most of the wrapping is done automatically using Lua documentation. So, sometimes the doc is just not there unfortunately.

So, if you have a look at guerilla.py, you'll see most Python objects are just wrappers around Lua objects (the _lua attribute.)
I know this is ugly, but sometimes you may try the following:

Code:

render_pass = pynode("RenderPass")
# note that render_pass._lua must be passed as self to the isrenderable
print (render_pass._lua.isrenderable(render_pass._lua))

We're currently stripping off legacy code of Guerilla 2.0, so we'll review the SDK doc and upgrade it soon.

Cheers,
Ben


Benjamin 'Ben' Legros
Guerilla developer
http://www.guerillarender.com

Offline

 

#6 2017-02-14 20:35:47

bonovasitch
Member

Re: RenderPass in python vs lua

Ok,

Thanks, Ben!  I appreciate the explanation.  Using the "_lua" object will be very useful. 

I'll certainly lean on lua when I'm doing something completely guerilla-centric.  However, for tying into current pipeline tools it's easier to stick with python.

Offline

 

#7 2017-02-15 00:31:31

Ben
Guerilla dev, the guy to hug

Re: RenderPass in python vs lua

Yes, of course, Python the preferred pipeline/integration language in Guerilla.


Benjamin 'Ben' Legros
Guerilla developer
http://www.guerillarender.com

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2008 PunBB