72 lines
1.6 KiB
HLSL
72 lines
1.6 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 diffuse : DIFFUSE;
|
|
float3 ambient : AMBIENT;
|
|
float3 worldPosition : WORLDPOS;
|
|
};
|
|
|
|
cbuffer CFrame : register(b0)
|
|
{
|
|
float4x4 transformMatrix;
|
|
float4x4 viewMatrix;
|
|
float4x4 projMatrix;
|
|
float4 camPosition;
|
|
|
|
float4 lightDir;
|
|
};
|
|
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 = lightDir;
|
|
float3 I = float3(1.0, 1.0, 0.8);
|
|
float3 md = color.xyz; //float3(1.0, 0.9, 0.9);
|
|
float3 Ia = float3(0.2, 0.2, 0.2);
|
|
|
|
//float3 p = float3(1440, 370, -1365);
|
|
output.diffuse = (I * md) * max(dot(input.normal, L), 0);
|
|
output.ambient = (Ia * md);
|
|
|
|
|
|
/* / length(worldCoords.xyz -
|
|
camPosition.xyz) * 200;*/
|
|
|
|
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.diffuse, 1.0f) / length(input.worldPosition -
|
|
camPosition.xyz) * 200 + float4(input.ambient, 1.0);
|
|
//output.color = float4(input.color, 1.0);
|
|
|
|
return output;
|
|
}
|