How to Start Developing Blender#

Peter Sergay ‘22#

This semester, I learned to develop Blender. I started with some knowledge of coding and C++, but had never really used Git or ever looked at Blender’s daunting source code. Here is a guide for other students interested in developing Blender for themselves. This guide is only a supplement to the Blender Wiki’s guide to build Blender--think of it like a strategy for how to follow the instructions, not the instructions themselves.

Snap back to reality: Before beginning your journey of developing Blender, here are some prerequisites.

  1. You should be quite comfortable using the Blender software - if not, spend more time creating within Blender.
  2. You don’t have to have taken CS courses at Middlebury, but you should have some experience coding with Python and/or C/C++.
  3. It helps if you’ve used VS Code in the past.
  4. Developing Blender does NOT equal creating art with Blender. It’s a profoundly different adventure with a steeper learning curve than Blender the software.
  5. You’ll have to leave your ego at the door to some extent. The core developers are much better than you. Be prepared to search for something new to work on after a core developer quickly fixes a bug you were hoping to fix yourself. Often, being the one to take initiative on a bug is just as valuable as being the one to find the final solution.

Read through this entire guide without clicking any links, then start back at the beginning.

Step 0 (IMPORTANT): Familiarize yourself with the command line (shell). At minimum, you should be able to use cd and ls to navigate through your files. Make sure you have admin rights on the computer you’re using.

Step 1: Go to the New Developer Info page on the Blender wiki. Read through it, but don’t click any links. That’s TMI for now.

Step 2: Then, go to the Building Blender page. Follow the instructions for your operating system. I recommend using Visual Studio Code as your development environment for both Windows and Mac.

Note: For MacOS, I wasn’t able to get Blender working as an XCode project. That’s why I recommend VS Code. Don’t install the entire XCode application (it’s 30 GB), just install the command line tools (see the Advanced Setup section in the MacOS setup guide). You also need three VS Code addons:

  1. C/C++
  2. Python
  3. GitLens

GitLens lets you click on any piece of code, and you’ll see who wrote the code and when. It’s useful for tracking changes, and you can even contact the author of a piece of code that you’re interested in changing!

Progress Check: After following the instructions for building Blender, You should now have on your computer…#

Troubleshooting 1#

Homebrew permissions:

When using Homebrew to install CMake and SVN on a school computer, you may encounter this error:

psergay@MIDD-11209 ~ % brew install cmake
Error: /usr/local/Cellar is not writable.

You should change the ownership and permissions of /usr/local/Cellar back to your user account: sudo chown -R $(whoami) /usr/local/Cellar

Warning: Treating cmake as a formula. For the cask, use homebrew/cask/cmake
Error: The following directories are not writable by your user:
/usr/local/Cellar
/usr/local/Frameworks
/usr/local/Homebrew
/usr/local/bin
/usr/local/etc
/usr/local/etc/bash_completion.d
/usr/local/include
/usr/local/lib
/usr/local/lib/pkgconfig
/usr/local/opt
/usr/local/sbin
/usr/local/share
/usr/local/share/aclocal
/usr/local/share/doc
/usr/local/share/info
/usr/local/share/locale
/usr/local/share/man
/usr/local/share/man/man1
/usr/local/share/man/man3
/usr/local/share/man/man5
/usr/local/share/man/man8
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
/usr/local/var/homebrew/linked
/usr/local/var/homebrew/locks

You should change the ownership of these directories to your user.

sudo chown -R $(whoami) /usr/local/Cellar /usr/local/Frameworks /usr/local/Homebrew /usr/local/bin /usr/local/etc /usr/local/etc/bash_completion.d /usr/local/include /usr/local/lib /usr/local/lib/pkgconfig /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/share/aclocal /usr/local/share/doc /usr/local/share/info /usr/local/share/locale /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man8 /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew/linked /usr/local/var/homebrew/locks

And make sure that your user has write permission.

chmod u+w /usr/local/Cellar /usr/local/Frameworks /usr/local/Homebrew /usr/local/bin /usr/local/etc /usr/local/etc/bash_completion.d /usr/local/include /usr/local/lib /usr/local/lib/pkgconfig /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/share/aclocal /usr/local/share/doc /usr/local/share/info /usr/local/share/locale /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man8 /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew/linked /usr/local/var/homebrew/locks

In this case, try to run the two highlighted commands that the error message gives you to change ownership of those directories to enable writing to them. Don’t copy and paste the commands directly from this document, use the ones that your own Terminal returns. If Terminal doesn’t let you run them, get Daniel to give you administrator (sudo) privileges. Once you have admin rights, you should be able to successfully change ownership. Make sure you retry the brew install cmake svn command after getting admin rights to get an updated (smaller) list of directories it wants you to change ownership for.

