Page MenuHome

Shading: Add more operators to Vector Math node.
ClosedPublic

Authored by Omar Emara (OmarSquircleArt) on Aug 18 2019, 10:25 PM.

Details

Summary

Add Multiply, Divide, Project, Reflect, Distance, Length, Scale, Snap,
Floor, Ceil, Modulo, Fraction, Absolute, Minimum, and Maximum operators
to the Vector Math node. The Value output has been removed from operators
whose output is a vector, and the other way around. All of those removals
has been handled properly in versioning code.

The patch doesn't include tests for the new operators. Tests will be added
in a later patch.

Diff Detail

Repository
rB Blender

Event Timeline

source/blender/blenlib/BLI_listbase.h
184

You can add this macro to the clang-format file. Then format the files where it was used again. (same for the other macro)

  • Add custom loop macros to the clang format dot file.
Omar Emara (OmarSquircleArt) marked an inline comment as done.Aug 19 2019, 11:22 AM

A file to test versioning code:

intern/cycles/util/util_math_float3.h
361

why use the name i for a vector?

408

Checking if b is zero should only be done once.

source/blender/blenkernel/intern/node.c
3235

Why did you remove this?

source/blender/blenloader/intern/versioning_cycles.c
504

I'm not sure if this does work when a reroute node was used.
Maybe we can just ignore this case, since it would be quite weird to have a reroute node in that place.

intern/cycles/util/util_math_float3.h
361

i -> incident vector
n -> normal vector

I could change that though, should I?

source/blender/blenkernel/intern/node.c
3235

Unavailable sockets can and may still be linked, not tagging them as "in use" implies that they aren't linked, which is not true. This causes problems when the developer use the SOCK_IN_USE flag as an indication of the linking status of a socket. An example for this would be versioning code.

source/blender/blenloader/intern/versioning_cycles.c
504

I will look into it.

intern/cycles/util/util_math_float3.h
361

yeah, just rename it to incident. That does not make it worse.

source/blender/blenkernel/intern/node.c
3235

Hm okay, seems like this depends on how SOCK_IN_USE is defined.
Not sure if it should be a reliable indicator on whether a socket is linked.
Can you check the other uses of SOCK_IN_USE to see if this might conflict with something?

  • Refactor the safe_divide_float3_float function.
Omar Emara (OmarSquircleArt) marked an inline comment as done.Aug 19 2019, 3:31 PM
Omar Emara (OmarSquircleArt) added inline comments.
source/blender/blenkernel/intern/node.c
3235

Ok, I checked before I made this change. But will check again just to make sure.

Omar Emara (OmarSquircleArt) marked 2 inline comments as done.Aug 19 2019, 3:45 PM
Omar Emara (OmarSquircleArt) updated this revision to Diff 17269.
  • Refactor reflect function.
source/blender/blenkernel/intern/node.c
3235

The flag is used in very few places it seems.

  • light_emission_node_to_energy where it is used to check if an input socket is linked or not.
  • std_node_socket_draw where it is used to check if an input socket is linked or not.
  • socket_is_available it doesn't really matter in this case because the function exist early before it reaches the flag anyway.

Moreover, do_versions_nodetree_socket_use_flags_2_62 actually does what we have now. So I think we are safe.

source/blender/blenkernel/intern/node.c
3235

Good. It's probably a good idea to rename this to SOCK_IS_LINKED then (in a separate patch).

This revision is now accepted and ready to land.Tue, Aug 20, 10:18 AM
Brecht Van Lommel (brecht) requested changes to this revision.Tue, Aug 20, 12:29 PM

One of the regression tests is failing here.

