Coding a texture node with a reference

Hello guys!
So: I am currently trying to understand what a material node consists of in the code, and if I get there, to implement one myself. So, I took the gabor noise node diff as a reference ( ). Yet, I don’t understand some things. Most lines I had to add were for registering the new files.
For example, I don’t understands what the necessary ingredients in gpu_material_shader.glsl, node_gabor_texture.osl, svm_gabortex.c are. They seem to be more or less duplicates to me. I don’t know what the functions do or what the parameters and return types mean. Could you give me some insight? For example, it would be helpful to know which function actually finally creates the texture, and how I could build my structure of helper and utils functions around that one. This question is likely rather broad, and I apologise for that, but I don’t know well how to describe it. If you need clarification, please ask.

There’s a few subsystems that need to know about any new texture, so you end up implementing it a few times over.

the changes in gpu_material_shader.glsl are needed for rendering it in the opengl viewport.
the node_gabor_texture.osl, file is the code needed for osl support
and the svm_gabortex.c file is the code for rendering it in cycles.

adding a new texture to cycles is more work than you’d think since you end up writing at-least 3 different implementations and you’d have to test on viewport/osl/cycles cpu/cycles gpu cuda/cycles gpu opencl

@LazyDodo is right about having to code the texture three times as Cycles has two render systems, one that uses OSL and one that uses it’s own SVM engine. The GLSL is used for Eevee and the viewport. They should all give the same results. Mostly the code is the same but there are coded in different languages. E.g. float3, vec3 and point are all used to handle a variable comprised of three floats. Most of the other code is there to create the node itself and register the node in Blenders RNA/DNA so it can be animated etc.

You could also look at the following patch that extends the existing Voronoi node. See:

Here are some brief notes I made when I made the patches you are referencing. Hope it helps and good luck!

nodes.h : Cycles node class and variables here
blender_shader.cpp : additional props here — non socket stuff (No warnings when building)
drawnode.c : non socket rna stuff
node_shader_xxx_… : definitions and sockets and GPU…sockets and glsl function should be in same order
rna_nodetree.c : rna stuff
DNA_node_types.h : DNA for enums etc
nodes.cpp : cycles socket and OSL params — non socket stuff compiler.parameter(this, “foobar”); (No warnings when building)
svm_types.h : cycles enums : UI menu
svm.h : node function
node_xxx…osl : variable names are case sensitive

Thanks, I will look into it and ask more questions here when they appear (which they surely do).