problem with script variables and inheritance Topic is solved

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


jwwalker
Goblin
Posts: 247
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 18

problem with script variables and inheritance

Post by jwwalker »

I have a material script that looks, partially, like this:

Code: Select all

fragment_program JWFP/SideBySideStereo unified
{
    delegate JW/SideBySide_ps_metal
    delegate JW/SideBySide_ps_hlsl
    delegate JW/SideBySide_ps_vulkan
}

abstract material JW/StereoComposite
{
    technique
    {
        pass
        {
            fragment_program_ref $composite_program
            {
                param_named     pixelWidth      int     100
                param_named     pixelHeight     int     100
            }
            
            // other irrelevant stuff
        }
    }
}

material JW/StereoSideBySide : JW/StereoComposite
{
    set $composite_program "JWFP/SideBySideStereo"
}

But when Ogre tries to compile the script, it logs "Compiler error: object name expected", pointing to the fragment_program_ref line that uses the script variable. The Ogre manual has only one example of the use of a script variable, and that variable holds an array of numbers rather than an object name, so I don't know whether this ought to work.

User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 479
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 167

Re: problem with script variables and inheritance

Post by sercero »

I'm not a super expert, but I have never seen that kind of syntaxis.

Which part of the manual led you to that kind of syntax?

jwwalker
Goblin
Posts: 247
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 18

Re: problem with script variables and inheritance

Post by jwwalker »

@sercero Script variables are discussed here.

User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 479
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 167

Re: problem with script variables and inheritance

Post by sercero »

Variables allow you to parameterize data in materials

I think you can only parametrize values, in your case I'm really not sure what you are trying to do. Sorry

paroj
OGRE Team Member
OGRE Team Member
Posts: 2095
Joined: Sun Mar 30, 2014 2:51 pm
x 1130

Re: problem with script variables and inheritance

Post by paroj »

object names cannot be variables

jwwalker
Goblin
Posts: 247
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 18

Re: problem with script variables and inheritance

Post by jwwalker »

It's not clear to me what constitutes "data" for this purpose. I have successfully used a script variable for a material name, but apparently I can't use one for a fragment program name. What's the difference?

paroj
OGRE Team Member
OGRE Team Member
Posts: 2095
Joined: Sun Mar 30, 2014 2:51 pm
x 1130

Re: problem with script variables and inheritance

Post by paroj »

anything called name here cannot be a variable:
https://ogrecave.github.io/ogre-next/ap ... tml#Format

to be more clear; object name declarations cannot be variables. Note: in this case "fragment_program_ref" is the object as far as the ScriptCompiler is concerned.

If the material name is the value of an attribute, it can be a variable.

jwwalker
Goblin
Posts: 247
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 18

Re: problem with script variables and inheritance

Post by jwwalker »

OK, I think I get it now. If a script says

Code: Select all

material MyMatName
{
    ...
}

compositor_node SomeNode
{
    ...
    target colorTx
    {
        pass render_quad
        {
            material MyMatName
            ...
        }
    }
}

then MyMatName is syntactically an object name in the first place where it appears, but not in the second place, so the second place could be replaced by a script variable. Whereas if a script says

Code: Select all

fragment_program MyProg
{
    ...
}

material SomeMat
{
    technique
    {
        pass
        {
            fragment_program_ref MyProg
            {
                ...
            }
        }
    }
}

then MyProg is an object name in both places where it appears.

paroj
OGRE Team Member
OGRE Team Member
Posts: 2095
Joined: Sun Mar 30, 2014 2:51 pm
x 1130

Re: problem with script variables and inheritance

Post by paroj »

yes, exactly