New relief mapping techniques (fast)

Hi there,

This is a demo using new relief technique. It’s based on assumption of extrusion strictly in vertical direction. When we also extrude along uv axis in tangent space shader can do calculations quite fast (2-3 simple steps to resolve ray hit point) with self-shadowing, too.

It’s something I’d like to put into asset store, so every feedback (how it works on different platforms) would be appreciated.

Demo web player:
http://www.stobierski.pl/unity/spaceShip_WebPlayer/WebPlayer.html

and standalones for PC and Mac (to better test performance on different resolutions and quality settings):

http://www.stobierski.pl/unity/spaceShip_PC.zip
http://www.stobierski.pl/unity/spaceShip_MAC.zip

I made this demo as a proof of concept. Stay tuned as I’ll put more demos soon (brickwalls, pavements, etc.). I’m also working on procedural relief shaders (no heightmap use at all to get paralax occlusion effect), so I intend to put it all in one package on the store.

Very nice…the web player works on my Mac always at 60fps with all options, although the DOF effect goes completely mental if shadows are enabled. Disabling shadows makes it work correctly.

–Eric

Wonderful. Your shader extrusion is a work of art.

very cool!

very nice!

looking superb

I love it!
Show us more, oh great one.

Any chance this would work on IOS, iPad 2/iPhone 4S + ?

Eric, have you tried standalone versions ? Please, could you be a bit more specific with DOF+shadows issue (screenshot or anything) ? I used HDR camera rendering with this DoF (Bloom and Lens flares post FX), maybe that’s the problem. Unless you turn on DoF, do the rest of postFXes work fine with shadows on your Mac ? The only thing I can do testing OpenGL is forcing this mode on my PC in editor.

I’m not much mobile oriented Unity developer, I don’t have any iOS hardware to check it. As far as I know the shader compiles for GLES, even for ARB / OpenGL with some options turned off. I don’t exclude this target platform in my surface shader code, so it could work I guess. The problematic part could be using tex2Dgrad / tex2Dlod functions inside for better apperance on extruded edges (uv coords becomes uncontinuous when offseting them), but this can be turned off by commenting one line in shader code. This case shader won’t look that fine on inner edges, but the same time works much faster (ddx/ddy/tex2Dgrad are pretty heavy against regular tex2D).

I can’t say what’s the GPU power of iPad2 comparing to desktop machines. What I can say is that the simplest version of my shader with most options turned off needs about 30%-40% more power comparing to ParallaxBumpedSpecular shader on my PC (nVidia GT240). With the every option turned on it is up to 2-2,5 slower than mentioned reference shader. There are plenty of options adjustable, i.e. normal smoothing, ambient occlusion (for procedural relief only), detail maps, displacing UVs by texture, etc. I’ve decided to name my shader “fast”, because classic relief mapping is considerably slower in most cases. It’s, of course not that fast like, let’s say, bumped specular. No way. We need to compute exact ray hit position in tangent space, whether analytical or using texture look-ups.

As said most of my shaders will be faster than other relief mapping shaders. For example relaxed cone mapping takes a few initial steps to cross the surface (texture lookups + calculations needed), next it uses binary/secant search to finetune exact ray hit position which is at least another couple of texture operations on heightmap. Worse, if we like self shadowing, we have to do the same process back again, tracing ray from ray hit point to light source. It’s heavy, so I’m not surprised that only a very few AAA games (in UDK, Cry Engine, etc.) uses relief mapping extensively. It just costs much. When you have GPU like GTX580 it’s fine, but when you got old good nVidia 7600 it becomes impractical. That’s why GPU developers went into tessellation in DX11 for example.

Reassuming in comparation to ParallaxBumpedSpecular. If you can consider spending twice a GPU power on shaders and it’s fine for your target audience platforms, my shaders are definitely something for you :).

One more thing. To be precise, don’t expect that my shaders are replacement for generic relief algorithms. My extrusion works much faster but it’s special case shader. It can handle a subset of situations fast enough to compute more bells-and-whistles (self shadowing), but it’s not general solution like relief mapping.

On my Mac it works fine with all post FX enabled. And it runs at smooth 60 fps.

