Unity-NorthStar / data /Assets /Tutorial /pages /Ocean shader_Fragment Shader.asset
introvoyz041's picture
Migrated from GitHub
d883ffe verified
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4510294d23d964fe59443526f1ca7c4b, type: 3}
m_Name: Ocean Shader_Fragment Shader
m_EditorClassIdentifier:
m_displayName: Fragment Shader
m_hierarchyName: Ocean Shader/Fragment Shader
m_context: {fileID: 11400000, guid: 95a8f8372a6947e40ad18fcd4817087a, type: 2}
m_markdownFile: {fileID: 0}
m_priority: 1005
m_overrideMarkdownText: '# Fragment Shader
The tiling normal map is sampled
using the same UVs as the displacement map. It contains foam and smoothness values
in the blue/alpha channels, discussed shortly. The normal value includes the
X and Z components, with the Y component reconstructed using a `NormalReconstructZ`
function. Since the ocean is a world-space grid, a regular tangent-to-world transform
isn''t needed; we can swizzle the Y and Z channels.
A detail normal map
is sampled with a different scale/offset than the main normal map, usually smaller
than the primary ocean normal map. The normal maps are combined using partial
derivative blending, accurately combining different normals from heightmaps.
This normal map can be scaled, panned, and rotated over time. When panned similarly
to the ocean, with a slightly offset rotation and speed, it adds convincing detail
to the lower-resolution ocean simulation.
When the giant wave is enabled,
partial derivatives combine with the ocean normal and detail normal partial derivatives
to produce the final world space normal. The giant wave is re-evaluated in the
pixel shader to obtain normals, as per-vertex passing often lacked accuracy,
causing visual artifacts.
'
m_overrideMarkdownRoot: .\Documentation/