1----------------------------------------------------------
232/145 Testing: cycles_render_graph_finalize_test
332/145 Test: cycles_render_graph_finalize_test
4Command: "/home/brecht/dev/worktree_build/bin/tests/cycles_render_graph_finalize_test"
5Directory: /home/brecht/dev/worktree_build/bin
6"cycles_render_graph_finalize_test" start time: Aug 19 14:19 CEST
7Output:
8----------------------------------------------------------
9[==========] Running 60 tests from 1 test case.
10[----------] Global test environment set-up.
11[----------] 60 tests from RenderGraph
12[ RUN ] RenderGraph.deduplicate_deep
13I0819 14:19:45.345264 47208 device_cpu.cpp:120] Will be using default kernels.
14
15GMOCK WARNING:
16Uninteresting mock function call - returning directly.
17 Function call: Log(0, @0x7ffcb1142a58 "/home/brecht/dev/worktree/intern/cycles/device/device_cpu.cpp", @0x7ffcb1142a78 "Will be using default kernels.")
18NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md#knowing-when-to-expect for details.
19[OpenColorIO Info]: Color management disabled. (Specify the $OCIO environment variable to enable.)
20I0819 14:19:45.345633 47208 constant_fold.cpp:46] Folding Value1::Value to constant (0.8).
21I0819 14:19:45.345650 47208 constant_fold.cpp:46] Folding Value2::Value to constant (0.8).
22I0819 14:19:45.345662 47208 graph.cpp:663] Deduplicated 2 nodes.
23[ OK ] RenderGraph.deduplicate_deep (0 ms)
24[ RUN ] RenderGraph.constant_fold_rgb_to_bw
25I0819 14:19:45.345726 47208 constant_fold.cpp:46] Folding RGBToBWNodeNode::Val to constant (0.8).
26I0819 14:19:45.345734 47208 constant_fold.cpp:58] Folding convert_float_to_color::value_color to constant (0.8, 0.8, 0.8).
27[ OK ] RenderGraph.constant_fold_rgb_to_bw (0 ms)
28[ RUN ] RenderGraph.constant_fold_emission1
29I0819 14:19:45.345779 47208 constant_fold.cpp:132] Discarding closure Emission.
30[ OK ] RenderGraph.constant_fold_emission1 (0 ms)
31[ RUN ] RenderGraph.constant_fold_emission2
32I0819 14:19:45.345819 47208 constant_fold.cpp:132] Discarding closure Emission.
33[ OK ] RenderGraph.constant_fold_emission2 (0 ms)
34[ RUN ] RenderGraph.constant_fold_background1
35I0819 14:19:45.345857 47208 constant_fold.cpp:132] Discarding closure Background.
36[ OK ] RenderGraph.constant_fold_background1 (0 ms)
37[ RUN ] RenderGraph.constant_fold_background2
38I0819 14:19:45.345896 47208 constant_fold.cpp:132] Discarding closure Background.
39[ OK ] RenderGraph.constant_fold_background2 (0 ms)
40[ RUN ] RenderGraph.constant_fold_shader_add
41I0819 14:19:45.345953 47208 constant_fold.cpp:113] Folding AddClosure1::Closure to socket Diffuse::BSDF.
42I0819 14:19:45.345960 47208 constant_fold.cpp:113] Folding AddClosure2::Closure to socket Diffuse::BSDF.
43[ OK ] RenderGraph.constant_fold_shader_add (0 ms)
44[ RUN ] RenderGraph.constant_fold_shader_mix
45I0819 14:19:45.346025 47208 constant_fold.cpp:113] Folding MixClosure1::Closure to socket Diffuse::BSDF.
46I0819 14:19:45.346032 47208 constant_fold.cpp:113] Folding MixClosure2::Closure to socket Diffuse::BSDF.
47I0819 14:19:45.346037 47208 constant_fold.cpp:113] Folding MixClosure3::Closure to socket Diffuse::BSDF.
48[ OK ] RenderGraph.constant_fold_shader_mix (1 ms)
49[ RUN ] RenderGraph.constant_fold_invert
50I0819 14:19:45.346083 47208 constant_fold.cpp:58] Folding Invert::Color to constant (0.68, 0.5, 0.32).
51[ OK ] RenderGraph.constant_fold_invert (0 ms)
52[ RUN ] RenderGraph.constant_fold_invert_fac_0
53I0819 14:19:45.346133 47208 constant_fold.cpp:113] Folding Invert::Color to socket Attribute::Color.
54[ OK ] RenderGraph.constant_fold_invert_fac_0 (0 ms)
55[ RUN ] RenderGraph.constant_fold_invert_fac_0_const
56I0819 14:19:45.346176 47208 constant_fold.cpp:58] Folding Invert::Color to constant (0.2, 0.5, 0.8).
57[ OK ] RenderGraph.constant_fold_invert_fac_0_const (0 ms)
58[ RUN ] RenderGraph.constant_fold_mix_add
59I0819 14:19:45.346225 47208 constant_fold.cpp:58] Folding MixAdd::Color to constant (0.62, 1.14, 1.42).
60[ OK ] RenderGraph.constant_fold_mix_add (0 ms)
61[ RUN ] RenderGraph.constant_fold_mix_add_clamp
62I0819 14:19:45.346271 47208 constant_fold.cpp:58] Folding MixAdd::Color to constant (0.62, 1, 1).
63[ OK ] RenderGraph.constant_fold_mix_add_clamp (0 ms)
64[ RUN ] RenderGraph.constant_fold_part_mix_dodge_no_fac_0
65[ OK ] RenderGraph.constant_fold_part_mix_dodge_no_fac_0 (0 ms)
66[ RUN ] RenderGraph.constant_fold_part_mix_light_no_fac_0
67[ OK ] RenderGraph.constant_fold_part_mix_light_no_fac_0 (0 ms)
68[ RUN ] RenderGraph.constant_fold_part_mix_burn_no_fac_0
69[ OK ] RenderGraph.constant_fold_part_mix_burn_no_fac_0 (0 ms)
70[ RUN ] RenderGraph.constant_fold_part_mix_blend_clamped_no_fac_0
71[ OK ] RenderGraph.constant_fold_part_mix_blend_clamped_no_fac_0 (0 ms)
72[ RUN ] RenderGraph.constant_fold_part_mix_blend
73I0819 14:19:45.346499 47208 constant_fold.cpp:113] Folding MixBlend1::Color to socket Attribute1::Color.
74I0819 14:19:45.346508 47208 constant_fold.cpp:113] Folding MixBlend2::Color to socket Attribute1::Color.
75I0819 14:19:45.346511 47208 constant_fold.cpp:113] Folding MixBlend3::Color to socket Attribute1::Color.
76[ OK ] RenderGraph.constant_fold_part_mix_blend (0 ms)
77[ RUN ] RenderGraph.constant_fold_part_mix_sub_same_fac_bad
78[ OK ] RenderGraph.constant_fold_part_mix_sub_same_fac_bad (0 ms)
79[ RUN ] RenderGraph.constant_fold_part_mix_sub_same_fac_1
80I0819 14:19:45.346596 47208 constant_fold.cpp:58] Folding Mix::Color to constant (0, 0, 0).
81I0819 14:19:45.346604 47208 constant_fold.cpp:132] Discarding closure EmissionNode.
82[ OK ] RenderGraph.constant_fold_part_mix_sub_same_fac_1 (0 ms)
83[ RUN ] RenderGraph.constant_fold_part_mix_add_0
84I0819 14:19:45.346681 47208 constant_fold.cpp:113] Folding Mix_Cx_F1::Color to socket Attribute::Color.
85I0819 14:19:45.346689 47208 constant_fold.cpp:113] Folding Mix_xC_Fx::Color to socket Attribute::Color.
86I0819 14:19:45.346693 47208 constant_fold.cpp:113] Folding Mix_xC_F1::Color to socket Attribute::Color.
87[ OK ] RenderGraph.constant_fold_part_mix_add_0 (0 ms)
88[ RUN ] RenderGraph.constant_fold_part_mix_sub_0
89I0819 14:19:45.346771 47208 constant_fold.cpp:113] Folding Mix_xC_Fx::Color to socket Attribute::Color.
90I0819 14:19:45.346777 47208 constant_fold.cpp:113] Folding Mix_xC_F1::Color to socket Attribute::Color.
91[ OK ] RenderGraph.constant_fold_part_mix_sub_0 (0 ms)
92[ RUN ] RenderGraph.constant_fold_part_mix_mul_1
93I0819 14:19:45.346849 47208 constant_fold.cpp:113] Folding Mix_Cx_F1::Color to socket Attribute::Color.
94I0819 14:19:45.346856 47208 constant_fold.cpp:113] Folding Mix_xC_Fx::Color to socket Attribute::Color.
95I0819 14:19:45.346861 47208 constant_fold.cpp:113] Folding Mix_xC_F1::Color to socket Attribute::Color.
96[ OK ] RenderGraph.constant_fold_part_mix_mul_1 (0 ms)
97[ RUN ] RenderGraph.constant_fold_part_mix_div_1
98I0819 14:19:45.346933 47208 constant_fold.cpp:113] Folding Mix_xC_Fx::Color to socket Attribute::Color.
99I0819 14:19:45.346940 47208 constant_fold.cpp:113] Folding Mix_xC_F1::Color to socket Attribute::Color.
100[ OK ] RenderGraph.constant_fold_part_mix_div_1 (0 ms)
101[ RUN ] RenderGraph.constant_fold_part_mix_mul_0
102I0819 14:19:45.347013 47208 constant_fold.cpp:58] Folding Mix_Cx_Fx::Color to constant (0, 0, 0).
103I0819 14:19:45.347023 47208 constant_fold.cpp:58] Folding Mix_Cx_F1::Color to constant (0, 0, 0).
104I0819 14:19:45.347028 47208 constant_fold.cpp:58] Folding Mix_xC_F1::Color to constant (0, 0, 0).
105I0819 14:19:45.347033 47208 constant_fold.cpp:58] Folding Out12::Color to constant (0, 0, 0).
106[ OK ] RenderGraph.constant_fold_part_mix_mul_0 (1 ms)
107[ RUN ] RenderGraph.constant_fold_part_mix_div_0
108I0819 14:19:45.347108 47208 constant_fold.cpp:58] Folding Mix_Cx_Fx::Color to constant (0, 0, 0).
109I0819 14:19:45.347116 47208 constant_fold.cpp:58] Folding Mix_Cx_F1::Color to constant (0, 0, 0).
110I0819 14:19:45.347122 47208 constant_fold.cpp:58] Folding Out12::Color to constant (0, 0, 0).
111[ OK ] RenderGraph.constant_fold_part_mix_div_0 (0 ms)
112[ RUN ] RenderGraph.constant_fold_separate_combine_rgb
113I0819 14:19:45.347183 47208 constant_fold.cpp:46] Folding SeparateRGB::R to constant (0.3).
114I0819 14:19:45.347190 47208 constant_fold.cpp:46] Folding SeparateRGB::G to constant (0.5).
115I0819 14:19:45.347195 47208 constant_fold.cpp:46] Folding SeparateRGB::B to constant (0.7).
116I0819 14:19:45.347200 47208 constant_fold.cpp:58] Folding CombineRGB::Image to constant (0.3, 0.5, 0.7).
117[ OK ] RenderGraph.constant_fold_separate_combine_rgb (0 ms)
118[ RUN ] RenderGraph.constant_fold_separate_combine_xyz
119I0819 14:19:45.347260 47208 constant_fold.cpp:46] Folding SeparateXYZ::X to constant (0.3).
120I0819 14:19:45.347268 47208 constant_fold.cpp:46] Folding SeparateXYZ::Y to constant (0.5).
121I0819 14:19:45.347272 47208 constant_fold.cpp:46] Folding SeparateXYZ::Z to constant (0.7).
122I0819 14:19:45.347277 47208 constant_fold.cpp:58] Folding CombineXYZ::Vector to constant (0.3, 0.5, 0.7).
123I0819 14:19:45.347282 47208 constant_fold.cpp:58] Folding convert_vector_to_color::value_color to constant (0.3, 0.5, 0.7).
124[ OK ] RenderGraph.constant_fold_separate_combine_xyz (0 ms)
125[ RUN ] RenderGraph.constant_fold_separate_combine_hsv
126I0819 14:19:45.347340 47208 constant_fold.cpp:46] Folding SeparateHSV::H to constant (0.583333).
127I0819 14:19:45.347347 47208 constant_fold.cpp:46] Folding SeparateHSV::S to constant (0.571429).
128I0819 14:19:45.347352 47208 constant_fold.cpp:46] Folding SeparateHSV::V to constant (0.7).
129I0819 14:19:45.347357 47208 constant_fold.cpp:58] Folding CombineHSV::Color to constant (0.3, 0.5, 0.7).
130[ OK ] RenderGraph.constant_fold_separate_combine_hsv (0 ms)
131[ RUN ] RenderGraph.constant_fold_gamma
132I0819 14:19:45.347416 47208 constant_fold.cpp:58] Folding Gamma::Color to constant (0.164317, 0.353553, 0.585662).
133[ OK ] RenderGraph.constant_fold_gamma (0 ms)
134[ RUN ] RenderGraph.constant_fold_gamma_part_0
135I0819 14:19:45.347471 47208 constant_fold.cpp:58] Folding Gamma_xC::Color to constant (1, 1, 1).
136[ OK ] RenderGraph.constant_fold_gamma_part_0 (0 ms)
137[ RUN ] RenderGraph.constant_fold_gamma_part_1
138I0819 14:19:45.347525 47208 constant_fold.cpp:113] Folding Gamma_xC::Color to socket Attribute::Color.
139I0819 14:19:45.347532 47208 constant_fold.cpp:58] Folding Gamma_Cx::Color to constant (1, 1, 1).
140[ OK ] RenderGraph.constant_fold_gamma_part_1 (0 ms)
141[ RUN ] RenderGraph.constant_fold_bright_contrast
142I0819 14:19:45.347574 47208 constant_fold.cpp:58] Folding BrightContrast::Color to constant (0.16, 0.6, 1.04).
143[ OK ] RenderGraph.constant_fold_bright_contrast (0 ms)
144[ RUN ] RenderGraph.constant_fold_blackbody
145I0819 14:19:45.347617 47208 constant_fold.cpp:58] Folding Blackbody::Color to constant (3.94163, 0.226523, 0).
146[ OK ] RenderGraph.constant_fold_blackbody (0 ms)
147[ RUN ] RenderGraph.constant_fold_math
148I0819 14:19:45.347661 47208 constant_fold.cpp:46] Folding Math::Value to constant (1.6).
149[ OK ] RenderGraph.constant_fold_math (0 ms)
150[ RUN ] RenderGraph.constant_fold_math_clamp
151I0819 14:19:45.347702 47208 constant_fold.cpp:46] Folding Math::Value to constant (1.6).
152I0819 14:19:45.347708 47208 constant_fold.cpp:46] Folding clamp::Result to constant (1).
153/home/brecht/dev/worktree/intern/cycles/test/render_graph_finalize_test.cpp:988: Failure
154Actual function call count doesn't match EXPECT_CALL(log, Log(google::INFO, _, HasSubstr("Folding Math::Value to constant (1).")))...
155 Expected: to be called once
156 Actual: never called - unsatisfied and active
157[ FAILED ] RenderGraph.constant_fold_math_clamp (0 ms)
158[ RUN ] RenderGraph.constant_fold_part_math_add_0
159I0819 14:19:45.347771 47208 constant_fold.cpp:113] Folding Math_Cx::Value to socket Attribute::Fac.
160I0819 14:19:45.347779 47208 constant_fold.cpp:113] Folding Math_xC::Value to socket Attribute::Fac.
161[ OK ] RenderGraph.constant_fold_part_math_add_0 (0 ms)
162[ RUN ] RenderGraph.constant_fold_part_math_sub_0
163I0819 14:19:45.347833 47208 constant_fold.cpp:113] Folding Math_xC::Value to socket Attribute::Fac.
164[ OK ] RenderGraph.constant_fold_part_math_sub_0 (0 ms)
165[ RUN ] RenderGraph.constant_fold_part_math_mul_1
166I0819 14:19:45.347887 47208 constant_fold.cpp:113] Folding Math_Cx::Value to socket Attribute::Fac.
167I0819 14:19:45.347894 47208 constant_fold.cpp:113] Folding Math_xC::Value to socket Attribute::Fac.
168[ OK ] RenderGraph.constant_fold_part_math_mul_1 (0 ms)
169[ RUN ] RenderGraph.constant_fold_part_math_div_1
170I0819 14:19:45.347947 47208 constant_fold.cpp:113] Folding Math_xC::Value to socket Attribute::Fac.
171[ OK ] RenderGraph.constant_fold_part_math_div_1 (0 ms)
172[ RUN ] RenderGraph.constant_fold_part_math_mul_0
173I0819 14:19:45.348003 47208 constant_fold.cpp:46] Folding Math_Cx::Value to constant (0).
174I0819 14:19:45.348011 47208 constant_fold.cpp:46] Folding Math_xC::Value to constant (0).
175I0819 14:19:45.348014 47208 constant_fold.cpp:46] Folding Out::Value to constant (0).
176I0819 14:19:45.348019 47208 constant_fold.cpp:46] Folding clamp::Result to constant (0).
177I0819 14:19:45.348024 47208 constant_fold.cpp:132] Discarding closure EmissionNode.
178[ OK ] RenderGraph.constant_fold_part_math_mul_0 (1 ms)
179[ RUN ] RenderGraph.constant_fold_part_math_div_0
180I0819 14:19:45.348075 47208 constant_fold.cpp:46] Folding Math_Cx::Value to constant (0).
181I0819 14:19:45.348083 47208 constant_fold.cpp:113] Folding Out::Value to socket Math_xC::Value.
182/home/brecht/dev/worktree/intern/cycles/test/render_graph_finalize_test.cpp:1117: Failure
183Mock function called more times than expected - returning directly.
184 Function call: Log(0, @0x7ffcb11428f8 "/home/brecht/dev/worktree/intern/cycles/render/constant_fold.cpp", @0x7ffcb1142918 "Folding Out::Value to socket Math_xC::Value.")
185 Expected: to be never called
186 Actual: called once - over-saturated and active
187[ FAILED ] RenderGraph.constant_fold_part_math_div_0 (0 ms)
188[ RUN ] RenderGraph.constant_fold_part_math_pow_0
189I0819 14:19:45.348157 47208 constant_fold.cpp:46] Folding Math_xC::Value to constant (1).
190[ OK ] RenderGraph.constant_fold_part_math_pow_0 (0 ms)
191[ RUN ] RenderGraph.constant_fold_part_math_pow_1
192I0819 14:19:45.348214 47208 constant_fold.cpp:46] Folding Math_Cx::Value to constant (1).
193I0819 14:19:45.348222 47208 constant_fold.cpp:113] Folding Math_xC::Value to socket Attribute::Fac.
194[ OK ] RenderGraph.constant_fold_part_math_pow_1 (0 ms)
195[ RUN ] RenderGraph.constant_fold_vector_math
196I0819 14:19:45.348270 47208 constant_fold.cpp:58] Folding VectorMath::Vector to constant (3, 0, 0).
197I0819 14:19:45.348278 47208 constant_fold.cpp:58] Folding convert_vector_to_color::value_color to constant (3, 0, 0).
198[ OK ] RenderGraph.constant_fold_vector_math (0 ms)
199[ RUN ] RenderGraph.constant_fold_part_vecmath_add_0
200I0819 14:19:45.348332 47208 constant_fold.cpp:113] Folding Math_Cx::Vector to socket Attribute::Vector.
201I0819 14:19:45.348340 47208 constant_fold.cpp:113] Folding Math_xC::Vector to socket Attribute::Vector.
202[ OK ] RenderGraph.constant_fold_part_vecmath_add_0 (0 ms)
203[ RUN ] RenderGraph.constant_fold_part_vecmath_sub_0
204I0819 14:19:45.348397 47208 constant_fold.cpp:113] Folding Math_xC::Vector to socket Attribute::Vector.
205[ OK ] RenderGraph.constant_fold_part_vecmath_sub_0 (0 ms)
206[ RUN ] RenderGraph.constant_fold_part_vecmath_cross_0
207I0819 14:19:45.348455 47208 constant_fold.cpp:58] Folding Math_Cx::Vector to constant (0, 0, 0).
208I0819 14:19:45.348464 47208 constant_fold.cpp:58] Folding Math_xC::Vector to constant (0, 0, 0).
209I0819 14:19:45.348489 47208 constant_fold.cpp:58] Folding Out::Vector to constant (0, 0, 0).
210I0819 14:19:45.348495 47208 constant_fold.cpp:58] Folding convert_vector_to_color::value_color to constant (0, 0, 0).
211I0819 14:19:45.348501 47208 constant_fold.cpp:132] Discarding closure EmissionNode.
212[ OK ] RenderGraph.constant_fold_part_vecmath_cross_0 (0 ms)
213[ RUN ] RenderGraph.constant_fold_bump
214I0819 14:19:45.348553 47208 constant_fold.cpp:113] Folding Bump::Normal to socket Geometry1::Normal.
215[ OK ] RenderGraph.constant_fold_bump (0 ms)
216[ RUN ] RenderGraph.constant_fold_bump_no_input
217I0819 14:19:45.348600 47208 constant_fold.cpp:113] Folding Bump::Normal to socket geometry::Normal.
218[ OK ] RenderGraph.constant_fold_bump_no_input (0 ms)
219[ RUN ] RenderGraph.constant_fold_rgb_curves
220I0819 14:19:45.348649 47208 constant_fold.cpp:58] Folding Curves::Color to constant (0.275, 0.5, 0.475).
221[ OK ] RenderGraph.constant_fold_rgb_curves (0 ms)
222[ RUN ] RenderGraph.constant_fold_rgb_curves_fac_0
223I0819 14:19:45.348696 47208 constant_fold.cpp:113] Folding Curves::Color to socket Attribute::Color.
224[ OK ] RenderGraph.constant_fold_rgb_curves_fac_0 (0 ms)
225[ RUN ] RenderGraph.constant_fold_rgb_curves_fac_0_const
226I0819 14:19:45.348740 47208 constant_fold.cpp:58] Folding Curves::Color to constant (0.3, 0.5, 0.7).
227[ OK ] RenderGraph.constant_fold_rgb_curves_fac_0_const (0 ms)
228[ RUN ] RenderGraph.constant_fold_vector_curves
229I0819 14:19:45.348784 47208 constant_fold.cpp:58] Folding Curves::Vector to constant (0.275, 0.5, 0.475).
230I0819 14:19:45.348793 47208 constant_fold.cpp:58] Folding convert_vector_to_color::value_color to constant (0.275, 0.5, 0.475).
231[ OK ] RenderGraph.constant_fold_vector_curves (0 ms)
232[ RUN ] RenderGraph.constant_fold_vector_curves_fac_0
233I0819 14:19:45.348837 47208 constant_fold.cpp:113] Folding Curves::Vector to socket Attribute::Vector.
234[ OK ] RenderGraph.constant_fold_vector_curves_fac_0 (0 ms)
235[ RUN ] RenderGraph.constant_fold_rgb_ramp
236I0819 14:19:45.348886 47208 constant_fold.cpp:58] Folding Ramp::Color to constant (0.14, 0.39, 0.64).
237I0819 14:19:45.348894 47208 constant_fold.cpp:46] Folding Ramp::Alpha to constant (0.89).
238I0819 14:19:45.348899 47208 constant_fold.cpp:58] Folding convert_float_to_color::value_color to constant (0.89, 0.89, 0.89).
239I0819 14:19:45.348904 47208 constant_fold.cpp:58] Folding Mix::Color to constant (0.585, 0.835, 1.085).
240[ OK ] RenderGraph.constant_fold_rgb_ramp (0 ms)
241[ RUN ] RenderGraph.constant_fold_rgb_ramp_flat
242I0819 14:19:45.348953 47208 constant_fold.cpp:58] Folding Ramp::Color to constant (0.125, 0.375, 0.625).
243I0819 14:19:45.348961 47208 constant_fold.cpp:46] Folding Ramp::Alpha to constant (0.875).
244I0819 14:19:45.348966 47208 constant_fold.cpp:58] Folding convert_float_to_color::value_color to constant (0.875, 0.875, 0.875).
245I0819 14:19:45.348973 47208 constant_fold.cpp:58] Folding Mix::Color to constant (0.5625, 0.8125, 1.0625).
246[ OK ] RenderGraph.constant_fold_rgb_ramp_flat (0 ms)
247[ RUN ] RenderGraph.constant_fold_convert_float_color_float
248I0819 14:19:45.349020 47208 constant_fold.cpp:113] Folding Invert::Color to socket convert_float_to_color::value_color.
249I0819 14:19:45.349026 47208 constant_fold.cpp:113] Folding convert_color_to_float::value_float to socket Attribute::Fac.
250[ OK ] RenderGraph.constant_fold_convert_float_color_float (1 ms)
251[ RUN ] RenderGraph.constant_fold_convert_color_vector_color
252I0819 14:19:45.349077 47208 constant_fold.cpp:113] Folding VecAdd::Vector to socket convert_color_to_vector::value_vector.
253I0819 14:19:45.349084 47208 constant_fold.cpp:113] Folding convert_vector_to_color::value_color to socket Attribute::Color.
254[ OK ] RenderGraph.constant_fold_convert_color_vector_color (0 ms)
255[ RUN ] RenderGraph.constant_fold_convert_color_float_color
256I0819 14:19:45.349135 47208 constant_fold.cpp:113] Folding MathAdd::Value to socket convert_color_to_float::value_float.
257[ OK ] RenderGraph.constant_fold_convert_color_float_color (0 ms)
258[----------] 60 tests from RenderGraph (4 ms total)
259
260[----------] Global test environment tear-down
261[==========] 60 tests from 1 test case ran. (4 ms total)
262[ PASSED ] 58 tests.
263[ FAILED ] 2 tests, listed below:
264[ FAILED ] RenderGraph.constant_fold_math_clamp
265[ FAILED ] RenderGraph.constant_fold_part_math_div_0
266
267 2 FAILED TESTS
268<end of output>
269Test time = 0.01 sec
270----------------------------------------------------------
271Test Failed.
272"cycles_render_graph_finalize_test" end time: Aug 19 14:19 CEST
273"cycles_render_graph_finalize_test" time elapsed: 00:00:00
274----------------------------------------------------------

