Home Artists Posts Import Register
Join the new SimpleX Chat Group!

Content

Hey, all!


Another quick update on what I'm working on. I don't know how frequent these posts are going to be, but I'll try to publish something every couple of days or so!

Anyway, I'm currently working on importing light sources from SFM session files. Sadly, that is not quite as straight-forward as it may seem, so this post is going to be a little more technical (but hopefully not too boring ;) ).


Lighting Conversion

Pragma, Cycles and the Source engine all use different lighting systems that are not 100% compatible with each other:

• Cycles uses radiometric SI units for light intensity (i.e. Watts and Irradiance (Watts per square-meter)). Light falloff is according to inverse-square law.

• Pragma uses photometric SI units for light intensity (i.e. Lumen, Candela and Lux (Lumen per square-meter)). Light falloff is according to inverse-square law, but can be manipulated via a falloff exponent (Similarly to how it works in the Unreal engine.).

• Source doesn't seem to be based on anything physical and seems mostly subjectively defined. Light falloff can be constant, linear, quadratic, or a combination (or alternatively by percentages).

This is a problem for multiple reasons. The main difference between radiometric and photometric units is that photometric units are weighted according to how humans perceive light, while radiometric units are more physically accurate. These two are not directly translatable, because radiometric units are dependent on the spectral distribution of the light source, i.e. some knowledge about the type of light source being used is required (e.g. Incandescent, LED, etc.). Since I don't have that information available, all I can do is approximate the lighting by trial and error. Same applies for the light falloff.

It took a lot of experimenting but the lighting conversion from Pragma to Cycles creates a pretty close match now, especially with GT-tonemapping:

I'll still have to test it with some actual scenes to make sure it's in order, but I think it'll do for now.

The conversion from Source/SFM to Pragma still needs some work, however:



You won't really have to worry about any of this when importing a SFM-session or rendering with Cycles of course, all of the necessary transformations will automatically be performed under the hood. There will always be some minor lighting differences, that can't be helped. I'll probably have to come back to the lighting conversion once in a while to do some additional tweaking.


Photometric Units in Pragma

Pragma using photometric units is new as well. Since I was working on lighting anyway, I took the opportunity to change how lighting works in Pragma and switched to photometric units, as that will make it much easier for artists to work with. As mentioned earlier, the intensity of a light source can now be specified in Lumen, Candela or Lux: 

Candela

One Candela is approximately equivalent to the amount of light emitted by a candle. Contrary to Lumen, Candela produces the same illuminance on a surface regardless of the configuration of the light source. That means regardless of the beam angle (or whether you're using a spot- or point-light), the lit surface will appear to have the same brightness:


This is very similar to how light intensity works in the source engine and it makes it easy to create consistent lighting in a scene (while still being based in real physics).

Lumen

Lumens describe the total amount of light emitted by a light-source. In the screenshot above the spot-light with a beam angle of 50° emits the same amount of light as the one with an angle of 140° and the point light. However, since the emitted light will be much more spread out the larger the angle is, the light will appear much dimmer.

Lumens can be a bit confusing to work with when configuring a light-source by hand, however they're very useful if you want to use light values of a real-world light source in the engine. The package of most light-bulbs will tell you the amount of light they emit in Lumens (lm), as well as the color temperature in Kelvin, both of which can be input directly into Pragma:

(The screenshots I've posted earlier use the same color temperature as the one on this package, but a higher light intensity.)


Lux

Sun-light is a bit of a special case. While the sun is technically a point-light, it would be very impractical to simulate it as one, due to the scales and distances involved. Instead, a sun is generally simulated as a directional light source, which doesn't have an origin and emits light from the same direction regardless of location.

This means that using Candela as a unit for the sun's intensity doesn't work, because Candela are defined as light intensity per solid angle relative to a specific point. Without going too much into detail, that means using Candela only makes sense if the light source has an origin and radiates outward from that origin, which is not the case for directional light sources.

Lumens are also problematic, because they describe the total amount of light emitted from a light source, which would be effectively infinite for a directional light source, because the light never attenuates and is equally intense everywhere.

Long story short, this is why the light intensity of directional light sources is measured in Lux instead. One Lux is equal to one Lumen per square-meter, and describes the amount of light received by a surface (not emitted as is the case for Lumens/Candela). That means that instead of defining the light intensity of the sun, you define the illuminance of what's being lit by the sun (i.e. the world and everything in it). There are special Lux meters that can be used to measure the illuminance in Lux in the real world, but luckily there are plenty of references already available, which can be used directly in Pragma:

(Table source: https://en.wikipedia.org/wiki/Lux#Illuminance)

I haven't actually fully implemented this one yet, so no comparison screenshot for now!


All of this will be incorporated in the editor later on, of course, so you'll be able to choose between Lumen/Candela/Lux, RGB-colors/Color temperatures, etc. depending on your needs. As with most features I implement, all of it is also exposed to the Lua API as well: 


Video Recording

I already implemented an in-engine video recorder using FFmpeg a short while ago, but I've now integrated it into the editor as well, which allows you to record videos with the Cycles raytracer. A few things are still missing:

• You can't record audio yet.

• Rendering with CUDA and OpenCL does not work yet, so it's CPU-only for now and fairly slow.

I haven't had the time to render a video with more than a few frames yet, but I'll try to record one soon(-ish).


Somewhat related: Someone on the Discord server also gave me the idea to implement collaborative rendering, i.e. allowing you to split the rendering of a video to multiple PCs (online or offline). Since Pragma already has multiplayer capabilities, this would be fairly trivial to implement, but it's a low priority for now. At some point I'd also like to implement full online collaboration options for filmmakers (allowing multiple people to work on the same project online), but that'll be for much later down the line.


Anyway, that's all for now! Technical posts like this one are probably gonna be an exception, but I thought it important to share some details on how the lighting works/is going to work.

Next up I'm going to implement some more of the missing import-features, like cameras. Once that's out of the way, I just need to do some testing on my Nvidia GPU and make sure everything's in order, then I'll be publishing the first preview-version for Tier-3 Patrons!


Thank you for reading! If you have any thoughts/ideas, please let me know!

Comments

No comments found for this post.