Page MenuHome

Shading: Interpolation node
Needs ReviewPublic

Authored by Charlie Jolly (charlie) on Tue, Sep 17, 6:34 PM.
Tags
None
Tokens
"Love" token, awarded by Ristovski."Love" token, awarded by intracube."Like" token, awarded by knightknight."Love" token, awarded by thiagodesul."Love" token, awarded by viadvena."100" token, awarded by valera."Like" token, awarded by JayE01."Love" token, awarded by astroblitz."Love" token, awarded by 100drips."Burninate" token, awarded by CAEL."Mountain of Wealth" token, awarded by TheAngerSpecialist."Love" token, awarded by looch."Love" token, awarded by brilliant_ape."Love" token, awarded by linolafett."Like" token, awarded by rjg."Party Time" token, awarded by mazigh."Love" token, awarded by klutz."Love" token, awarded by misiewiczradoslaw."Love" token, awarded by dbystedt."Burninate" token, awarded by zanqdo."Love" token, awarded by R2792."Love" token, awarded by wuzzle."Love" token, awarded by dpdp."Love" token, awarded by MizManFryingP."Like" token, awarded by nacioss."Love" token, awarded by abdoubouam."Love" token, awarded by phalaris."Love" token, awarded by Linkun."Love" token, awarded by jskksj."Love" token, awarded by Thane5."Love" token, awarded by quollism."Love" token, awarded by shakesoda."Love" token, awarded by Draise."Love" token, awarded by Zino."Love" token, awarded by julperado."Love" token, awarded by andruxa696."Love" token, awarded by ChrisGraz."Love" token, awarded by LapisSea."Love" token, awarded by carlosmu."Love" token, awarded by Schamph."Love" token, awarded by fin.eskimo."Love" token, awarded by ogierm."Orange Medal" token, awarded by Alrob."Love" token, awarded by Taros."Love" token, awarded by mantissa."Love" token, awarded by MetinSeven."Love" token, awarded by Kramon."Love" token, awarded by CGKrisu."Love" token, awarded by zeffii."Love" token, awarded by BlenderBrit."Love" token, awarded by Samirosman."Love" token, awarded by davidmcsween."Love" token, awarded by simonthommes."Love" token, awarded by tilapiatsu."Love" token, awarded by monio.

Details

Summary

This adds a float interpolation node with multiple options.

Linear interpolation, smooth linear, stepped linear, smoothstep/smootherstep and inverse linear. See image below.

Diff Detail

Repository
rB Blender
Branch
master
Build Status
Buildable 5356
Build 5356: arc lint + arc unit

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Charlie Jolly (charlie) edited the summary of this revision. (Show Details)Tue, Sep 17, 6:36 PM

Looks good, here is my initial review.

intern/cycles/kernel/shaders/node_interpolate.osl
26

Looks like Factor / (1.0 / (Steps + 1.0))) can be simplified to Factor * (Steps + 1.0). Also, I think you should clamp the Factor instead of clamping the final result.

29

I would just consider this as an invalid case. It can be confusing for the end-user and isn't immediately clear.

intern/cycles/kernel/svm/svm_interpolate.h
43

No need to check if the stack offset is valid.

intern/cycles/kernel/svm/svm_types.h
311

Style: Comma at the end.

source/blender/makesrna/intern/rna_nodetree.c
197

Provide more detailed tool tips.

3942

Better call this interpolation_type.

source/blender/nodes/shader/nodes/node_shader_interpolate.c
30

I would rename those to Start and End.

33

I would move the Factor to the top of the socket list so that it gets connected automatically. Also, if the Factor input is in the [0, 1] range, we should use PROP_FACTOR.

Charlie Jolly (charlie) marked 8 inline comments as done.Wed, Sep 18, 12:11 PM
Charlie Jolly (charlie) added inline comments.
intern/cycles/kernel/shaders/node_interpolate.osl
26

Thanks for the simplification. It is clamping the factor in this case.

source/blender/nodes/shader/nodes/node_shader_interpolate.c
33

Factor input may not be in [0-1] range.

Charlie Jolly (charlie) marked 2 inline comments as done.

Address review comments

intern/cycles/render/nodes.cpp
5725

No need for if_linked here.

5728

Pass the type as the second argument and encode the factor_stack_offset in the uchar4 instead.

Charlie Jolly (charlie) marked 2 inline comments as done.Wed, Sep 18, 7:06 PM

Tidy up and address comments.
Also add linearstep as a compliment to smoothstep.
Add extrapolate option to linear and stepped interpolation.

Fix clamping error when start is greater than end.

Charlie Jolly (charlie) updated this revision to Diff 18983.EditedSun, Oct 13, 8:40 AM

Changes based on user feedback from @Bartosz Moniewski (monio)

Change extrapolate to clamp.
Rename linearstep to inverse linear. Same as linearstep when clamped.
Add smootherstep function.

Missing glsl dependency. Didn't show up as the test file had another node with the required dependency.

Add node label support.