62 lines
1.3 KiB
HLSL

struct VSInput // vertex shader bemeneti struktúra
{
float3 position_D : POSITION;
float3 normal : NORMAL;
};
struct VSOutput // vertex shader kimeneti struktúra
{
float4 position_H : SV_Position;
float3 color : COLOR;
float3 worldPosition : WORLDPOS;
};
cbuffer CFrame : register(b0)
{
float4x4 transformMatrix;
float4x4 viewMatrix;
float4x4 projMatrix;
float4 camPosition;
};
cbuffer CEntity : register(b1)
{
float4x4 worldMatrix;
float4 color;
}
VSOutput vs_main(VSInput input)
{
VSOutput output; // vertex shader kimenete
float4 worldCoords = mul(float4(input.position_D, 1.0), worldMatrix);
output.position_H = mul(worldCoords, mul(viewMatrix, projMatrix));
// TODO fények
float3 L = normalize(float3(1.0, 1.0, 0.5));
float3 I = float3(1.0, 1.0, 0.8);
float3 md = float3(1.0, 0.1, 0.1);
//float3 p = float3(1440, 370, -1365);
output.color = (I * color.xyz) * max(dot(input.normal, L), 0);
output.worldPosition = worldCoords;
return output;
}
struct PSOutput
{
float4 color : SV_Target;
};
PSOutput ps_main(VSOutput input)
{
PSOutput output;
//output.color = float4(0.0f, 1.0f, 0.0f, 1.0f);
output.color = float4(input.color, 1.0f) / length(input.worldPosition -
camPosition.xyz) * 200;
return output;
}