Skip to main content Skip to navigation

What is SeExpr about?

Categories:

Good morning everyone!

For this Community Bonding period post, I want to write about what this project is about. I’ve gotten some questions about its scope and how it will benefit the Krita community, so a full writeup may help clarify these bits. As I’m a Computer Graphics student, this post may be biased towards the math-y bits, but I hope it’s still clear.

Let’s get started!


A bit of background

To understand what SeExpr is about, we need to differentiate between two types of graphics, raster and procedural.

The vast majority of the computer-generated stuff you see every day belong to the first type– images like photos, your favourite anime screenshots, memes, are all a multitude of tiny little dots of color arranged into a (usually) rectangular grid. We call these dots pixels, and obtain them by a two-fold process:

  • sampling, where we get the color value at each grid cell;
  • and quantization, where we turn these values into numbers that the computer can store and process.
These are this blog's favicons. The first is 200x200 pixels; the second is 16x16, but upscaled to match the other. The grid is visible to the naked eye.

Raster textures have two drawbacks. First, once you create them, they are fixed. You cannot get any more detail, there’s no enhancement à la CSI (unless using AI to imagine the missing details). And if you need to change the texture, either you go back to the source and sample it again (which is sometimes impossible), or edit it with a raster graphics program, like Krita.

But to us CG people, one of the biggest problems is that we are always limited by the space our programs can use; either secondary storage, like SD cards, or RAM. Unless compressed, image memory needs are quadratic in the size of the image. For a quick example, the Create new document dialog of Krita tells you three bits of information: its size in pixels, the size of the pixel itself, and the total memory needed.

A screencap of the "Create new document" dialog.

Here’s a summary for square textures:

Size Memory needed
256 256 KiB
512 1 MiB
1024 4 MiB
2048 16 MiB
4096 64 MiB

So what about procedural textures?

Procedural textures are a whole different thing. In practical terms, they are generated at runtime from a script.

There’s a book chock full of details on the subject, by Morgan Kaufmann: Texturing and Modeling: A Procedural Approach.

What is SeExpr, then?

SeExpr is an expression language, designed by Disney Animation, that lets us do just this thing. Pixar calls it in its documentation a scriptable pattern generator and combiner.

How will this benefit artists?

In short, it lets artists turn a piece of code into a beautiful, lava-like noise pattern, as below:

# Copyright Disney Enterprises, Inc.  All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License
# and the following modification to it: Section 6 Trademarks.
# deleted and replaced with:
#
# 6. Trademarks. This License does not grant permission to use the
# trade names, trademarks, service marks, or product names of the
# Licensor and its affiliates, except as required for reproducing
# the content of the NOTICE file.
#
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0

$val=voronoi(5*[$u,$v,.5],4,.6,.2);
$color=ccurve($val,
    0.000, [0.141, 0.059, 0.051], 4, 
    0.185, [0.302, 0.176, 0.122], 4, 
    0.301, [0.651, 0.447, 0.165], 4,  
    0.462, [0.976, 0.976, 0.976], 4);
$color

The possibilities are simply too many to describe. This project will start by letting you render patterns like the above onto a Fill Layer. Once I get the render, UX, and storage working, I may add extras like dynamically binding additional inputs, or hooks to extend SeExpr with additional functions.

Implementation plan

Roughly speaking, this project will be done in four parts:

  • Researching SeExpr: how it’s implemented, what APIs and components exposes, etc. (I’m here)
  • Integrating SeExpr into the building process (3rdparty modules, for us Krita devs)
  • Developing the new layer
  • Testing, testing, testing!

Is there any way I can help you?

YES! Once I get a prototype up and running, and a build is made, I’ll need lots of testers for the UX bits.

But most importantly: I need examples! Up to now, SeExpr is used mostly with proprietary software: Pixar’s Renderman (wiki here), and Autodesk’s Maya. The only open-source software that supports SeExpr is INRIA’s compositing software, Natron. Fully free, open source examples that we can bundle with Krita, would go a long way towards showcasing this project.

That’s all from me! Next time, I’ll dissect the insides of the SeExpr library. Please chime in with any comments, amyspark @ #krita in the Freenode network.

Until next time,

~amyspark