ModelVertex

fragment %FRAGMENTNAME%

AutoBlock

inputs
{
    // Local to World matrix
    float4x4 World;

    // World to View matrix
    float4x4 View;

    // View to Projection (Clip space) matrix
    float4x4 Projection;

    // Local to View matrix
    float4x4 WorldView;

    // World to Projection matrix
    float4x4 ViewProjection;

    // Local to Projection matrix
    float4x4 WorldViewProjection;

	// Vertex position in Local space
    float3 Position;

    // Vertex Normal in Local space
    float3 Normal;

    // Vertex Tangent in Local space
    float3 Tangent;

    // Vertex Bitangent in Local space
    float3 Bitangent;

    // Time in seconds
    float Time;

    // First set of Uv's
    float2 Uv;

    // Second set of Uv's
    float2 Uv1;

    // The color of the current vertex
    float4 VertexColor;
}

outputs
{
    // These three outputs are required

    // Normal in View space
    float3 Normal;

    // Position in Clip space
    float4 Projected;

    // Position in View space
    float3 PixelPosition;
}

fragmentCode

void %FRAGMENTNAME%(inout Data data)
{
    // Scrolling sin wave
    float sinWave = sin(data.Time) * 0.1 + 0.1;

    // Project the position out by its normal
    float3 newPosView = data.Position + (data.Normal * sinWave);

    // Bring the Local position to the Clip space
    // 1.0 needs to be the fourth element when multiplying by the matrix as it's a position
    data.Projected = mul(data.WorldViewProjection, float4(newPosView, 1));

    // Bring the Local normal to View space
    // 0 needs to be the fourth element when multiplying by the matrix as it's a normal
    data.Normal = mul(data.WorldView, float4(data.Normal, 0) ).xyz;

    // Bring the Local position to View space
    // 1.0 needs to be the fourth element when multiplying by the matrix as it's a position
    data.PixelPosition = mul(data.WorldView, float4(newPosView, 1) ).xyz;
}
