April 14, 2016

Perfect Tile System - Home Content

The Perfect Tile System is getting some special additions: home content! The simple home (which is in no way finished) features a new preset called "Advanced Bricks" with a mix of Sun directions and custom directions for POM shadows, and some wooden paneling. There's also new content, like a rocking chair, an Indian-styled glass table, some artwork, and interesting shaders!

A lot of the home content uses clear coat shading models and variation in metallic rendering. The reasons for this is a lot of wood finishes and surfaces for home products often have a slight metallic sheen, giving them an interesting color.

I also added some blueprints to help with the creation of any home. The lights are controlled by switches you can place on the wall. Just place the lights, place the switches, hook the lights to the switches, and you can start toggling them on and off! You can also adjust the length of the cable that comes down from the ceiling and toggle between covered and uncovered lamps.

The new shaders look fantastic for a home setting. The paint shader looks particularly stunning, appearing just like an acrylic or oil painting with a nice semi-gloss varnish. I hope to eventually have an easy picture frame blueprint to avoid the work of having to manually scale individual pieces. Enjoy!

Lighting was a huge component of this project. The pointlights I used around the spots where the sun hit had very large indirect intensities and very low direct intensities. This allowed light to flood the room. I also used spotlights to direct the light in the direction of bounce off the floors, so along with some soft light bounces, you also get more directional lighting as well.

Hallway lights can be turned on to show off the IES profiles...

...or off to let the soft bounce lighting take over!

The paint shader looks fantastic! My mother said she wants to live in this house. I guess that's a sign that I'm doing something right. The color scheme for the whole home is very warm with green accents, and I found that sticking to a scheme works better than breaking away from it. Hopefully this painting will have a frame later.

Glass shader took a while to get right. This one uses a combination of forward shading and GGX specular with metallic rendering. I opted for an additive model because it brightens the scene the way translucent glass does. And yes, the glass does cast a shadow on the floor.

Along with excellent indirect lighting, the post processes makes the scene. I use a nice, soft bloom with a lower threshold, constrained the adaption a little to allow the light to brighten the scene, and I included Ambient Occlusion to aid with the shadowing in corners. Home lighting is all about that indirect lighting, and the post process needs to aid that.

March 23, 2016

UE4 Water Caustics - Light Function Method

In an earlier post, I showed how to make caustics with a material function. This is the light function method. This system functions much in the same way the earlier one did, except instead of world position determining the size of the caustics, I used a texture coordinate, and since pixel depth is not available to light function materials, I used the distance between the absolute world position and camera position. There is a second directional light in this scene which does not cast dynamic lighting or shadows, but projects the caustics function into the world. This method respects all material qualities and there is the capability of using both shadow maps and dynamic shadows to improve the quality of the function. However, light functions do not support colored textures (I believe the performance benefit comes from handling most functions using 1-vectors as opposed to RGB 3-vectors), so the caustics are completely desaturated here.



Aside from the color issue, this method supports all the functions of the previous caustics system: the texture blurs and fades out as it approaches the bottom of the water. The caustics are mapped and aligned with the directional light as if it has been cast from the sun. And it even cuts off at the water level! On top of all that, this method also respects the shadow environment and surface properties (color, metallic, roughness, etc). This is the proper way to handle caustics in UE4. The light function uses 85 instructions.

I also used the material function method to shade the particles in the water.

This caustics texture was made with the free caustics generator provided with Allegorithmic's Substance Player. The player is free as well. The distortion is provided by a simple noise texture converted to a normal map. I provided the assets below. Please note if you wish to use a texture for the light function, flag the compression as a Grayscale image. This will use the same amount of memory as a standard texture but improve the quality by decompressing the texture. Because the caustics function relies heavily on the quality of the mipmaps, and to eliminate tiling, it is a much better idea to make sure the texture is large enough so that accurate mipmaps can be produced. Alternatively, you can also hide the texture in one of the channels of a larger mask texture to save memory.

Click here to download the caustics texture, wavy normals, and a Phong material function.

March 22, 2016

Underwater Caustics

I may have figured out a (somewhat) cheap method to get realistic caustics underwater in UE4. This method is all done purely within materials and requires no lights. The caustics rendering itself only takes 30 instructions, and depending on how you shade it, anywhere from an extra 0-20 instructions.



This technique uses a light vector to correctly planar map a panning image of caustics. The shimmering effect is then provided through a noise normal map distorting the UVs. The caustics will map on both sides of an object's normals, so they have to be shaded with either Phong or GGX specular and Lambertian shading.

