Building the Ocean Shader

Open the Shader Graph:

  • Double-click the OceanShader to open the Shader Graph editor.

Base Color Setup:

  • Color Node: Create a Color node and set it to a blue-green color to represent the ocean.
  • Multiply Node (Base Color): Create a Multiply node and connect the Color node to its input.

Wave Texture:

  • Simple Noise Node: Create a Simple Noise node.
  • Tiling and Offset Node: Create a Tiling and Offset node and connect the Simple Noise node to it.
  • Multiply Node (Wave Texture): Create another Multiply node and connect the Tiling and Offset node to it.

Wave Animation:

  • Time Node: Create a Time node.
  • Multiply Node (Speed): Create a Multiply node, connect the Time node to one input, and create a Vector1 node named Speed to the other input.
  • Sine Node: Create a Sine node and connect the Multiply (Speed) node to it.
  • Add Node (UV Coordinates): Create an Add node, connect the Sine node to it, and add UV coordinates as the other input.

Normal Mapping:

  • Simple Noise Node (Height): Create another Simple Noise node for height.
  • Multiply Node (Normal): Create a Multiply node and connect the Simple Noise (Height) node to it.
  • Normal From Height Node: Create a Normal From Height node and connect the Multiply (Normal) node to it.
  • Normal Vector Node: Create a Normal Vector node and connect the Normal From Height node to it.
  • PBR Master (Normal): Connect the Normal Vector node to the Normal input of the PBR Master node.

Reflection Setup:

  • Reflection Probe Node: Create a Reflection Probe node.
  • Multiply Node (Intensity): Create a Multiply node and connect the Reflection Probe node to it. Create a Vector1 node named Intensity and connect it to the other input.
  • Add Node (Base Color Composition): Create an Add node, connect the Multiply (Intensity) node to one input, and connect the Multiply (Base Color) node to the other input.

Refraction Setup:

  • Screen Position Node: Create a Screen Position node.
  • Add Node (Distortion): Create an Add node, connect the Screen Position node to one input, and add distortion as the other input.
  • Sample Texture 2D Node (Screen Texture): Create a Sample Texture 2D node, connect the Add (Distortion) node to its UV input.
  • PBR Master (Refraction): Connect the Sample Texture 2D node to the Refraction input of the PBR Master node.

Finalizing the Shader:

  • PBR Master (Base Color): Connect the Add (Base Color Composition) node to the Base Color input of the PBR Master node.

Leave a comment

Your email address will not be published. Required fields are marked *