Ronald Vermeij (indigowarrior9)

7 replies · posted

Blender Cycles - Technical (developer) question about various types of Cycles Shader data-streams

Hello All,
I'm currently "hacking" Cycles to fully understand how it works (right down to the source_code), so I can fully maximize its awesome rendering potential for my own future blender projects. Here's how I am currently progressing and where I get stuck

Fig 1 - Default Blender Scene, (1 cube, sunlight, camera and wood-texture (jpg-file) on the Cube via the Cycles Node Editor)

In Fig.1 - Here you can literally see a visualization of what the yellow type of "Color" (input/output) information.

In order to fully understand which type of (internal) Shader data streams Cycles uses I've have analyzed all existing Cycles Nodes, their inputs and outputs and their data-stream types or  "Shader sockets".

Fig. 2 - Color (yellow) data Input/output streams.

Fig. 3 - Shader (green) data Input/output streams.

Fig. 4 - Vector ?? (purple) data Input/output streams.

Fig 5 - ?? (grey ) data Input/output streams.

Why do I do this?
- To understand which type-of-datastream/shader-socket is generated by any Cycles Node output.
- To understand which type-of-datastream/shader-socket can be accepted by a given Cycles Node input.
- What type of data a stream acutally holds (bits, bytes, floats, vectors, pixels, shader-data)

Where am I getting stuck and why?
So far the official
- Blender Wiki
- Blender online end-user manual
- Developer-level documentation over Cycles
all fail to mention the different type of data which is contained in/ carried the Cycles Shader sockets.

So I went a step further and downloaded the entire Blender (2.79a) Source code package and started looking for the exact definition of those Cycles Shader data types ... and found this information (os far):

Fig 6 - Blender Shader sockets information, located in various source code-files

So now my question to you all is:
Where must I look (further) to find the exact documenation / definitions of the Shader sockets, when it is not documented in any official Blender (developer, manual) source and its own source-code-files?

Thanks in advance for your hints, tips, and tricks to get me closer to demistifing the Cycles Sockets data_types.

  • Anyone?

  • I've never looked at the Blender source code, but I'm a professional C++ developer. I'm not 100% sure that I understand your question though. 

    Are you trying to determine, for example, how a "Size" or "Displacement" is coded from a memory perspective? If so I can take a peek at the source and see if they are defined in some central place that I can point you to.

    Or are you asking more like "what is an unsigned integer?" or "what is a boolean?" If this is more your question then a good place to start is here:

  • Hello Catherine,
    Nice to know that you are already a C++ pro.. I'm currently busy reviving my (25 years ago) old C-skills, in order to start some serious digging and reading into the Blender source-code.

    What I initially wanted to understand is:
    - How Cycles works under the hood.
    - What type of (image, color, vector) data is being transported between the various nodes.
    - Why one can connect one color node output-stream into another (different) color node-input
    Since the official Blender "manual" seriously lacks this type of information (if any info is present at all :-})

    I'm not looking for any kind of information about C-datatypes. but thanks for the reference to the website
    It is a very informative place to learn from.

    • Ah I see! Yeah sorry for the basic info then I was a bit confused by your question. I'll take a look though my initial thought is that all data between nodes in Cycles is most likely an array of floats. I'm going to go out on a limb and guess that the nodes are basically wrappers around GLSL shader scripts ( which typically operate on floats within the C-like scrips.

       So while I don't know for certain, having not yet looked at the source, I would guess that an understanding of GLSL will translate pretty easily to understanding of cycles.

      Not sure if that helps though, I'll probably be looking at the source to Blender in the near future myself (though not as much in shaders, more on geometry) 

  • Thanks Catherine for the GLSL references (I did not get to this point yet).

    Q: What are your personal interests, regarding Blender geometry?

  • Sure :-) GLSL is really neat. It's kind of what makes all this cool impressive graphics stuff possible IMHO. Like I said I don't know for sure that Cycles is directly using it or is directly based on it. Its quite possible that there is an abstraction layer in between allowing both GLSL and other implementations under the hood, though as I mention I'd be quite surprised if an understanding of GLSL doesn't pretty directly translate into understanding the internals of the node trees.

    I made a post here:

    regarding a project I hope to do using Blender. Most likely it will be largely in Python, however, using tensorflow but that is just speculation as I have a lot of research to do before deciding for certain on a language and toolkit (or even if I do want to pursue this path)

    • catherineirkalla : "Like I said I don't know for sure that Cycles is directly using it or is directly based on it. Its quite possible that there is an abstraction layer in between allowing both GLSL and other implementations under the hood, "

      I do not know either (yet) but will get to the bottom of this later in 2019.
      I'm planning to do a little C, C++ OpenGL coding myself, just to be able fully understand the stuff under the Blender hood.