Good work tomaszek!

OK,

Below you’ve got demo with more materials. Pavements, bricks relief are realised by texture info (which defines where are holes, aligned to uv tangent space axis). Balls at the center are extruded proceduraly. User can adjust every aspect of its look. Tiling (not necesarilly the same in u nad v axis), dimensions, extrude height, ceil/floor levels, ambient occlusion, self-shadow. Another option for all of my shaders is that they’re properly shaded (although from one light only) even when lightmapped by single / dual lightmap - shader doesn’t need directional lightmapping to get normal dependent shading (like bump mapping for example - they don’t work when lightmapped unless unsing directional lightmapping).

http://www.stobierski.pl/unity/pavements_WebPlayer/WebPlayer.html

Świetna robota :wink:

Looking great! I love it. What will be the price? :stuck_out_tongue:

Price :slight_smile: This is the most difficult job always. I intend to make it just “relief for masses”. I count on people to buy it on large scale (should I ?), so I’ll probably set the price in low-mid range ($20-$35). Package will consist of several procedural shaders, and a few versions of “extrude map” shaders (extrusion from bitmap like pavements/brick boxes here and space station in previous example). User will have tool to make distance maps from height bitmaps (extrude map shaders needs them to work). I have to sort things up first and check it good before I put it on asset store. I think I’ll also put this kind of shader (exact extrusion - walls dont have to be uv-axis aligned) like in this thread:

http://forum.unity3d.com/threads/147498-Extrude-Shader

I think I’ll put some teaser shaders today - extrude map shader and one procedural shader (compiled for D3D9, ARB) free of charge for people to play around with this stuff. Thus potential users will have better idea how does it work.

It’s very cool, and fast too. It seems like it would be really easy to use since it’s based on a texture. Makes modelling seem much simpler to do when you just need to change the image to paint the surface shape, instead of going into a 3d modelling program. I think this will offer easy editing benefits to a lot of people who might not be adept at 3d modelling but who can mess with textures. I think you could go in the $30-$50 price range if you include a number of useful/useable example textures. This is what I like to see in a tool - easy to use, takes a huge burden of pain off of development time and complexity, opens up possibility to a larger audience that they didn’t have before, and does something ingenious at the same time.

The standalone version does work fine.

Actually it’s DOF+AA+glow+shadows. If one of those is disabled, then it works. Here’s a series of screenshots taken over a second or two:

–Eric

Thanks Eric,

I’m afraid the origin of issue is somewhere outside my shader. It’s rather matter of mysterious postFX effect interaction in Unity web player (bug ?). I confess I pushed fragment shader a bit (to the limits), but I definitely didn’t hacked surface shader output, nor shadow caster/collector. I use clip() (discard) for silhouettes cut on uv borders, but not in this case. I output alpha, combining it from color and main texture (as alpha is used by some postFXes). So can’t help, but good to hear it works in standalone version.

I’m running Windows 7 home premium - Intel Core 2 duo - 3gb ram - Nvidia GeForce GTX 560 Ti

Both webplayers ran perfectly with 60 fps with everything turned all the way up.
Didn’t have the same issues as eric.

Standalone:

640 fps at 640x400 Fantastic fullscreen
330 fps at 1440 x 900 Fantastic fullscreen
380 fps at 1440 x 900 Fastest fullscreen

Again, no issues at all. All my test had everything turned up and moving the sliders around saw no different in performance. Looked amazing fullscreen with max resolution.

Looks awesome. I would love to see a video or something of this being setup. Is it as simple as throw the shader on a material and play with the settings?

So,

Here is little teaser as a unity package. You can play a bit with the shaders (compiled versions, w/o full options)

http://www.stobierski.pl/unity/ReliefDemo.unitypackage

You’ve got 2 examples:

  • extrude map materials (demo version - no texture color/bump/detail mapping nor uv displacement) - bricks / hello world distance maps
  • procedural relief shader with its all options available except for texturing

Check it out and tell me what do you think about it (performance in different configurations, etc). Especially you can texture different objects (different uvs) with procedural shader and play with its settings. I can imagine we’re able to use it for many interesting applications, even with no texturing.