Tip: A good way to check ownership of directories is to use the ls -l (“-long”) command in the Terminal. This will display all the contents of your current directory and the owners. For example:

psergay@MIDD-11209 local % ls -l
total 0
drwxrwxr-x   2 dhoughton  admin    64 Jan  7  2020 Caskroom
drwxrwxr-x  11 dhoughton  admin   352 Jun 24 10:16 Cellar
drwxrwxr-x   3 dhoughton  admin    96 Jan  7  2020 Frameworks
drwxrwxr-x  20 dhoughton  admin   640 Jun 24 10:19 Homebrew
drwxrwxr-x  56 dhoughton  admin  1792 Oct 14 10:56 bin
drwxrwxr-x   5 dhoughton  admin   160 Jun 11 09:23 etc
drwxrwxr-x  15 dhoughton  admin   480 Sep 16 12:06 include
drwxr-xr-x   3 root       wheel    96 Feb  8  2019 jamf
drwxrwxr-x  87 dhoughton  admin  2784 Sep 16 12:06 lib
drwxrwxr-x  14 dhoughton  admin   448 Jun 24 10:20 opt
drwxrwxr-x   3 dhoughton  admin    96 Jan  7  2020 sbin
drwxrwxr-x  14 dhoughton  admin   448 Sep 16 12:06 share
drwxrwxr-x   3 dhoughton  admin    96 Jan  7  2020 var

This shows that dhoughton owns the /usr/local/Cellar directory. You want access to it, so you’ll use the chown (“change owner”) command to do it.

Troubleshooting 2#

No XCode or Command Line Tools detected

If you get this error when running make

CMake Error at build_files/cmake/platform/platform_apple_xcode.cmake:107 (message):
No Xcode or Command Line Tools detected

Try reinstalling the command line tools like so:

sudo rm -rf $(xcode-select -print-path)
xcode-select --install

Yay! At this point, you’ve gotten everything installed and built Blender from source. You have all the tools necessary to start developing Blender. Now it’s time to start learning how to navigate the source code. First, in Blender settings, activate Python tooltips and Developer Extras in Preferences->Interface.

I recommend this video with Pablo Vasquez and Dalai Felinto for learning how the codebase is organized.

Useful commands in VS Code#

Here is a workflow for editing the code for any UI element you can see in Blender:

  1. Mouse over the UI element with Developer Tooltips enabled. It should then show you the path of the piece of source code that is responsible for that UI element.
  2. Go to VS Code and find that code/property with Cmd+P or Shift+Cmd+F. In Blender, usually Python code is UI and C/C++ code is the functionality. If you want to edit functionality, you’ll want to edit the C/C++ code, not the Python.

Getting connected with the devs#

Now it’s time to make an account on developer.blender.org. You should now have a Blender ID that you can use to log into blender.chat. On blender.chat, you can use the Directory to find chat communities for different aspects of Blender that you’re interested in working on.

Blender Chat Directory Icon

I recommend connecting with Hans Goudey. He’s a Middlebury class of ‘19.5 Physics/CS major who now works full-time developing Blender. He is reachable via DM on blender.chat.

Something I was surprised by is how helpful and open to chat even the most “senior” devs are. I recommend asking questions in chat and DMing people you’d like to talk with more. There is always a steady flow of bugs on developer.blender.org. The newer the bug, the easier it is to solve, most likely. Now is also the time to revisit the New Developer Info page where you can find more resources.

Getting along well with the community#

In my experience:

  1. If you have an idea for a new feature, check with devs to see if your idea would fit into Blender. Try to address a need! Often, bugfixes are the gateway to making a bigger fix or feature. To avoid bloat, the devs try to reject any proposal that can already be accomplished with the existing tools that Blender has. After all, every new feature that gets added will need to be maintained for years into the future. Don’t do a lot of work on something that the devs say is unnecessary.
  2. Be considerate in the chat. I have seen someone get banned because they were spamming the chat too much with videos of their feature and arguing with devs. They value vertical space efficiency, so don’t split an idea into too many chat entries that take up a lot of screen space.
  3. Don’t be afraid to ask “stupid” questions or comment something on an issue thread. Ex. “I’m using Blender 3.0 and I’m not understanding this bug.” Your thoughts matter even if you aren’t an expert.

Submitting a change!#

When you have made a change to the code that works and addresses a need, you can create a revision on developer.blender.org. Follow this guide.

I recommend looking at a past revision and copying the format that they’ve used. Click the “edit revision” option to see the plain text version. For instance, you can get nice embedded links to other blender issues by using {issue tracking #}. Be sure to check out Arcanist for submitting a good diff file. Alternately, you can use Git to make a more basic diff.

Good Luck and Have Fun!#

This is a difficult but rewarding journey. I love knowing that millions of artists and creatives are using software that has a bit of my code in it, and that something I worked on might help people.

-Peter Sergay ‘22