The Caustics texture was generated from a free plugin provided by Allegorithmic with their Substance Player. The texture has chromatic aberration (colors), and plenty of detail and depth. The function also uses the exposed Mip levels of the texture to blur and "scatter" it based off of its depth in the water. Close to the shore, the caustics are crisp and clear. Deeper down, they become blurry and less noticeable. It automatically cuts off the caustics rendering above the water as well.

As an added bonus, because caustics use the World Position nodes to map itself onto objects, you get the transmission of the caustics through the surface and onto the other side for free. To make translucent grass, you don't even need to bother shading it! Unlit grass can look too even without the GI to differentiate itself, so for this demo I used the Masked/Two Sided Foliage shading model. A custom Mip function means you can also make the caustics blur more in the distance as a cheap way of showing scattering in the water, though I did use proper depth of field post process in the demo.

The Caustics function is automatically linked up to a Material Parameter Collection, so when certain properties are adjusted (like the depth of the caustics blurring effect, or the intensity), those values change for all of the models where the caustics appear.


Pros:
  • Cheapest way to render underwater caustics (does not require complicating entire scene through the use of a light function)
  • Automatically respects the direction of sunlight
  • Mip level adjustments can scatter and blur caustics into water based on depth (extremely cheap feature, and very convincing)
  • Ability to use forward custom shading that can be adapted to many uses and shading techniques (Phong, Blinn, Beckerman, Cook-Torr, or GGX + Lambertian diffuse, and transmission)
  • Free transmission for grass and plants (more complex subsurface scattering can be simulated through a more interesting Mip adjustment)
  • Colorful chromatic aberration (light functions currently do not support colored textures, and post process applies evenly to the entire scene)
  • Can be adjusted per-object and universally through individual material parameters and collection parameters
Cons:
  • Does not respect surface properties or UE4's lighting renderer. Because the caustics are sitting on top of UE4's lighting, not integrated as a light function would be, this material mapping function method does not respect any surface properties and requires its shading to be handled separately. Any Lambertian or GGX specular lighting must be applied separately, nearly doubling the shading work.
    • Alternatively, you can render objects as unlit to save greatly on instructions, but at the cost of the GI, shadow environment, and reflection environment. For products not requiring too much power, rendering unlit with all light being supplied by the caustics is definitely the cheapest option to render caustics at all. Fully rough materials can also work.
  • Does not respect shadow environment, so areas that should be shaded appear to have the caustics effect. This can be mitigated through the use of textures or vertex painting, but it would be more ideal to have the caustics respect the built-in shadow environment.
  • Must be applied manually to all materials requiring it

February 9, 2016

UV Test

Here's a quick texture to test UVs.

The numbers range 1-16 from left to right.
The colors are staggered, but are laid in this order:

White
Red
Orange
Yellow
Green
Blue
Purple
Gray


December 12, 2015

The Perfect Tile System: version 1.1 now released on the Marketplace!

And check out the changelog!:

  • Roughness maps - Now you can finally use the full range of PBR shading in UE4!
  • Independant roughness TM - Along with detail textures, you can also specify roughness variation amount per-tile.
  • Ryan B’s POM with shadows - New POM calculation allows you to use shadows and direction
  • Sun Direction material parameter collection and blueprint - Allows you to pull sun direction from the directional light in level for accurate POM shadow direction
  • Colored Tile Maps - Tile maps can now be colored, allowing you to manually color individual tiles with the full range of RGB values and colors
  • Tiling in world space - You can map the system in XYZ coordinates so it works flat on a wall, floor, or ceiling, and tiles seamlessly across multiple meshes, even if UVs are not set up on them
  • Fixed bug - POM disabled local tiling
  • Fixed bug - Parallax/Iterative caused displacement to tile incorrectly
  • Toggle for Metallic shader - Previously set to on all the time
  • Toggle for cheaper gamma correction - Previously set to on all the time
  • Optimum Maps - Use individual channels of one texture map for all areas that used to be handled by the Tile Maps. Can save draw calls on PS4/OpenGL systems, but wastes more memory (Shared samplers are still preferred for DirectX 11 systems)

You can download the Perfect Tile System here:


The newest version of the guide can be downloaded here:

June 12, 2015

The Perfect Tile System - Released on UE4 Marketplace! Development Priorities.

