Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(76)

Issue 12177043: Cycles shading nodes soc-2013

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 9 months ago by brechtvl
Modified:
10 years, 9 months ago
Reviewers:
bf-codereview
CC:
blender_dingto.org
Base URL:
https://svn.blender.org/svnroot/bf-blender/trunk/blender/
Visibility:
Public.

Description

Cycles shading nodes soc-2013

Patch Set 1 #

Total comments: 24
Unified diffs Side-by-side diffs Delta from patch set Stats (+1506 lines, -58 lines) Patch
M intern/cycles/blender/addon/ui.py View 7 chunks +11 lines, -9 lines 0 comments Download
M intern/cycles/blender/blender_session.cpp View 3 chunks +6 lines, -0 lines 0 comments Download
M intern/cycles/blender/blender_shader.cpp View 3 chunks +17 lines, -0 lines 0 comments Download
M intern/cycles/blender/blender_sync.cpp View 1 chunk +1 line, -1 line 0 comments Download
M intern/cycles/device/device.h View 2 chunks +2 lines, -0 lines 0 comments Download
M intern/cycles/device/device_cpu.cpp View 1 chunk +1 line, -0 lines 0 comments Download
M intern/cycles/device/device_cuda.cpp View 1 chunk +1 line, -0 lines 0 comments Download
M intern/cycles/device/device_multi.cpp View 2 chunks +2 lines, -0 lines 0 comments Download
M intern/cycles/kernel/CMakeLists.txt View 2 chunks +3 lines, -0 lines 0 comments Download
M intern/cycles/kernel/kernel_accumulate.h View 3 chunks +7 lines, -0 lines 0 comments Download
M intern/cycles/kernel/kernel_displace.h View 1 chunk +1 line, -1 line 0 comments Download
M intern/cycles/kernel/kernel_emission.h View 9 chunks +10 lines, -10 lines 2 comments Download
M intern/cycles/kernel/kernel_object.h View 1 chunk +10 lines, -0 lines 0 comments Download
M intern/cycles/kernel/kernel_passes.h View 3 chunks +8 lines, -0 lines 0 comments Download
M intern/cycles/kernel/kernel_path.h View 13 chunks +13 lines, -13 lines 1 comment Download
M intern/cycles/kernel/kernel_shader.h View 8 chunks +36 lines, -5 lines 1 comment Download
M intern/cycles/kernel/kernel_textures.h View 1 chunk +55 lines, -0 lines 0 comments Download
M intern/cycles/kernel/kernel_types.h View 8 chunks +32 lines, -4 lines 3 comments Download
M intern/cycles/kernel/osl/osl_services.h View 1 chunk +1 line, -0 lines 0 comments Download
M intern/cycles/kernel/osl/osl_services.cpp View 3 chunks +7 lines, -1 line 2 comments Download
M intern/cycles/kernel/shaders/CMakeLists.txt View 3 chunks +4 lines, -0 lines 0 comments Download
A intern/cycles/kernel/shaders/node_blackbody.osl View 1 chunk +31 lines, -0 lines 1 comment Download
A intern/cycles/kernel/shaders/node_combine_hsv.osl View 1 chunk +29 lines, -0 lines 0 comments Download
M intern/cycles/kernel/shaders/node_light_path.osl View 2 chunks +3 lines, -1 line 1 comment Download
A intern/cycles/kernel/shaders/node_separate_hsv.osl View 1 chunk +33 lines, -0 lines 0 comments Download
A intern/cycles/kernel/shaders/node_vector_transform.osl View 1 chunk +36 lines, -0 lines 3 comments Download
M intern/cycles/kernel/svm/svm.h View 6 chunks +15 lines, -0 lines 0 comments Download
A intern/cycles/kernel/svm/svm_blackbody.h View 1 chunk +83 lines, -0 lines 3 comments Download
M intern/cycles/kernel/svm/svm_image.h View 1 chunk +54 lines, -0 lines 0 comments Download
M intern/cycles/kernel/svm/svm_light_path.h View 1 chunk +1 line, -0 lines 0 comments Download
A intern/cycles/kernel/svm/svm_sepcomb_hsv.h View 1 chunk +56 lines, -0 lines 0 comments Download
M intern/cycles/kernel/svm/svm_types.h View 5 chunks +23 lines, -1 line 0 comments Download
A intern/cycles/kernel/svm/svm_vector_transform.h View 1 chunk +98 lines, -0 lines 1 comment Download
M intern/cycles/render/CMakeLists.txt View 2 chunks +2 lines, -0 lines 0 comments Download
A intern/cycles/render/blackbody.h View 1 chunk +30 lines, -0 lines 0 comments Download
A intern/cycles/render/blackbody.cpp View 1 chunk +140 lines, -0 lines 0 comments Download
M intern/cycles/render/film.cpp View 6 chunks +25 lines, -0 lines 0 comments Download
M intern/cycles/render/graph.h View 1 chunk +1 line, -0 lines 0 comments Download
M intern/cycles/render/image.h View 3 chunks +6 lines, -2 lines 0 comments Download
M intern/cycles/render/image.cpp View 1 chunk +9 lines, -4 lines 0 comments Download
M intern/cycles/render/nodes.h View 4 chunks +30 lines, -0 lines 1 comment Download
M intern/cycles/render/nodes.cpp View 6 chunks +165 lines, -1 line 0 comments Download
M intern/cycles/render/scene.h View 1 chunk +2 lines, -2 lines 0 comments Download
M intern/cycles/render/scene.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M intern/cycles/render/shader.h View 2 chunks +2 lines, -0 lines 0 comments Download
M intern/cycles/render/shader.cpp View 7 chunks +26 lines, -0 lines 0 comments Download
M intern/cycles/render/svm.cpp View 2 chunks +6 lines, -0 lines 1 comment Download
M release/datafiles/splash.png View Binary file 0 comments Download
M release/scripts/startup/nodeitems_builtins.py View 2 chunks +4 lines, -0 lines 0 comments Download
M source/blender/blenkernel/BKE_node.h View 2 chunks +7 lines, -0 lines 1 comment Download
M source/blender/blenkernel/intern/node.c View 2 chunks +4 lines, -0 lines 0 comments Download
M source/blender/editors/space_node/drawnode.c View 2 chunks +10 lines, -0 lines 0 comments Download
M source/blender/gpu/shaders/gpu_shader_material.glsl View 2 chunks +3 lines, -1 line 0 comments Download
M source/blender/makesdna/DNA_node_types.h View 2 chunks +18 lines, -0 lines 1 comment Download
M source/blender/makesdna/DNA_scene_types.h View 1 chunk +3 lines, -0 lines 0 comments Download
M source/blender/makesrna/intern/rna_nodetree.c View 1 chunk +42 lines, -0 lines 1 comment Download
M source/blender/makesrna/intern/rna_render.c View 1 chunk +3 lines, -0 lines 0 comments Download
M source/blender/makesrna/intern/rna_scene.c View 1 chunk +18 lines, -0 lines 0 comments Download
M source/blender/nodes/CMakeLists.txt View 1 chunk +3 lines, -0 lines 0 comments Download
M source/blender/nodes/NOD_shader.h View 3 chunks +4 lines, -0 lines 0 comments Download
M source/blender/nodes/NOD_static_types.h View 2 chunks +4 lines, -0 lines 0 comments Download
M source/blender/nodes/composite/nodes/node_composite_image.c View 3 chunks +13 lines, -0 lines 0 comments Download
A source/blender/nodes/shader/nodes/node_shader_blackbody.c View 1 chunk +54 lines, -0 lines 0 comments Download
M source/blender/nodes/shader/nodes/node_shader_light_path.c View 1 chunk +1 line, -0 lines 0 comments Download
A source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c View 1 chunk +80 lines, -0 lines 0 comments Download
A source/blender/nodes/shader/nodes/node_shader_vectTransform.c View 1 chunk +66 lines, -0 lines 0 comments Download
M source/blender/render/intern/source/render_result.c View 3 chunks +33 lines, -0 lines 1 comment Download

