SwayVertexShaderPartVulkan
Package: Libraries.Game.Graphics.Shaders.Vulkan.Vertex · Inherits from: Libraries.Language.Object
The SwayVertexShaderPartVulkan gives the GLSL shared by the 3D vertex shaders and the shadow vertex shaders for the wind: the GPU material as MaterialVulkan writes it, and a function giving how far a vertex of a swaying material moves. Using the same text in each shader keeps a model and its shadow swaying together. A material sways when its flag 128 is set. Its word 21 is the strength: how far a point moves sideways per unit of height above its model's origin. Its word 22 is the wind's direction about the up axis, in radians from +x toward +z. The height is measured along the world's up axis from the instance's origin (the translation of its transform), so a card pitched upright sways by its top as a tree does, and the part below the origin stays still. The movement leans with the wind and wavers with two sine waves of time, offset by where the copy stands, so neighbors don't move as one. Most users will never need this class directly.
Example Code
use Libraries.Game.Graphics.Shaders.Vulkan.Vertex.SwayVertexShaderPartVulkan
SwayVertexShaderPartVulkan sway
text code = sway:GetMaterialCode() + sway:GetSwayFunction()
Actions
GetMaterialCode()
This action returns the GLSL for the GPU material and the Materials buffer reference, to come before the InstanceData struct, which then holds a Materials member where its material's address is. The shader needs GL_EXT_buffer_reference and GL_EXT_scalar_block_layout.
Returns
text: The GLSL text.
GetSwayFunction()
This action returns the GLSL function swayOffset(materials, origin, worldPosition, time), which returns how far a vertex moves in the world: nothing unless its material sways. It must come after GetMaterialCode's text.
Returns
text: The GLSL text.