Unity Products:Amplify Shader Editor/Parallax Occlusion Mapping

From Amplify Creations Wiki
Revision as of 09:37, 26 August 2021 by ampwiki>Amplify RnD Rick
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Samples

The ASE package includes several Parallax samples, be sure to check them out.

AmplifyShaderEditor\Examples\Official\ParallaxMapping
AmplifyShaderEditor\Examples\Official\ParallaxOcclusionMappingPOM
AmplifyShaderEditor\Examples\Official\ParallaxOffsetFakeInterior

About

Parallax occlusion mapping (POM) is an enhancement of the Parallax Mapping technique. Parallax occlusion mapping is used to procedurally create 3D definition in textured surfaces, using a displacement map (similar to a topography map) instead of through the generation of new geometry.[Reference]

Node

The Parallax Occlusion Mapping node calculates the offseted UVs for the parallax occlusion mapping effect. Similarly to the Parallax Mapping node, you must plug the output to the UV Input Port of all channels (Albedo, Normal etc) in order to ensure that the effect is properly displayed. In addition to the Parallax Occlusion Mapping node, you must specify your own derivatives for texture lookups, be sure to set the Mip Mode Texture Sample node to Derivative.

When sampling textures, we must be careful about how to specify derivatives for texture lookups. In general, the displaced texture coordinates have discontinuities (for example, due to sections of the texture that are occluded). When mipmapping or anisotropic filtering is enabled, the GPU needs information about the derivatives of the texture coordinates. Because the GPU approximates derivatives with finite differences, these derivatives have incorrect values at discontinuities. This leads to an incorrect choice of mipmap levels, which in turn leads to visible seams around discontinuities. Instead of using the derivatives of the displaced texture coordinates, we substitute the derivatives of the base texture coordinates. This works because displaced texture coordinates are always continuous, and they vary at approximately the same rate as the base texture coordinates.[Reference]

Input

  • UV - Requires UV coordinates, the example below uses the Texture Coordinates node to define its parameters.
  • Tex (R) - Height/displacement texture (channel set in the node properties) to be used in the Parallax Occlusion effect. Note that you cannot plug a Texture Sample node directly into it, use the Texture Object node instead.
  • SS - If set, uses the connected sampler state connected instead of internally generating one. Must have Use Sampling Macros option turned on over master node properties.
  • Scale - Scale value for the Parallax Occlusion effect.
  • ViewDir - View direction used to calculate the Parallax effect. You can plug a View Direction (tangent) node directly into the Parallax Mapping ViewDir Input Port or supply your own tangent values for specific effects.
  • Reference Plane - Starting reference height point, 0 by default.
  • Array Index - This input is only available if the Clip Silhouette option is toggled in the node properties. Array index when using Texture Array.
  • Curvature - This input is only available if the Use Texture Array option is toggled in the node properties. When enabled, this allows you to use the UV coordinates to clip the effect curvature in the x or v axis.

Output

  • UV Coordinates - Offseted UVs, transform if needed, plug into the Texture Sampler UV Input Port.
ParallaxOcclusionMapping.jpg

Node Properties

  • Channel - Channel used for the effect.
  • Min-Max Samples - Defines the minimum and maximum number of layers extruded.
  • Sidewall Steps - The number of interpolations done to smooth the result on the side of the layer extrusions, min is used at steep angle while max is used at orthogonal angles.
  • Default Scale - Only used when nothing is pluged into the Scale input.
  • Default Ref Plane - Reference plane lets you adjust the starting reference height, 0 = deepen ground, 1 = raise ground, any value above 0 might cause distortions at higher angles.
  • Use Texture Array - Enables the use of a 2D Texture Array through a Texture Object node.
  • Clip Edges - Clip the ends of your uvs to give a more 3D look at the edges. It'll use the tilling given by your Heightmap input.
  • Clip Silhouette - Use the UV coordinates to clip the effect curvature in X or V axis, useful for cylinders, works best with 'Clip Edges' turned OFF.
POM2.jpg

Additional Nodes

Be sure to use the DDX and DDY nodes along with the Texture Coordinates node used for the calculations, it's the quickest way to get the approximate partial derivatives needed for the Parallax Occlusion Mapping effect.

Example

POM2.jpg

Back to Node List