intern/cycles/kernel/shaders/node_vector_math.osl
33–34

Code style: len_squared

This revision now requires changes to proceed.Tue, Aug 20, 12:29 PM
  • Clean Up: Follow code style.

@Brecht Van Lommel (brecht) I will fix those regression tests in a separate patch as they are related to the Math node.

Ah ok, did not notice the test was already failing.

Some of the removed functionality was convenient even if poorly named.

  • There were effectively "Average Normal" and "Orthogonal Normal" operations with Average and Cross.
  • "Normalize" providing a length as output is quite convenient if you want to decompose a vector into a unit vector and length. If the float output was named "Length" it would have been clear.

I don't want this to block the patch, but might be interesting to consider adding them back with better names.

This revision is now accepted and ready to land.Wed, Aug 21, 6:42 PM

@Brecht Van Lommel (brecht) Ok, I will create a patch for those. But I need a bit more details, in particular:

  • Shouldn't we normalize the input vectors in the Average operator if we want to compute the "Average Normal"? Or is it meant to be a weighted average of some sort?
  • The Cross Product wasn't removed, are you talking about the fact that it is no longer normalized? I just thought that it makes sense not to normalize the output, the cross product operator should just do a cross product, nothing more.
  • The problem is that the output value is used by more than one operator. I wounder if we can dynamically rename sockets somehow. Would that mess something up?

The normals indeed would have to be normalized on input as well probably, even if in most cases they'd already be normalized. I'm also not sure about the Length output renaming.

Probably best to focus on getting the existing patches in, this isn't really that important.