Forum

#1 2017-12-05 21:04:01

Random surfaces on multiple object

Hi,

I can not find a way to randomly assign surfaces to multiple objects under the same tag.

For example :
A hundred objects with the tag "leaf". Two or three surfaces with each their diffuse texture, opacity, specular .. Randomly assign these surfaces to objects under the "leaf" tag.

There is a "TextureSwitch" node but it is limited when we have more object than textures. And I do not think it works if it must randomly associate a diffuse with the specular that corresponds to it...

Any idea ?

Cheers,
Nicolas

Last edited by Nicolas Castelli (2017-12-05 21:35:24)

Offline

 

#2 2017-12-05 22:19:38

Ben
Guerilla dev, the guy to hug

Re: Random surfaces on multiple object

Hi Nicolas,

Guerilla 1.4 can only randomly tweak the material at shader level, just like you mentionned,
Guerilla 2.0 has more features in the RenderGraph to program this kind of things, yes.

In Guerilla 2.0, you have to use a Script node, and make something like a switch based on the path of the object.

Ben


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

Offline

 

#3 2018-02-14 13:49:58

MegaComputeur
New member

Re: Random surfaces on multiple object

Hi,

I have a similar setup where I'd like to randomly switch between some surface2 based on an id but I am not familiar with Lua and I can't get it working with the Script node hmm
Is there a way to put python code in the Script node, or maybe another approach to this ?

Thanks,
Quentin

Offline

 

#4 2018-02-26 10:58:20

Re: Random surfaces on multiple object

I did not succeed to do anything with this, sorry hmm

Offline

 

#5 2018-02-28 18:22:57

Ben
Guerilla dev, the guy to hug

Re: Random surfaces on multiple object

The script node is Lua only, for performance reasons.

In Guerilla 2.0, you can extract the name of the currently evaluated object using the getscenegraphpath function. For instance:

For instance, if your leaf objects are name blablabla_leaf_###, then you can do something like that:

Code:

if Input then
    Output = duplicate (Input)
    local path = getscenegraphpath ()
    -- extract the ### from the object name
    local leaf_id = string.match (path, "leaf_(%d+)")
    if leaf_id then
        -- if the leaf id exist, then turn it into a real number
        leaf_id = tonumber (leaf_id)
        -- then turn the diffuse color into a Texture shader
        subshader (Output, "DiffuseColor", "Texture", { File = string.format ("c:/texture/lead_diffuse_%02d.png", leaf_id) })
    end
end

Does it help?


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

Offline

 

#6 2018-04-15 19:26:07

Re: Random surfaces on multiple object

Hello,

Yes, it helped me a lot !

Thanks

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2008 PunBB