Material node group : choosing between the normal geometry or the normal input

Hello,

I have created a node group with a normal input. In my node group, I need the normal values of the object shape to generate the shader result. Therefore, I want to use either the normal parameter of the geometry node, or the normal input of the node group if this value has been set outside (let’s say, the way it’s done within the Fresnel node), to define a normal map for example.
How can I do that ?

Let me see if I get this right. You want to; if group normal input is connected then group should use that, otherwise it should use something from within the group itself?

I’ve tried something like this, but unsuccessful, and I’m not sure it can be done. I could check if color was black (shouldn’t happen in the maps I had, and was kinda complex in it’s own), but if nothing was connected, it could end up reading “random garbage data” (as if memory pointers were missing).

Only way I had around it, which has some limitations, is to have in the group gui a “blend slider” that inside the group color mixes between the input and whatever you do inside. When you want to have two separate materials following the same setting just without the feed/unfed one, you have to create a nodegroup that specifies the remaining inputs. Like:

group.ColorAndRoughness -> group.MaterialWithObjectBasedNormals.
group.ColorAndRoughness -> group.MaterialWithInputBasedNormals.

I once thought I had it, in a case where I wanted to check if UV map was present to drive tangents for anisotropic metals, and Z axis driven (internally in the group) if it was disconnected. But alas, turned out it was still reading garbage data a second time I read in the project.

Imagine the teapot being brushed metal. Lid and body can be Z axis based, but nozzle and handle would require UV based. I couldn’t use UVs for everything since tangent data isn’t smoothed over a defined seam, but I could hide the seam for those two parts but not the lid and body. I reported it as a bug, but was rejected (add geometry or paint the data in - geometry is not an option due memory and I don’t know how the data should really look like which would be too cumbersome anyhow).

So yeah, if someone has a solution to this, I would appreciate it as well.

That is, if I understood the problem correctly of course.

That’s exactly my problem. Like you, I was disappointed to see that the normal input is set to a random value if not connected (the everlasting coding mistake of non initialized pointers). Yet it’s possible to set a default value in the right panel of the node editor. It sounds like a bug to me.

Maybe if the normal input is replaced by a color type input (as a normal map can be converted to a color image) would it be possible to set a default value … and thus it would be possible to detect if the input is connected or not.
I’ll try this workaround shortly.

I reported the “random value” issue when the normal input is not connected, and it seems that it will be corrected in a future version of Blender : https://developer.blender.org/T46406

Cool. Oh;
“Default value in the settings only affects newly added node group instances”
so that’s what actually happens? Yeah, bites me every time, because it appears to be working, then all of a sudden without warning it fails miserably. It’s nice to be aware of this though.

It seems to be corrected in the new release 2.76 (Fix T46406) :
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.76/Bug_Fixes

Okay! It really seems that the random normal input value issue is corrected in 2.76. Thus I was able to make a node group that detects if the normal input is connected or not : http://www.pasteall.org/blend/38518

@CarlG : maybe you can try the blend above and tell me if it fits your need. Then I’ll mark this thread as solved.

Sorry, not able to for a while. Maybe others can try it out?