Shader Bits: Octahedral Impostors
Shader Bits: Octahedral Impostors
hedral Impostors
Blog R
ime to release the first version of the Impostor Baker tool! This is currently uploaded to
e I could not get access to the ue4 community server:
ub.com/ictusbrucks/ImpostorBaker
tly for UE4.19 only. I have a 4.18 version that is a bit older if anybody really wants but its
oaded anywhere. TAGS
ing should be downloaded to the location: \MyProject\Plugins\ImpostorBaker\ .
gin called "BlueprintMaterialTextureNodes" must be enabled (That one is my first c++ Ue4 7
n the engine. Makes it possible to the BP to save assets.)
still beta. Please let me know of any issues. Volumetri
3
nstructions are in the included map file Generate_Impostor_Map.umap. cs
Ray
ing about this in more detail at GDC next (this?) week. Here is more info on those talks: 2
Marching
dule.gdconf.com/session/optimizing-span-classhighlightfortnitespan-battle-royale-part-2-
by-epic/857076 Caustics 1
dule.gdconf.com/session/realistic-foliage-imposter-and-forest-rendering-in-ue4/852286
Foliage 1
Impostors 1
Materials 1
Refraction 1
Volume
1
Rendering
experimenting with impostors for several years now. The idea is not exactly cutting edge.
ersion of an impostor generator built into UE4 that I added a long time ago, but at this
retty dated and borderline unusable (it exists under the Render To Texture BP
hile the biggest problem with the old method is the cumbersome usability, it also wasted
ure memory.
rsion improves the workflow issues and makes more optimal use of the available texture
ing a layout based on octahedra.
I was able to spend time on a new version is due to being asked to help out on
nt of the Apple Park AR Demo. So this Impostor Generator was first built and tested for
unately I do not have permission to show any images related to that, so instead I will use
om Fortnite since it has been in use in Battle Royale since the map 2.0 update. I made a
ing the transitions a skydiver will see going from Proxy LOD to actual level geometry. The
ors are built into the LOD actors.
modes are: Full Sphere, Upper Hemisphere and Traditional Billboards. In order to better
the impostors, I will first show the Billboards and progressively enable expensive features
hem look better. Then the similarity/overlap should make sense.
DepthOffset (PDO) is enabled in the video. This uses the captured depth to offset the pixels
more interesting intersections between the cards and the world. It has the same problem
supported or a good idea to enable for all platforms, plus it makes TempAA look smeary
ax does not match for complicated reasons.
M (parallax mapping) is enabled. Notice how this makes the transitions between frames
other. There are some strange artifacts at the edge of the frames (especially when
g the top view). Those artifacts are very difficult to explain and fix, but I do not intend to
h time fixing them, since enabling full POM on a billboard like this is quite expensive, and it
equire significantly more than 9 frames for POM to look smooth for all views.
wanted to make with the above example is that while decent results can be had with a few
ks, it does not scale to a smooth high quality version. To increase quality we need to add
ard cards. This makes the mesh heavier in terms of both vertex and pixel shader, and
is slow enough without it being in lots of overlapping masked triangles. The 9 card cross is
81 verts, so if we add many more, whats the point? At some point a very low standard LOD
etter, but it would be harder to make.
e was a way to capture more view angles, but render the final material without needing
or each card? That is basically what impostors attempt to do.
hind impostors is to capture the object from a variety of view angles and store each view
. An example of cameras arranged around an upper hemisphere:
d used here is very important. In my previous impostor generator, I defined the capture
evenly spaced X columns split over Y rows based on pitch angle. If that made no sense to
ps this image will help:
e how each 'ring' of the sphere has the same number of verts. So the row near the top of
has verts more densely packed than the equator. This is the layout the old impostor baker
tes tons of resolution around the poles by capturing views that are next together. And yes,
p Z frame also gets repeated instead of just being a single view. At the time the only reason
bove layout was because it was cheap to compute in a shader, whereas the more 'fancy'
th equal spacing that people were writing papers about required expensive trig and
ays because the grids did not map to 2D space uniformly (For example, BN11 in
sion, I am using Octahedra and Hemi Octahedra to handle the mapping. For those not
h octahedra, they are a convenient way to convert between 2D and 3D space, or vice versa.
been used in graphics for a while to compress things like V3 normals to be V2 since the full
preserved (no Z sign loss as with derivenormalZ). UE4 makes use of them in this way
few times. Octahedra have very little distortion. Slightly more than a 6 sided cubemap but
h simpler to compute.
nderstand how Octahedrons come into play, I made this animated gif. It shows the result
ng between 2D grid points and 3D points using Hemi-Octahedron (left) and full
otice that the full octahedron is more evenly spaced. While this is true, the Hemi-
n still gains significant resolution for cases where you never need to see below the horizon.
d of convenient that it gives a bit of over-sampling to the horizon, which is where trees are
n most games. Most trees should use the Hemi-Octahedron layout for that reason. Both of
gnificantly better than the 'old style' method I referenced at the start, notice there are no
close together. Note: I have flipped the edge direction around the poles above to make them
The current shader is not actually doing that correction because it costs a few more instructions and added
did have it working at some point though and its a potential way to improve quality and ensure symmetrical
impostors, you specify how many XY frames you want. That determines how dense the
is. Each vertex on the grid will become a rendered frame. Note that the grid itself is
ual within the vertex shader, it is not actually rendered as a mesh at any point.
the virtual grid over the captured Impostor texture atlas, we can see that the vertices of
n with frame centers in the atlas.
ens if we simply find the nearest frame and draw it on a regular camera facing sprite? The
This video is unavailable.
or rotates wildly from the top view. This is because the view transform is changing quite a
ose top views. If we think about the original billboard, each 'view' was always locked to its
rldspace. if we want to render with a sprite, we also need to lock the sprite to the original
tion it was captured at. That means it needs to change every time the view changes
at gets us looking like:
ck to the 'virtual grid mesh' above, we can see that for any triangle on the grid, it has 3
if we want to blend smoothly across this grid, we need to be able to identify the 3 nearest
d remember how using a sprite caused messed up projection of just one frame? Well it
he same thing happens when you try to reuse the projection from one frame for another!
n. So you actually have to render a virtual frame projection for the other 2 frames to
eir geometry. While using the mesh UVs for one projection and 'solving' the other two does
s apart for lower (~8x8) frame counts because the angular difference can be so great
rds that you see the card start to clip at grazing angles (not shown in any videos yet). As a
e, the shader does not use ANY UVs right now. It solves all 3 frames using virtual frame
n the vertex shader and then uses a traditional sprite vertex shader. The only downside is
ances you occasionally see some minor clipping on the edge but it is much more
this way.
er quick video to show how this eliminates all popping. It does slightly blur the result but
erable to popping and is not noticeable at typical impostor distances (0.1 screen size or so):
art is done in 2D space, it is relatively simple. First we find which QUAD (not tri) we are in
standard floor(View2DVec * FrameXY)/FramesXY type operation. Then we say the 'current
an offset of 0, the 'right frame' has an offset of (1,0), the 'lower frame' has an offset of
he 'lower right' frame has an offset of (1,1).
ad, the weights for each frame and the 'triangle mask' are used to identify which part of
the view intersects.
epresents the weight for the upper left or 'current frame'. B (green) represents the weights
e right frame and the lower frame. Notice it is symmetrical across the diagonal. That is
reduce from 4 to 3 neighbors, we 'flip' between either the right or lower neighbor. C (blue)
weight for the lower right frame. D (alpha) is the triangle flip mask. Ie when the ray hits the
we use the right neighbor. When the ray hits the black part of D, we use the lower
o we end up flipping which neighbor is used when the view is on the diagonal. This works
has a weight of 0 along the diagonal. When the camera is perfectly aligned with any vertex,
will always have full weight of 1 and the others will be 0.
ws the intersection being found on both grids, before and after unwrapping. This
es how finding the triangle in 3D also finds it in 2D. Notice the small white dot which is the
mera ray to the center of each sphere. The color of the triangle at that single point is where
are read from.
mage shows what the single depth offset is like, very similar to bump offset. Note that this
y well for very dense trees where the depth mostly forms a cohesive shell. For very sparse
ees, this single offset will show lots of noisy artifacts.
rison shows a 12x12 layout impostor for one of the main Fortnite pine trees. It holds up
at a medium distance. The smallest frame count used in Fortnite is for the smaller farm
get by pretty well with only an 8x8 layout.
ds for Hierarchical LOD. We use HLOD in UE4 to represent distant levels that are not
ded. We tend to refer to those as "Proxy HLODs". Originally, FNBR just used standard
on for all the trees. That was causing HLOD meshes to be a ton of tris/verts and ti also
sland did not look great while skydiving and popping was quite noticeable.
tching to impostors saved ~270,000 verts from being stored in always loaded memory
er unstream) but it cost around 600 draw calls when viewing the whole island. That draw
ostly goes away from the ground.
the impact on an individual POI (point of interest), the Ranger Station aka Lonely Lodge.
LOD was costing almost 13k tris. Impostor HLODs dropped that in half and made it look
memory, they do cost significant texture memory. We saved the 270k verts from proxy
ch is estimated to be around 10mb from memory. But each impostor in FNBR uses a 2048
lpha and 1024 normal/depth. So each tree is 5.4 + 1.4 or 6.8mb of textures. There are
2 trees so thats ~81mb of textures. But the good news is that the texture data is
whereas the proxy mesh data is not.
we limit impostors to 1024 textures across the board. In the ASTC format, the 1024s use
. So on mobile the total texture memory cost is 8.1mb. So when you look at the numbers
witching to impostors DID save memory for mobile and everybody else paid a few megs to
nt automatically makes a mesh cutout based on the combined alpha of all impostor
e cutout method has issues with very thin objects and it fails to make the most optimal cuts
e rows are black. You can press the 'Convert to Manual Cutout' button and adjust the
ually too!
only scratches the surface of some of the experiments I have done with this. There is
her quality 'light field' version of the impostor material (M_Imposter_PerPixel_Parallax)
obably write a followup focusing on it, after GDC.
time Realistic Rendering and Lighting of Forests. Eric Bruneton, Fabrice Neyret
nria.fr/hal-00650120/file/article.pdf
(Spherical) Light Field Rendering with Per-Pixel Depth. Severin Todt, Christof Rezk-Salama
eerx.ist.psu.edu/viewdoc/download?doi=10.1.1.90.6202&rep=rep1&type=pdf
Sort by Oldest
Add a comment...
reg Bolton
ello, I am currently trying to get this plugin to work, I have it installed into the engine and in
e plugins it is checked on. when i drag a combined mesh out into the scene and try to cick
n the impostor BP unreal crashes. this is happening on 4.19, 4.19.1, 4.19.2
Reply ꞏ 3y
eorge Hulm
i, I've got this plugin working in 4.19.2, have you enabled the plugin
ueprintMaterialTextureNodes?
have issues with lighting instances, they don't seem to shadow cast correctly. Any
formation available on this?
Reply ꞏ 3y
Greg Bolton
hello i have gotten it to come up in the scene and have baked the frames . i am
having trouble adding the material node now, i would check into distance field
shadow casting.
Like ꞏ Reply ꞏ 3y
George Hulm
Greg Bolton I got shadow casting to work, but to get the self shadowing and normals
correct I had to make some modifications to the imposter master shader.
What issues are you having with adding the material node?
Like ꞏ Reply ꞏ 3y
Rick Rock
Is this for Real?
https://technoidhub.com/.../fortniteseason8now.../11969/
Like ꞏ Reply ꞏ 2y
ick Rock
this for Real?
tps://technoidhub.com/.../fortniteseason8now.../11969/
Reply ꞏ 2y
rpit Singh
We offer cheap and discounted prices as compared to other smurf websites, Our team
ways make sure our customers get cheap prices on varieties of csgo prime accounts and
on prime accounts.
tps://waytosmurf.com
Reply ꞏ 1y
Comments plugin
RECENT POSTS