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!

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!