Messages

Total messages: 2
brechtvl
10 years, 9 months ago (2013-07-31 16:38:27 UTC) #1
brechtvl
10 years, 9 months ago (2013-07-31 17:22:17 UTC) #2
Overall looks good to me, see inline comments for things to fix.

The only thing that I don't think is ready to merge after fixes is the
non-progressive mode for CUDA. That needs to become a separate kernel first.

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/kernel_em...
File intern/cycles/kernel/kernel_emission.h (left):

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/kernel_em...
intern/cycles/kernel/kernel_emission.h:45: eval = shader_eval_background(kg,
&sd, 0, SHADER_CONTEXT_EMISSION);
This should be bounce+1, same for the two calls to shader_setup_from_sample
later in this function.

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/kernel_em...
File intern/cycles/kernel/kernel_emission.h (right):

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/kernel_em...
intern/cycles/kernel/kernel_emission.h:243: shader_setup_from_background(kg,
&sd, ray, bounce);
Make this bounce+1.

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/kernel_pa...
File intern/cycles/kernel/kernel_path.h (right):

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/kernel_pa...
intern/cycles/kernel/kernel_path.h:218: shader_setup_from_ray(kg, &sd, &isect,
ray, state->bounce);
This should be state->bounce+1, as you're doing shading at the next bounce, not
the current shading point.

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/kernel_sh...
File intern/cycles/kernel/kernel_shader.h (right):

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/kernel_sh...
intern/cycles/kernel/kernel_shader.h:959: #ifdef __KERNEL_GPU__
Remove this #ifdef and just use this loop for both CPU and GPU.

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/kernel_ty...
File intern/cycles/kernel/kernel_types.h (right):

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/kernel_ty...
intern/cycles/kernel/kernel_types.h:51: #define BB_TABLE_SPACING 2.0
Align the values with spaces like for BSSRDF.

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/kernel_ty...
intern/cycles/kernel/kernel_types.h:558: float ray_depth;
Can you keep this as an int and do the cast to float when needed? Is a tiny bit
faster but also just makes more sense to have it as in I think, only reason it
needs to be cast to float is because svm doesn't support integer sockets.

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/kernel_ty...
intern/cycles/kernel/kernel_types.h:831: typedef struct KernelBLACKBODY {
Rename to KernelBlackbody without the all caps.

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/osl/osl_s...
File intern/cycles/kernel/osl/osl_services.cpp (right):

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/osl/osl_s...
intern/cycles/kernel/osl/osl_services.cpp:667: return set_attribute_float(f,
type, derivatives, val);
This should be set_attribute_int.

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/osl/osl_s...
intern/cycles/kernel/osl/osl_services.cpp:928: shader_setup_from_ray(kg, sd,
&tracedata->isect, &tracedata->ray, -1);
To get the bounce value here, you could do:

ShaderData *original_sd = (ShaderData *)(sg->renderstate);
bounce = original_sd->ray_depth + 1;

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/shaders/n...
File intern/cycles/kernel/shaders/node_blackbody.osl (right):

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/shaders/n...
intern/cycles/kernel/shaders/node_blackbody.osl:29: Color = rgb /= l;
Check for division by zero here:

float l = luminance(rgb);
if (l != 0.0)
    rgb /= l;
Color = rgb;

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/shaders/n...
File intern/cycles/kernel/shaders/node_light_path.osl (right):

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/shaders/n...
intern/cycles/kernel/shaders/node_light_path.osl:41:
getattribute("path:ray_depth", RayDepth);
Make this:

int ray_depth;
getattribute("path:ray_depth", ray_depth);
RayDepth = (float)ray_depth;

Kind of stupid but we must keep the sockets float for now, while at the same
time it's best to have integer values as integers.

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/shaders/n...
File intern/cycles/kernel/shaders/node_vector_transform.osl (right):

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/shaders/n...
intern/cycles/kernel/shaders/node_vector_transform.osl:24: string convert_to =
"Object",
Can you make these lowercase "world" and "object". Not that they are actually
uses in practice but is nice if they match valid values.

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/shaders/n...
intern/cycles/kernel/shaders/node_vector_transform.osl:29: VectorOut =
transform(convert_from, convert_to, VectorIn);
Thinking about this there is a 3rd type that makes sense, "Normal", which
automatically normalizes after the transform. The code would be:

if (type == "Vector" || type == "Normal) {
    VectorOut = transform(convert_from, convert_to, VectorIn);
    if (type == "Normal")
        VectorOut = normalize(VectorOut);
}

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/shaders/n...
intern/cycles/kernel/shaders/node_vector_transform.osl:32: point Point =
point(VectorIn[0], VectorIn[1], VectorIn[2]);
I think you can just cast like this?
point Point = (point)VectorIn;

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/svm/svm_b...
File intern/cycles/kernel/svm/svm_blackbody.h (right):

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/svm/svm_b...
intern/cycles/kernel/svm/svm_blackbody.h:52: const float lookuptablesizef =
956.0f;
You can replace this with

const float lookuptablenormalize = 1.0f/956.0f;

and then do:

float lutval = t*lookuptablenormalize;

The compiler in general can't replace a division by a multiplication for you
because then it doesn't follow the IEEE specification, but we can do it manually
like this.

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/svm/svm_b...
intern/cycles/kernel/svm/svm_blackbody.h:56: float t = powf ((temperature -
BB_DRAPPER) / BB_TABLE_SPACING, 1.0f/BB_TABLE_XPOWER);
Similar optimization here, you can make this:
float t = powf((temperature - BB_DRAPPER) * (1.0f / BB_TABLE_SPACING),
1.0f/BB_TABLE_XPOWER));