UPDATE: 8/7/2015 - I fixed a bug that caused some textures to not tile properly with parallax mapping. The fix also allows materials using Parallax Occlusion to retain all local tiling adjustments. I also have some more toggles for the performance-minded folks: you can toggle the special metallic shading on and off. On, and metals appear brighter around the edges with an added sheen. You can also toggle between simple and complex gamma correction. Simple uses a multiply node for a power of 2.0 and saves 3 instructions. Complex uses a power node for a power of 2.2, bringing colors closer to sRGB standards, but uses 3 more instructions. The flexibility just got a whole lot better!

Stay tuned for further updates!

UPDATE: 7/6/2015 - I have just finished an integration of roughness maps and a variety of randomization settings. Tiling can now take place in world space as well, for perfectly seamless floors, walls, and ceilings across multiple meshes without the need for perfect UVs. And custom UVs are now utilized for global scaling within the system (unfortunately, this optimization was performed under the hood all along like I had hoped). Other improvements also took place, mainly to fix minor bugs and streamline the pipeline. The improvement are not over yet, though. I still need a bit more time to develop a good solid update, which includes rewriting the user guide.

I have squashed out the ability to swap linear and sRGB assets from the system. Because sRGB does not follow a standard exponential curve, it will be impossible for me to convert it in any reliable way to take advantage of the dual features. I am thinking about including sRGB tile maps as an option when dual color/roughness features are not required, which would save instructions and look slightly more accurate, but both sRGB and dual surfacing are not seamlessly compatible with each other.

---

So, The Perfect Tile System is finally up on the Marketplace!

https://www.unrealengine.com/content/8b8ae16ae659425384a6caaafc36212a

This is great news, but it's not all over yet! Listed below are some plans I have for the shader system, including both optimizations and newer features. Please comment on this blog for features you'd like to see. I will update this list:

High Priority
  1. Inclusion of Roughness maps for surface detail (requires full-scale integration with the tile distortion and parallax features).
  2. Switch between linear and sRGB assets (the dual color algorithm makes this very difficult).
    Unfortunately, swapping between linear and sRGB assets is impossible in the engine. Instead, I use a power of 2.2 on linear assets, or 2 for the optimized method.
  3. Tiling optimization using custom UVs for global scale.
  4. Toggle world-space coordinates (must also work with parallax and texture tile distortion).
Medium Priority
  1. Colored Tile Maps (easy to implement for linear color, difficult for sRGB).
  2. Optimum Map that combines TM, metal map, glass map, and scattering maps all in one texture. Parameter masked with RGBA values to eliminate the need for extra draw calls with heavy TM materials.
  3. Optimum Map 2 for displacement, roughness, and custom AO.
  4. Special tiling for bricks and panel flooring to convert pixel TMs into more complex TMs, uses instructions but saves texture space and time in bitmap editor (parallax makes this difficult).
    While special tiling features have now been added, including the tile randomizer and world coordinates, the brick tiling method produces unpleasant results for too much instruction cost. While there is some work required to make a manual brick TM, the work is well worth the hassle when it comes to optimization. The included TMs work for 65,536 individual bricks. I may make a larger texture in a newer update.
Low Priority
  1. Detail texturing (requires another pipeline to be added. Not too difficult, just time consuming).
  2. Tile randomizer (must also be compatible with texture tile distortion).
  3. Simple gamma corrector to save instructions on colors (but will result in less accurate colors).

May 4, 2015

The Perfect Tile System - Up on Trello!

https://trello.com/c/SNP7QkhW/360-the-perfect-tile-system

It was a long and bumpy road, but the system is finally up on Trello for votes! 2 days in and it already received 10 votes, ranking 3rd. for all systems in the category. Please go there and vote now if you want to see this on the Marketplace!

There are of course a ton of features I would still like to update the system with, but it takes time to experiment and implement across the board:

  • Switch between linear and sRGB assets (the dual color algorithm makes this very difficult)
  • Colored Tile Maps (easy to implement for linear color, difficult for sRGB)
  • Special tiling for bricks and panel flooring to convert pixel TMs into more complex TMs, uses instructions but saves texture space and time in bitmap editor (parallax makes this difficult)
  • Inclusion of Roughness maps for surface detail (requires full-scale integration with the tile distortion and parallax features)
  • Tile randomizer (must also be compatible with texture tile distortion)
  • Detail texturing (requires another pipeline to be added. Not too difficult, just time consuming)
And there are some further optimizations I'd like to include as well:
  • Optimum Map that combines TM, metal map, glass map, and scattering maps in one texture, parameter masked with RGBA values to eliminate the need for extra draw calls with heavy TM materials.
  • Simple gamma corrector to save instructions on colors (but will result in less accurate colors)
  • Ability to feed textures without needing to gamma correct.