25 Commits

Author SHA1 Message Date
Alex Strand
b248ec9776 Shaders: add emission strength input to Principled BSDF node
This impacts I/O add-ons. OBJ, FBX and Collada have been updated, glTF not yet.

Differential Revision: https://developer.blender.org/D4971
2020-09-17 18:54:04 +02:00
Bastien Montagne
0696eaa3e8 Fix T80684: Node shader wrapper: Tweak handling of alpha textures.
There is no ideal solution here, but we can assume by default that we should
use the Alpha output from a texture used for transparency data.

This will break people using a dedicated B&W texture for this alpha
pass, but we cannot really handle all cases properly in this wrapper, we
only try to support the most common ones to some extent.
2020-09-16 16:39:49 +02:00
Bastien Montagne
d89b65cc91 Node shader wrapper: use 'Non-Color' profile for BW textures inputs.
All the single-value texture inputs of Principled BSDF node should use
non-color colorspace profile, not sRGB one (issue raised in
https://blender.stackexchange.com/questions/155617, thanks).

That also revealed another issue - since those color space settings are
stored at the image level itself, not the node one, we need to
duplicate those image data-blocks when we use same picture for e.g. base
color (sRGB) and specular (non-color) inputs...

For now using a basic mechanism for that, might generate several extra,
uneeded copies of the image ID, but that’s better than breaking custom
settings and such.

Note that while this will modify the behavior of the impporters using
that node wrapper, no change should be needed in IO add-ons themselves.
2019-10-17 11:43:11 +02:00
Bastien Montagne
826db891ab Node Shader wrapper: add access to the Emission color of Principled BSDF node.
This did not exist when that wrapper was created, but is supported by
many formats, so worth supporting it now. See also T70666.
2019-10-10 17:21:06 +02:00
Bastien Montagne
e846852862 Fix T70596: Wrong default scale value for node wrapper tool.
This affected all exporter add-ons using that wrapper to handle the node
shaders... sigh...
2019-10-09 20:33:22 +02:00
Philipp Oeser
87d0033ea9 Fix node_shader_utils problems with new mapping node
Since rBbaaa89a0bc54 we have to access the mapping node differently.
This doesnt take actual linkage of the new sockets into account (but
this wasnt done for most sockets on the Principled BSDF node either)

Also the min/max of the mapping node was removed entirely.
It was decided upon removing this from node_shader_utils as well (and
replace this by existing access to the Extension parameter of the
Texture node).

Part of solving T69526.

Differential Revision: https://developer.blender.org/D5693
2019-09-06 23:39:19 +02:00
Bastien Montagne
db0782e946 Py node shader wrapper: Add clamping to official min/max values.
Taking values from relevant node definition C file...

Related to T67889.
2019-07-30 11:24:10 +02:00
Philipp Oeser
711960b3c2 node_shader_utils: add possibility to override image colorspace
'is_data'

since the move from 'cycles_shader_compat' (2.79) to
'PrincipledBSDFWrapper' (2.8) we lost the ability to (automatically) set
this colorspace setting for imported textures. This was useful for e.g.
normalmaps to always assume 'Non-Color' data.

This adds the possibility to overide and uses this for normalmaps...

Fixes T66368

Reviewers: mont29, brecht

Maniphest Tasks: T66368

Differential Revision: https://developer.blender.org/D5176
2019-07-04 12:32:25 +02:00
andreas atteneder
28f472472b Fix typo pratially breaking node shader wrapper (used by IO add-ons).
Reported with patch as D5140 by andreas atteneder (@atti), thanks!
2019-06-26 17:57:07 +02:00
Bastien Montagne
f9784ea6af Py NodeShader wrapper helper: add support for new Alpha setting of Principled BSDF.
Now that we have real alpha in BSDF, it's much better option for
transparency, than previously used Transmission value.

Related to T64609.
2019-05-15 20:59:58 +02:00
Campbell Barton
7465a5db3b Cleanup: unused args/vars/imports in modules 2019-05-09 13:11:36 +10:00
Campbell Barton
69bf4e5e36 Cleanup: unused variables 2019-03-17 21:14:43 +11:00
Jacques Lucke
1ceaca7f64 Fix T61017: node_shader_utils did not handle diffuse_color correctly 2019-01-30 14:37:09 +01:00
Campbell Barton
7894d6c6f1 Cleanup: line length 2019-01-30 09:06:44 +11:00
Bastien Montagne
2589263b6e Fix related to T57851: broken normalmap handling in py shader wrapper.
Pretty stupid mistake...
2018-11-16 14:59:30 +01:00
Philipp Oeser
cfb6f14616 Fix node_shader_utils: "Specular Tint" is a float (not a color) 2018-11-15 17:52:40 +01:00
Bastien Montagne
65ea9ec948 node_shader_utils: Proper fix for node_normalmap accessor returning ellipsis value.
Ellipsis value is internal ingredient only, to tag hidden _node_normalmap
'real' property as not yet initialized. Public node_normalmap accessor
should never ever have that value, it's either None or a valid node!
2018-10-17 20:18:40 +02:00
Bastien Montagne
5c038a6930 Revert "Fix error on FBX export after material changes"
This reverts commit ce4cfbe108d0641832d86a731ea32f596220b7c5.

Obviously wrong 'fix', please do not touch other dev’s code, especially
in active/WIP area, when you do not fully understand it.
2018-10-17 20:17:02 +02:00
Dalai Felinto
ce4cfbe108 Fix error on FBX export after material changes
Update the addons repository as well.
2018-10-17 17:12:17 +00:00
Bastien Montagne
fb550ca6b9 node_shader_utils: fix bad setting of use_nodes in readonly case.
Also added access to extension property in texture wrapper.
2018-10-16 19:58:50 +02:00
Bastien Montagne
dd6bf3f84a node_shader_utils: several fixes, improvements and cleanups.
Fix broken behavior in case of texcoords mapping (we do need texcoords
node in all cases, then, even for UV coords...).

Use nodes by default when generating new write-allowed wrapper around a
material.

Do not try to find nodes in existing tree all the time, do it only once,
even for lazy-initialized nodes (through accessors).

Fix ugly spacing in property accessors (since it looks like some people
do not like a single 'block' with both getters, setters and prop
definition, at least use one sep line everywhere (and two sep lines to
separate properties)...
2018-10-13 19:36:47 +02:00
Brecht Van Lommel
78390f7724 Python: change node_shader_utils diffuse RGBA to base_color RGB.
Best to give its actual name so it's clear that the Principled BSDF does
not have a diffuse color exactly, and does not have an alpha component.

Also image textures use UVs by default, so avoid creating a texture
coordinate node for that.
2018-10-12 15:55:09 +02:00
Campbell Barton
bda7a333a3 Cleanup: use tuple unpacking 2018-10-01 09:20:32 +10:00
Campbell Barton
0256d8b4e2 Cleanup: pep8, unused import 2018-10-01 09:20:32 +10:00
Bastien Montagne
6f42eb245b Python IO: Initial nodal shader support for import AND export.
That new bpy_extras' node_shader_utils module is remotely based on
existing addons' cycles_shader_compat module. It has some key
differences though:
 - It is based on Principled shader, instead of the noodle combination
   of half a dozen simpler shaders.
 - It does not do any value conversion (like e.g. clamping, which was
   only suited for FBX). Any conversion/adaptation is to be done
   by each IO add-on.
 - It extensively uses accessors to offer:
   - Easy read/write of values, hiding all the hairy noodly nodes
     (principled shader helps a lot here).
   - lazy creation of most nodes on accessing (when generating a
     material), which avoids getting unused nodes in final shader.
 - We only use Principled BSDF so far though, which means some features
   supported by previous system are not yet implemented in new one.

Note that, even though we support 'exporting' side of things, this will
only work for a very specific (and basic) kind of shader. This will have
to be clearly explained in end-user documentation.

Also, that code has had some basic testing, but most certainly needs a
lot more refinement.

As proof-of-concept, OBJ IO script will be updated to use that new
system after that commit.
2018-09-27 23:32:56 +02:00