It can do the division compile time then and only do the multiplication at
runtime.

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/svm/svm_b...
intern/cycles/kernel/svm/svm_blackbody.h:77: color_rgb /= l;
Check for division by zero here like in OSL shader.

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/svm/svm_v...
File intern/cycles/kernel/svm/svm_vector_transform.h (right):

https://codereview.appspot.com/12177043/diff/1/intern/cycles/kernel/svm/svm_v...
intern/cycles/kernel/svm/svm_vector_transform.h:38: int is_object = (sd->object
!= ~0);
Can make this "bool is_object".

https://codereview.appspot.com/12177043/diff/1/intern/cycles/render/nodes.h
File intern/cycles/render/nodes.h (right):

https://codereview.appspot.com/12177043/diff/1/intern/cycles/render/nodes.h#n...
intern/cycles/render/nodes.h:517: static ShaderEnum convert_to_enum;
convert_from_enum and convert_to_enum can be a single convert_space_enum. They
have the same values so there's no need to define them twice.

https://codereview.appspot.com/12177043/diff/1/intern/cycles/render/svm.cpp
File intern/cycles/render/svm.cpp (right):

https://codereview.appspot.com/12177043/diff/1/intern/cycles/render/svm.cpp#n...
intern/cycles/render/svm.cpp:395: current_shader->has_converter_blackbody =
true;
Can you move this check inside   if(inputs_done) {
Right before   node->compile(*this);

Doesn't matter much but seems more logical there.

https://codereview.appspot.com/12177043/diff/1/source/blender/blenkernel/BKE_...
File source/blender/blenkernel/BKE_node.h (right):

https://codereview.appspot.com/12177043/diff/1/source/blender/blenkernel/BKE_...
source/blender/blenkernel/BKE_node.h:811: #define RRES_OUT_SUBS_COLOR			30
Can you use SUBSURFACE instead of SUBS as abbreviation? SUBS is not so obvious
to me.

https://codereview.appspot.com/12177043/diff/1/source/blender/makesdna/DNA_no...
File source/blender/makesdna/DNA_node_types.h (right):

https://codereview.appspot.com/12177043/diff/1/source/blender/makesdna/DNA_no...
source/blender/makesdna/DNA_node_types.h:882: #define
SHD_VECT_TRANSFORM_FROM_WORLD	0
Same comment here as in nodes.cpp, this can actually be a single enum instead of
having separate ones for to/from.

https://codereview.appspot.com/12177043/diff/1/source/blender/makesrna/intern...
File source/blender/makesrna/intern/rna_nodetree.c (right):

https://codereview.appspot.com/12177043/diff/1/source/blender/makesrna/intern...
source/blender/makesrna/intern/rna_nodetree.c:3527: static EnumPropertyItem
prop_vect_to_items[] = {
Same comment as before, this can be a single enum.

https://codereview.appspot.com/12177043/diff/1/source/blender/render/intern/s...
File source/blender/render/intern/source/render_result.c (right):

https://codereview.appspot.com/12177043/diff/1/source/blender/render/intern/s...
source/blender/render/intern/source/render_result.c:283: if (channel == -1)
return "SubsDir";
Can you use SubsurfaceDir here? There used to be a limit on the name length but
that is actually gone now.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b