Object Info node support for GLSL mode and the internal render
ClosedPublic

Authored by Alexander Romanov (a.romanov) on Dec 21 2016, 6:46 PM.

Details

Summary

Object Info node can be useful to give some variation to a single material assigned to multiple instances. This patch adds support for Viewport and BI.

Example:

Diff Detail

Repository
rB Blender

Update for the current master

Brecht Van Lommel (brecht) requested changes to this revision.Sun, Apr 9, 6:52 PM

Looks generally fine to me, always nice to have more complete GLSL support.

source/blender/blenkernel/intern/object_dupli.c
184

Can you add a comment that the logic here is designed to match Cycles?

Or even better, expose this random number in RNA so Cycles and other renderers can use it instead of duplicating code.

source/blender/gpu/intern/gpu_draw.c
1909–1910

Code convention is to always use {}

source/blender/render/intern/source/renderdatabase.c
1463–1464

Code convention is to always use {}.

This revision now requires changes to proceed.Sun, Apr 9, 6:52 PM
  1. Fixed style
  2. random_id added to RNA. Now it is interpreted as signed int on Python side (regardless PROP_UNSIGNED). We can leave it as is, or make convertion to float [0,1]. What could be the best solution?

I think it should be unsigned int as you did. It's what I would expect anyways, we don't want different colors assigned to materials because of float precision problems.
Do you know how to make Cycles to use this RNA value?

Do you know how to make Cycles to use this RNA value?

First, I don't know how to return it as unsigned to Python.

We don't have an unsigned int type in RNA, but exposing it as an int should be fine. In practice casting unsigned int -> int -> unsigned int is a no-op.

Using expanded random_id in Cycles

Update for the current state of master branch

Great, looks good to me now. I confirmed the random values in Cycles stayed the same.

This revision is now accepted and ready to land.Fri, Apr 14, 4:13 PM
This revision was automatically updated to reflect the committed changes.