Lighting still looks horrible, but whatever for now

This commit is contained in:
Dynamitos
2024-05-04 09:25:13 +02:00
parent 247d6a54fb
commit f0fd9a7ae7
24 changed files with 563 additions and 386 deletions
+28 -1
View File
@@ -1,10 +1,10 @@
const static float PI = 3.1415926535897932f;
const static uint MAX_PARTICLES = 65536;
const static uint BLOCK_SIZE = 32;
struct ViewParameter
{
float4x4 viewMatrix;
float4x4 inverseViewMatrix;
float4x4 projectionMatrix;
float4x4 inverseProjection;
float4 cameraPos_WS;
@@ -13,6 +13,24 @@ struct ViewParameter
layout(set=0)
ParameterBlock<ViewParameter> pViewParams;
float4 worldToModel(float4x4 inverseTransform, float4 world)
{
float4 model = mul(inverseTransform, world);
model = model / model.w;
return model;
}
float4 viewToWorld(float4 view)
{
float4 world = mul(pViewParams.inverseViewMatrix, view);
world = world / world.w;
return world;
}
float4 clipToView(float4 clip)
{
float4 view = mul(pViewParams.inverseProjection, clip);
@@ -32,6 +50,15 @@ float4 screenToView(float4 screen)
return clipToView(clip);
}
float4 screenToModel(float4x4 inverseTransform, float4 screen)
{
float4 view = screenToView(screen);
float4 world = viewToWorld(view);
return worldToModel(inverseTransform, world);
}
struct Plane
{
float3 n;