/*
 * Copyright (c) 2015 - 2025 Yuriy Kotsarenko. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and limitations under the License.
 */

cbuffer BufferTransform
{
  row_major float4x4 objectViewProj;
  row_major float4x4 objectWorldInvTrans;
  row_major float4x4 objectWorld;
}

void main(
  float3 streamPosition: POSITION0,
  float3 streamNormal: NORMAL0,
  float4 streamColor: COLOR0,
  out float4 outPosition: SV_POSITION,
  out float3 outNormal: NORMAL0,
  out float3 outPositionWorld: TEXCOORD0,
  out float4 outColor: COLOR0)
{
  float4 worldPosition = mul(float4(streamPosition, 1.0f), objectWorld);
  outPosition = mul(worldPosition, objectViewProj);
  outNormal = normalize(mul(float4(streamNormal, 0.0f), objectWorldInvTrans).xyz);
  outPositionWorld = worldPosition.xyz;
  outColor = streamColor;
}