Can shader and logic nodes interact?

question

#1

For example how would you go about making the scale of the Veronoi texture below change when pushing the space bar, using nodes?

If this isn’t possible, then is it possible to at least animate the material properties? When I added key frames to the scale property it animates in Blenders viewport, but not in Armory…


Material animation
#2

This example should show you how to do it. You can dynamically modify float and color properties of shaders I think.


#3

Thanks @zicklag!

I’m just trying to figure out what they mean by:
“Enable ‘Parameter’ property in ‘Logic Node Editor - Properties - Armory Material Node’” in the example, though.

I mean, I see the “Armory Material Node” section in the logic node editor. I’m not quite sure what’s meant by enable the ‘parameter’ property though…


#4

The point of making it a parameter is to allow that node value to be updated at runtime by Haxe or nodes. I think it has to compile the shader differently to allow for that, so that is why it needs the checkbox.

The Name of the material parameter node is then used used to change the value of the parameter through logic nodes.

image


#5

OK, so it took a bit of experimentation, but it worked!


#6

It helps to think about what Armory is doing “behind the scenes.” Your game turns into a Haxe program. The logic-nodes are a visual way to construct that programming … letting Armory do most of the work of building a program in a language that’s probably not familiar to you (if you have any experience in writing computer source-code at all, which you might or might not). The “core” of Armory – also written in Haxe – runs the show, invoking the game-specific logic that you’ve specified, using either logic-nodes or Haxe source code that you’ve written yourself to specify it.

Haxe then magically turns that source-code into whatever-it-is that actually runs on your target(s), using the native tools associated with that target as necessary.


#7

For some reason this is returning only first Slot from materials, when I need another. Any clues?


#8

Did you only copy the node tree at the bottom of @zicklag’s post, or did you also select the RGB node, name it “RGB” in the node properties and tick the “Parameter” checkbox in “Armory Material Node”? The last parts are necessary for the logic nodes to be able to access the RGB material node.


#9

I did not copy anything - as I understand the concept, I recreate it. And yes I have that checks needed. The object and material is returned, but as I have multiple ones assigned to object, I only get first :frowning:
Maybe it’s 0.5 incomplete feature?


#10

Hmmm… Not sure. I did all my experimentation with this, using 0.6 / Blender 2.8 beta…


#11

Nerveless the material name is wrong, it actually effects the right material slot. Jahu


#12

Hi,

I am having problems with the following example:

There’s a trait “MyTrait” but I do not see that it’s bound to any object. Can anybody tell me why this trait is working anyway?

When having a look the logic node editor, I see “Armory Material Node”. But it’s empty. Is this supposed to be like that (got latest SDK today)? What’s the use of this? How can I make a parameter out it?!
MaterialNode

In general, I do not understand how this script works. What’s iron.object.Uniforms and what is it used for?

Any help or links to help are greatly appreciated.

Best regards
blackno666


#13

this node works with the normal principled shader. You need to use the get material node to tell it what material you want to set the color too.


#14

Monte_Drebenstedt,

thanks this sheds a lot of light into my darkness. I still don’t get how the trait MyTrait can work when it is not attached to a single object in the scene (at least that’s how I see it)


#15

All traits must be attached to an object (to the best of my knowledge) if nothing else throw an empty in the scene and attache the trait to that.


#16

The “MyTrait” is attached to the actual scene, I often forget about that one too, it’s easy to oversee:

SceneTrait


#17

facepalm

Thanks for slapping me in the face :wink: