Unity’s Scriptable render loops – Revolution!

Heyah,

I recently heard about unity’s new “Scriptable render loops” feature which is currently in experimental state available, and so far it looks to me like the “rendering revolution” unity needs to finally have proper support for custom rendering effects.

The current problem in my opinion is that the unity rendering pipeline is ways too fixed and badly needs more flexibility.
There are a lot of things in unity which are really annoying to me regarding their rendering.

If you are trying to implement custom rendering that doesnt follow the rendering patterns of forward or deferred rendering on unity you are basically out of luck as soon as you want lighting integration.
The tressfx renderer is a very good example for why unity is so bad in this situation.

It is very hard to get lighting data out of unity and make sense of it, the best example most likely is the shadow map.
In order to retrieve the shadowmap of a light, you can use LightEvent.AfterShadowMap and copy the current render target into a render texture (See this example: https://docs.unity3d.com/ScriptReference/Rendering.CommandBuffer.SetShadowSamplingMode.html).

This works great and in case you just want to get the shadow map it’s perfect, but usually when you want a shadowmap you want to use it in order to render shadows, which isnt possible without knowing the shadow matrices, which are (surprise!) not exposed by unity so the shadowmaps you can copy are pretty much useless.

There is (apparently, i haven’t tested it) a workaround to this solution described here.

What Avol from the unity forums suggests is basically rendering a quad into a 7×7 texture and outputting the matrix encoded into it’s colors(On LightEvent.AfterShadowMap the shadow matrix should still be set as view / projection matrix, on LightEvent.AfterScreenspaceMask it should be bound as actual shadow matrix, i guess).
Then reading it back on the cpu and decoding the color values, but seriously i shouldnt have to even think of a solution like this in a modern game engine.

So, in case of the tressfx renderer i had to render my own shadow maps (which doubles the amount of time needed to render scene shadows, which is not acceptable at all).

All this madness will change with the new scriptable render loops!

Unity will allow us to implement own “render loops” which essentially control all draw calls the unity engine does in order to render the final image, by giving us an api that can be used to cull and render sets of objects from C#.
This way we will be able to setup any kind of rendering behaviour we want, without having the unity black-box around it and not knowing what’s going on.

Also they will introduce a new rendering pipeline (basically a reference implementation of a AAA rendering pipeline implementation by unity), which is open-sorce (here: https://github.com/Unity-Technologies/ScriptableRenderLoop).

I am really looking forward to testing the stable version of this system, it could give unity’s renderer the same flexibility as the rest of the engine has finally!

Here are some links you might want to read about the scriptable render loops:
Google doc: https://docs.google.com/document/d/1e2jkr_-v5iaZRuHdnMrSv978LuJKYZhsIYnrDkNAuvQ/edit
Aras’ presentation from GDC 2017: http://aras-p.info/texts/files/2017_GDC_UnityScriptableRenderPipeline.pdf

As a sidenote, the game i am working on just entered public alpha phase on 31st May and is now available on www.itch.io.
You can get a copy here: https://dapperpenguinstudios.itch.io/rise-of-industry

Have a nice day!

TressFX OIT Renderer on Github!

Heyho,

Just a short update.
Some days ago i started to finish off a first release of the new TressFX renderer. Just some minutes ago i started the push to github to get the new renderer to anyone who might can use it 🙂

It has support for self-shadows, shadowmapping, multiple lights, order-independent transparency (A-/K-Buffer fill / evaluate algorithm, like AMD’s implementation).
It’ll also stay open source, i wont be able to provide support for it due to my current other projects which are very time consuming.

I dont know if ill have more time in the future to continue this project, but if so ill push all my changes to git. There’s still a lot missing. It only supports directional lights for now, it also is missing skinned mesh rendering and (a lot) code cleanups.
My future focus now is on Project Automata and stay tuned for some blog posts about it’s development “soon” (after the release of it).

So, that’s it again.

Have a nice day!

Project Automata

Heyho,

I’ve been away for quite a long time, the reason for my absence is i joined the development team of Project Automata (www.projectautomata.com).

We’re working on a game which is a mix of Factorio, Anno and OpenTTD.
It involves production line building / optimization, pollution, trading and may more epic gameplay elements! 🙂

Have a look at our first trailer:

 

 

For all readers waiting for more tressfx stuff, i’m sorry but i have no news for you 🙁
Im still trying to fit the rendering system into unitys rendering pipeline (which is becoming a nightmare).
Also, with Unity 5.4 many cool new graphics features will be added which might or might not give me more freedom to “hack” deeper into their rendering system.

Anyways, as soon as i got news from TressFX i will post them here.

Have a nice day!

Self-Shadows and more!

Hey,

Some time has passed since the last blog entry. I have been a bit busy but could get some new stuff into the new renderer to blog about 🙂

The renderer now supports self-shadowing using a customized version of amd’s self-shadowing algorithm.
Well, no more words. See some screenshots:

This hair was rendered without self-shadows, this one is rendered with self-shadows:

The new renderer is now almost feature-complete and will be released soon (2-3 months on my current timeline).
It will be released under GPL 3.0 license (http://www.gnu.de/documents/gpl.en.html).

This license will allow you to use Unity TressFX in ANY project (even commercial) as long as you release your sourcecode for free.

There will be a commercial license available for a reasonable price soon after the release whcih does not require you to release your sourcecode. 🙂

Thats all for today,

Have a nice evening!

UPDATE: Licensing was changed – I decided to release it publicly under GPL 3.0. There will be however a commercial license available that will allow you to redistribute your application / game without releasing it’s sourcecode. Post edited 🙂

Progress update & Simulation imprecision

Heyho,

The past days i’ve been working quite a lot on the new tressfx renderer and started testing tressfx with characters and animation.

When doing those animation tests, i immediately ran into a very annoying issue that is fixed now.
If you try to import hair in “normal” scale (1 unit = 1 meter) you will see tressfx simulation just failing, all hair will just fall down when starting play. It will lose its shape.

I could not track down the real problem that is causing this (most likely floating point imprecision on asset import and simulation local shape constraints), but i fixed this problem by letting the simulation run in another world space.

The simulation now ALWAYS uses the hair in uniform 1 scaling, while the render settings can be set was you want.
So, for my example i got normal sized human hair modeled with blender, i import it with scale 100x.
Now i prepare the gameobjects for my scene and set the scale of the tressfx gameobject to 0.01.

What happens now on simulation is it takes the tressfx gameobject’s model rotation matrix with uniform 1 scaling (so, the hair is 100x scaled up from the import) and on rendering i transform all hair vertices from world to local space, scale them up and transform them back into the world space.

This works quite well, simulation runs stable and rendering looks like it would be simulation in the 0.01 scaling 🙂

 

So, for the general update part of this post i updated the TressFX repository on github, it now got partial tressfx 3 feature integration and this simulation fixup i mentioned before.

Skinning will be delayed for later, at the moment my priorities are improving the hair rendering and skinning will be a bit more complex than i thought due to the integration into unity without much overhead. No fixed date here yet, just wait and get some tea. Sorry 🙁

The new tressfx renderer is almost done, the integration into unity’s lighting system is pretty much completed, there are only some shadow functions missing, but i guess it’ll be relased soon.
I have not decided yet if it will be open source, im still trying to figure out which licensing model will be the best (but most likely it will be free for personal use and only commercial use will need a license).

This renderer will support the following features:

  • Full integration with unity lighting (spot, point and directional lights)
  • Up to 4 shadow casting lights
  • Unlimited amount of non-shadow casting lights
  • Custom shadow mapping for directional lights with very high-resolution
  • Self-Shadowing
  • Order independent transparency
  • Level of detail, Hair density control
  • Multiple hairs per scene without much rendering overhead
  • Whole hair rendered in 2 drawcalls, no more overhead :3

Most of this stuff is already implemented and im only doing final tweaks and performance improvements, so again get some tea if you’re waiting for that rendering 🙂

To finish this dev post here’s a new screenshot from the current version of the new renderer:

tressfx_smooth_blend

TressFX 3.0

Hey,

I was recently notified that TressFX 3.0 was released publicly on github: https://github.com/GPUOpen-Effects/TressFX.
After some diffs and reading through the new code I started porting it to Unity.

The new TressFX 3.0 supports fur rendering and skinning. Thats the only real change on the simulation they made (apart from minor fixes).
What’s also new is a brand new SDK (finally!) that features a viewer, maya plugin, tools and some example models.

As far as i could see rendering is almost untouched.

So, i think ill be able to integrate all new TressFX 3.0 features into UnityTressFX this month.
I expect a new commit on github with the 3.0 features to happen at the end of this month.

So, stay tuned for further updates.
Thats all for today 🙂

Blender -> Unity TressFX Import

Heyho,

I recently added a new importer to the TressFX project. This new importer can get used to import blender hair particles into TressFX Unity.
In this article i will explain how to create the hair particles in blender and import them into unity.

First, open up your blender (I’m using version 2.76).
Add a new particle system to any object in the scene (I’m using the cube that’s always added on a new scene).
Your scene should now look like this:

blender-hair-particle-scene

I will leave the hair now just as it is, since i’m not very familar with blender and it’s all we need in order to demonstrate the import workflow 😛

The next step is converting the hairs into an actual mesh we can export, in order to do so we need to add a modifier, which can be done at the modifier tab:

blender-hair-convert

Press the “Convert” button to convert your particle system into a mesh. Now your scene should contain a new object:

blender-hair-new-object

Now, remove all unnecessary things from your scene (the light, camera and the cube) and export the hair mesh as Wavefront OBJ file:

blender-hair-obj-export

Now, we are almost done.
In order to import this hair into unity now we need to customize the TressFX import settings a bit. To do so, open up the TressFX Window (Window > TressFX).
First, you need to tick normalize vertex count in order to normalize the hair strands to 16 vertices per strand (this is only needed in order to use simulation).
The follow hair max radius around guidance hairs is ways too high for this kind of hair aswell. It controls the radius around the hairs you import where additional hairs are added to make the hair more dense. I used 0.025 here:

tressfx-import-settings

Now right click in the project explorer, select “Create > TressFX > Hair from OBJ” and let unity import the obj file.
After that you are done importing the hair mesh into unity. Yay 🙂

Now, creating an example scene is pretty straightforward.
Create a new gameobject and add the TressFXRender and TressFXSimulation script to the gameobject.
Assign the “Shadow Shader” and “Hair Material” to the TressFXRender (The shader is located in Assets/TressFX/Shaders/TressFXShadow.shader, the material must use the shader “TressFX/Surface”).
Now, assign the “Simulation Shader” of the TressFXSimulation component and the “Hair Data” of the TressFX Behaviour.
Finally it should look like this:

blender-hair-unity-example

The last step now is setting up the simulation parameters for the hair, click the hair asset and configure them as you like.
Here is my example config:

blender-hair-unity-example-config

Press “Save”, and you’re done 🙂
If you hit the start button, it should get rendered like this now:

blender-hair-unity-example-running

That’s it 🙂

Have a nice day!