depth, normals i guess
This commit is contained in:
@@ -27,6 +27,7 @@ DECLARE_BUILD_STAGE(install_game)
|
|||||||
filesystem2->CopyFile(szOutputDir, GET_PROJECT_OBJECT(shadercompiler, "fs"));
|
filesystem2->CopyFile(szOutputDir, GET_PROJECT_OBJECT(shadercompiler, "fs"));
|
||||||
filesystem2->CopyFile(szOutputDir, GET_PROJECT_OBJECT(Server, "server"));
|
filesystem2->CopyFile(szOutputDir, GET_PROJECT_OBJECT(Server, "server"));
|
||||||
filesystem2->CopyFile(szOutputDir, GET_PROJECT_OBJECT(Client, "client"));
|
filesystem2->CopyFile(szOutputDir, GET_PROJECT_OBJECT(Client, "client"));
|
||||||
|
filesystem2->CopyDirectory(CUtlString("%s/core",szOutputDir.GetString()), "funnyassets/meshes");
|
||||||
filesystem2->CopyDirectory(CUtlString("%s/core",szOutputDir.GetString()), "build/funnygame/assets/shaders");
|
filesystem2->CopyDirectory(CUtlString("%s/core",szOutputDir.GetString()), "build/funnygame/assets/shaders");
|
||||||
if (Target_t::DefaultTarget().kernel == TARGET_KERNEL_WINDOWS)
|
if (Target_t::DefaultTarget().kernel == TARGET_KERNEL_WINDOWS)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "tier1/interface.h"
|
#include "tier1/interface.h"
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
#include "icvar.h"
|
#include "icvar.h"
|
||||||
|
#include "tier2/ifilesystem.h"
|
||||||
|
|
||||||
void CClientGameDLL::Init()
|
void CClientGameDLL::Init()
|
||||||
{
|
{
|
||||||
@@ -19,6 +20,7 @@ void CClientGameDLL::Init()
|
|||||||
|
|
||||||
pEngineBridge->ConnectInterface(RENDER_CONTEXT_INTERFACE_VERSION, m_pRenderContext);
|
pEngineBridge->ConnectInterface(RENDER_CONTEXT_INTERFACE_VERSION, m_pRenderContext);
|
||||||
pEngineBridge->ConnectInterface("MainWindow", m_pGameWindow);
|
pEngineBridge->ConnectInterface("MainWindow", m_pGameWindow);
|
||||||
|
pEngineBridge->ConnectInterface(FILESYSTEM_INTERFACE_VERSION, filesystem);
|
||||||
pEngineBridge->Init();
|
pEngineBridge->Init();
|
||||||
m_pBridge = pEngineBridge;
|
m_pBridge = pEngineBridge;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,12 +53,16 @@ extern "C" void FunnyMain( int argc, char **argv )
|
|||||||
g_pClientGame->Init();
|
g_pClientGame->Init();
|
||||||
|
|
||||||
|
|
||||||
|
double fPrevious = Plat_GetTime();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
g_pWindowManager->Frame(0);
|
double fCurrent = Plat_GetTime();
|
||||||
g_pServerGame->m_pBridge->Frame(0);
|
double fDelta = fCurrent-fPrevious;
|
||||||
g_pClientGame->m_pBridge->Frame(0);
|
fPrevious = fCurrent;
|
||||||
|
g_pWindowManager->Frame(fDelta);
|
||||||
|
g_pServerGame->m_pBridge->Frame(fDelta);
|
||||||
|
g_pClientGame->m_pBridge->Frame(fDelta);
|
||||||
|
|
||||||
g_pRenderContext->Frame(0);
|
g_pRenderContext->Frame(fDelta);
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Binary file not shown.
@@ -3,7 +3,7 @@ float GetSpecularThreshold( float m_fMetalness )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BRDF_Data
|
struct BRDF_t
|
||||||
{
|
{
|
||||||
float3 m_vRayIn;
|
float3 m_vRayIn;
|
||||||
float3 m_vRayOut;
|
float3 m_vRayOut;
|
||||||
@@ -23,7 +23,7 @@ struct BRDF_Data
|
|||||||
float fSineNormalView = saturate(dot(m_vNormal, m_vRayIn));
|
float fSineNormalView = saturate(dot(m_vNormal, m_vRayIn));
|
||||||
float fFresnelLight = FresnelDiffuseTerm(fSineNormalLight);
|
float fFresnelLight = FresnelDiffuseTerm(fSineNormalLight);
|
||||||
float fFresnelView = FresnelDiffuseTerm(fSineNormalView);
|
float fFresnelView = FresnelDiffuseTerm(fSineNormalView);
|
||||||
return fFresnelView * fFresnelLight;
|
return saturate(dot(m_vNormal,m_vRayOut));
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 GetOutGoingDirection()
|
float3 GetOutGoingDirection()
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
#include "../macros.hlsl"
|
|
||||||
COMMON
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
VS
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
PS
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -4,16 +4,20 @@ COMMON {
|
|||||||
cbuffer CameraInfo
|
cbuffer CameraInfo
|
||||||
{
|
{
|
||||||
float4x4 g_matViewProjection;
|
float4x4 g_matViewProjection;
|
||||||
|
float4 g_vViewPosition;
|
||||||
};
|
};
|
||||||
struct PerModelData
|
struct PerModelData
|
||||||
{
|
{
|
||||||
float4x4 m_matTranslation;
|
float4x4 m_matTranslation;
|
||||||
|
float4x4 m_matRotation;
|
||||||
}
|
}
|
||||||
StructuredBuffer<PerModelData> g_modelData;
|
StructuredBuffer<PerModelData> g_modelData;
|
||||||
struct PS_INPUT
|
struct PS_INPUT
|
||||||
{
|
{
|
||||||
float4 m_vScreenPosition: SV_POSITION;
|
float4 m_vScreenPosition: SV_POSITION;
|
||||||
float4 m_vWorldPosition: POSITION;
|
float4 m_vWorldPosition: POSITION;
|
||||||
|
float4 m_vTexCoord: TEXCOORD0;
|
||||||
|
float4 m_vNormal: NORMAL0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VS
|
VS
|
||||||
@@ -22,6 +26,8 @@ VS
|
|||||||
struct VS_INPUT
|
struct VS_INPUT
|
||||||
{
|
{
|
||||||
float3 m_vPosition: POSITION;
|
float3 m_vPosition: POSITION;
|
||||||
|
float2 m_vTexCoord: TEXCOORD0;
|
||||||
|
float3 m_vNormal: NORMAL0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PS_INPUT vsMain( VS_INPUT input )
|
PS_INPUT vsMain( VS_INPUT input )
|
||||||
@@ -36,7 +42,15 @@ VS
|
|||||||
output.m_vScreenPosition,
|
output.m_vScreenPosition,
|
||||||
g_matViewProjection
|
g_matViewProjection
|
||||||
);
|
);
|
||||||
output.m_vWorldPosition = float4(input.m_vPosition, 1);
|
output.m_vWorldPosition = mul(
|
||||||
|
float4(input.m_vPosition, 1),
|
||||||
|
g_modelData[0].m_matTranslation
|
||||||
|
);
|
||||||
|
output.m_vNormal = mul(
|
||||||
|
float4(input.m_vNormal, 1),
|
||||||
|
g_modelData[0].m_matRotation
|
||||||
|
);
|
||||||
|
output.m_vTexCoord = float4(input.m_vTexCoord, 0, 0);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,8 +61,15 @@ PS
|
|||||||
float4 psMain( PS_INPUT input )
|
float4 psMain( PS_INPUT input )
|
||||||
{
|
{
|
||||||
|
|
||||||
float4 vWorldSpacePosition = input.m_vWorldPosition;
|
float4 vWorldSpacePosition = input.m_vNormal;
|
||||||
return float4(vWorldSpacePosition);
|
BRDF_t brdf = {};
|
||||||
|
brdf.m_vRayIn = normalize(g_vViewPosition.xyz-input.m_vWorldPosition.xyz);
|
||||||
|
brdf.m_vRayOut = normalize(-input.m_vWorldPosition.xyz);
|
||||||
|
brdf.m_vNormal = input.m_vNormal.xyz;
|
||||||
|
brdf.m_fRoughness = 1;
|
||||||
|
brdf.m_fMetalness = 1;
|
||||||
|
|
||||||
|
return float4(brdf.BurleyDiffuse(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ class CFunnyGameBridge: public IEngineBridge
|
|||||||
virtual void Frame( float fDelta ) override;
|
virtual void Frame( float fDelta ) override;
|
||||||
virtual void Shutdown() override;
|
virtual void Shutdown() override;
|
||||||
virtual void ConnectInterface( const char *psz, void *pInterface ) override;
|
virtual void ConnectInterface( const char *psz, void *pInterface ) override;
|
||||||
|
IMeshInstance *m_pMeshInstance;
|
||||||
|
float m_fTime = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
IEngineBridge *EngineBridge()
|
IEngineBridge *EngineBridge()
|
||||||
@@ -35,26 +37,17 @@ void CFunnyGameBridge::Init()
|
|||||||
g_pWorldRenderer->Init();
|
g_pWorldRenderer->Init();
|
||||||
pShader = g_pRenderContext->CreateShader("game/core/shaders/mesh_raster.shader_c");
|
pShader = g_pRenderContext->CreateShader("game/core/shaders/mesh_raster.shader_c");
|
||||||
|
|
||||||
float cubeVertices[][3] = {
|
IFileHandle *pHandle = filesystem->Open("game/core/meshes/cube.fmesh_c", FILEMODE_READ);
|
||||||
{-1, -1, 1}, { 1, -1, 1}, { 1, 1, 1},
|
float *pData = (float*)V_malloc(filesystem->Size(pHandle));
|
||||||
{-1, -1, 1}, { 1, 1, 1}, {-1, 1, 1},
|
filesystem->Read(pHandle, pData, filesystem->Size(pHandle));
|
||||||
{-1, -1, -1}, {-1, 1, -1}, { 1, 1, -1},
|
pBuffer = g_pRenderContext->CreateVertexBuffer(filesystem->Size(pHandle));
|
||||||
{-1, -1, -1}, { 1, 1, -1}, { 1, -1, -1},
|
|
||||||
{-1, -1, -1}, {-1, -1, 1}, {-1, 1, 1},
|
|
||||||
{-1, -1, -1}, {-1, 1, 1}, {-1, 1, -1},
|
|
||||||
{ 1, -1, -1}, { 1, 1, -1}, { 1, 1, 1},
|
|
||||||
{ 1, -1, -1}, { 1, 1, 1}, { 1, -1, 1},
|
|
||||||
{-1, 1, -1}, {-1, 1, 1}, { 1, 1, 1},
|
|
||||||
{-1, 1, -1}, { 1, 1, 1}, { 1, 1, -1},
|
|
||||||
{-1, -1, -1}, { 1, -1, -1}, { 1, -1, 1},
|
|
||||||
{-1, -1, -1}, { 1, -1, 1}, {-1, -1, 1}
|
|
||||||
};
|
|
||||||
pBuffer = g_pRenderContext->CreateVertexBuffer(sizeof(cubeVertices));
|
|
||||||
pBuffer->Lock();
|
pBuffer->Lock();
|
||||||
void *pMapped = pBuffer->Map();
|
void *pMapped = pBuffer->Map();
|
||||||
V_memcpy(pMapped, cubeVertices, sizeof(cubeVertices));
|
V_memcpy(pMapped, pData, filesystem->Size(pHandle));
|
||||||
pBuffer->Unmap();
|
pBuffer->Unmap();
|
||||||
pBuffer->Unlock();
|
pBuffer->Unlock();
|
||||||
|
V_free(pData);
|
||||||
|
filesystem->Close(pHandle);
|
||||||
|
|
||||||
|
|
||||||
IMesh *pMesh = g_pWorldRenderer->CreateMesh("Triangle");
|
IMesh *pMesh = g_pWorldRenderer->CreateMesh("Triangle");
|
||||||
@@ -67,8 +60,8 @@ void CFunnyGameBridge::Init()
|
|||||||
|
|
||||||
pMesh->SetVertices(pBuffer);
|
pMesh->SetVertices(pBuffer);
|
||||||
pMesh->SetMaterial(pMaterial);
|
pMesh->SetMaterial(pMaterial);
|
||||||
IMeshInstance *pMeshInstance = g_pWorldRenderer->CreateInstance(pMesh);
|
m_pMeshInstance = g_pWorldRenderer->CreateInstance(pMesh);
|
||||||
pMeshInstance->SetPosition({1,1,1});
|
m_pMeshInstance->SetScale({5, 5, 5});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFunnyGameBridge::Tick( float fDelta )
|
void CFunnyGameBridge::Tick( float fDelta )
|
||||||
@@ -77,6 +70,11 @@ void CFunnyGameBridge::Tick( float fDelta )
|
|||||||
|
|
||||||
void CFunnyGameBridge::Frame( float fDelta )
|
void CFunnyGameBridge::Frame( float fDelta )
|
||||||
{
|
{
|
||||||
|
versor q;
|
||||||
|
m_fTime += fDelta;
|
||||||
|
glm_euler_zyx_quat((vec3){0,m_fTime, 0}, q);
|
||||||
|
m_pMeshInstance->SetPosition({sin(m_fTime/3)*10,0,0});
|
||||||
|
m_pMeshInstance->SetRotation({q[0], q[1], q[2], q[3]});
|
||||||
g_pWorldRenderer->Frame(fDelta);
|
g_pWorldRenderer->Frame(fDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,6 +87,7 @@ void CFunnyGameBridge::Shutdown()
|
|||||||
void CFunnyGameBridge::ConnectInterface( const char *psz, void *pInterface )
|
void CFunnyGameBridge::ConnectInterface( const char *psz, void *pInterface )
|
||||||
{
|
{
|
||||||
CONNECT_INTERFACE(RENDER_CONTEXT_INTERFACE_VERSION, g_pRenderContext);
|
CONNECT_INTERFACE(RENDER_CONTEXT_INTERFACE_VERSION, g_pRenderContext);
|
||||||
|
CONNECT_INTERFACE(FILESYSTEM_INTERFACE_VERSION, filesystem);
|
||||||
CONNECT_INTERFACE("MainWindow", g_pMainWindow);
|
CONNECT_INTERFACE("MainWindow", g_pMainWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,13 @@
|
|||||||
struct ViewBuffer_t
|
struct ViewBuffer_t
|
||||||
{
|
{
|
||||||
mat4 m_matCameraProjection;
|
mat4 m_matCameraProjection;
|
||||||
|
vec4 m_vCameraPosition;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PerMeshData_t
|
struct PerMeshData_t
|
||||||
{
|
{
|
||||||
mat4 m_matTranslation;
|
mat4 m_matTranslation;
|
||||||
|
mat4 m_matRotation;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CFunnyMeshInstance;
|
class CFunnyMeshInstance;
|
||||||
@@ -35,11 +37,15 @@ public:
|
|||||||
|
|
||||||
void CFunnyMesh::ConfigureShader( IShader *pShader )
|
void CFunnyMesh::ConfigureShader( IShader *pShader )
|
||||||
{
|
{
|
||||||
pShader->AddLayout(0, 12);
|
pShader->AddLayout(0, 32);
|
||||||
pShader->AddAttribute(0, 0, VERTEX_FORMAT_XYZ32_SFLOAT, 0);
|
pShader->AddAttribute(0, 0, VERTEX_FORMAT_XYZ32_SFLOAT, 0);
|
||||||
// color
|
pShader->AddAttribute(0, 1, VERTEX_FORMAT_XY32_SFLOAT, 12);
|
||||||
|
pShader->AddAttribute(0, 2, VERTEX_FORMAT_XYZ32_SFLOAT, 20);
|
||||||
|
// albedo
|
||||||
pShader->AddOutputImage(0, IMAGE_FORMAT_RGBA8_UNORM);
|
pShader->AddOutputImage(0, IMAGE_FORMAT_RGBA8_UNORM);
|
||||||
|
|
||||||
|
pShader->SetMultisampling(MULTISAMPLE_TYPE_1_SAMPLES);
|
||||||
|
|
||||||
pShader->SetDepthImage(IMAGE_FORMAT_D32_SFLOAT);
|
pShader->SetDepthImage(IMAGE_FORMAT_D32_SFLOAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +76,7 @@ public:
|
|||||||
PerMeshData_t m_data = {};
|
PerMeshData_t m_data = {};
|
||||||
Quat m_vRotation = {};
|
Quat m_vRotation = {};
|
||||||
Vector m_vPosition = {};
|
Vector m_vPosition = {};
|
||||||
Vector m_vScale = {};
|
Vector m_vScale = { 1, 1, 1 };
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -91,7 +97,27 @@ void CFunnyMeshInstance::SetScale( Vector vScale )
|
|||||||
}
|
}
|
||||||
void CFunnyMeshInstance::Frame()
|
void CFunnyMeshInstance::Frame()
|
||||||
{
|
{
|
||||||
|
vec3 v;
|
||||||
|
versor q;
|
||||||
|
mat4 m;
|
||||||
glm_mat4_identity(m_data.m_matTranslation);
|
glm_mat4_identity(m_data.m_matTranslation);
|
||||||
|
glm_mat4_identity(m_data.m_matRotation);
|
||||||
|
v[0] = m_vPosition.x;
|
||||||
|
v[1] = m_vPosition.y;
|
||||||
|
v[2] = m_vPosition.z;
|
||||||
|
glm_translate(m_data.m_matTranslation, v);
|
||||||
|
q[0] = m_vRotation.x;
|
||||||
|
q[1] = m_vRotation.y;
|
||||||
|
q[2] = m_vRotation.z;
|
||||||
|
q[3] = m_vRotation.w;
|
||||||
|
glm_quat_mat4(q, m);
|
||||||
|
glm_mat4_mul(m_data.m_matTranslation, m, m_data.m_matTranslation);
|
||||||
|
glm_mat4_mul(m_data.m_matRotation, m, m_data.m_matRotation);
|
||||||
|
v[0] = m_vScale.x;
|
||||||
|
v[1] = m_vScale.y;
|
||||||
|
v[2] = m_vScale.z;
|
||||||
|
glm_scale_make(m, v);
|
||||||
|
glm_mat4_mul(m_data.m_matTranslation, m, m_data.m_matTranslation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -164,7 +190,8 @@ void CFunnyWorldRenderer::Frame( float fDelta )
|
|||||||
*/
|
*/
|
||||||
m_pViewBufferData = (ViewBuffer_t*)m_pViewBuffer->Map();
|
m_pViewBufferData = (ViewBuffer_t*)m_pViewBuffer->Map();
|
||||||
m_pViewBuffer->Lock();
|
m_pViewBuffer->Lock();
|
||||||
V_memcpy(m_pViewBufferData, matCamera, sizeof(matCamera));
|
V_memcpy(&m_pViewBufferData->m_matCameraProjection, matCamera, sizeof(matCamera));
|
||||||
|
V_memcpy(&m_pViewBufferData->m_vCameraPosition, m_vPos, sizeof(vec3));
|
||||||
m_pViewBuffer->Unlock();
|
m_pViewBuffer->Unlock();
|
||||||
m_pViewBuffer->Unmap();
|
m_pViewBuffer->Unmap();
|
||||||
|
|
||||||
@@ -222,7 +249,7 @@ void CFunnyWorldRenderer::Frame( float fDelta )
|
|||||||
continue;
|
continue;
|
||||||
m_pRasterCommandList->SetMaterial(mesh->m_pMaterial);
|
m_pRasterCommandList->SetMaterial(mesh->m_pMaterial);
|
||||||
m_pRasterCommandList->SetVertexBuffer(0, mesh->m_pVertexBuffer);
|
m_pRasterCommandList->SetVertexBuffer(0, mesh->m_pVertexBuffer);
|
||||||
m_pRasterCommandList->DrawPrimitives(mesh->m_pVertexBuffer->GetSize()/12, 0, mesh->m_instances.GetSize(), 0);
|
m_pRasterCommandList->DrawPrimitives(mesh->m_pVertexBuffer->GetSize()/32, 0, mesh->m_instances.GetSize(), 0);
|
||||||
}
|
}
|
||||||
m_pRasterCommandList->EndRecording();
|
m_pRasterCommandList->EndRecording();
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,6 @@ void CCompiledShaderManager::ReadFromFile( CCompiledShader *pShader, const char
|
|||||||
}
|
}
|
||||||
pFile = filesystem->Open(szFile, FILEMODE_READ);
|
pFile = filesystem->Open(szFile, FILEMODE_READ);
|
||||||
uint32_t u = filesystem->Read(pFile, &stHeader, sizeof(ShaderHeader_t));
|
uint32_t u = filesystem->Read(pFile, &stHeader, sizeof(ShaderHeader_t));
|
||||||
V_printf("Read %s %s\n", szFile, Plat_GetWorkingDir());
|
|
||||||
|
|
||||||
objects.Resize(stHeader.m_nNumShaders);
|
objects.Resize(stHeader.m_nNumShaders);
|
||||||
lumps.Resize(stHeader.m_nNumLumps);
|
lumps.Resize(stHeader.m_nNumLumps);
|
||||||
|
|||||||
@@ -323,10 +323,19 @@ void CVkCommandBuffer::TryBarrier( int iCurrent, int iCurrentBuffer )
|
|||||||
imageMemoryBarrier.dstStageMask = VulkanGetStageFlags(barrier.m_eNewDependency);
|
imageMemoryBarrier.dstStageMask = VulkanGetStageFlags(barrier.m_eNewDependency);
|
||||||
imageMemoryBarrier.dstAccessMask = VulkanGetAccessFlags(barrier.m_eNewDependency);
|
imageMemoryBarrier.dstAccessMask = VulkanGetAccessFlags(barrier.m_eNewDependency);
|
||||||
if (barrier.m_eOldDependency == DEPENDENCY_MODE_NEXT_STAGE)
|
if (barrier.m_eOldDependency == DEPENDENCY_MODE_NEXT_STAGE)
|
||||||
|
{
|
||||||
|
if (pImage->m_eLastUsage == DEPENDENCY_MODE_JUST_CREATED)
|
||||||
|
{
|
||||||
|
imageMemoryBarrier.oldLayout = VulkanGetImageLayout(DEPENDENCY_MODE_JUST_CREATED);
|
||||||
|
imageMemoryBarrier.srcStageMask = VulkanGetStageFlags(DEPENDENCY_MODE_JUST_CREATED);
|
||||||
|
imageMemoryBarrier.srcAccessMask = VulkanGetAccessFlags(DEPENDENCY_MODE_JUST_CREATED);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
imageMemoryBarrier.oldLayout = pImage->m_ePreferredLayout;
|
imageMemoryBarrier.oldLayout = pImage->m_ePreferredLayout;
|
||||||
imageMemoryBarrier.srcStageMask = VulkanGetStageFlags(DEPENDENCY_MODE_NEXT_STAGE);
|
imageMemoryBarrier.srcStageMask = VulkanGetStageFlags(DEPENDENCY_MODE_NEXT_STAGE);
|
||||||
imageMemoryBarrier.srcAccessMask = VulkanGetAccessFlags(DEPENDENCY_MODE_NEXT_STAGE);
|
imageMemoryBarrier.srcAccessMask = VulkanGetAccessFlags(DEPENDENCY_MODE_NEXT_STAGE);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
imageMemoryBarrier.oldLayout = VulkanGetImageLayout(barrier.m_eOldDependency);
|
imageMemoryBarrier.oldLayout = VulkanGetImageLayout(barrier.m_eOldDependency);
|
||||||
imageMemoryBarrier.srcStageMask = VulkanGetStageFlags(barrier.m_eOldDependency);
|
imageMemoryBarrier.srcStageMask = VulkanGetStageFlags(barrier.m_eOldDependency);
|
||||||
|
|||||||
@@ -120,6 +120,21 @@ VkFormat CVkImage::GetImageFormat( enum EImageFormat eImageFormat )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VkSampleCountFlagBits CVkImage::GetMultisampling( enum EMultisampleType eImageFormat )
|
||||||
|
{
|
||||||
|
switch ( eImageFormat )
|
||||||
|
{
|
||||||
|
case MULTISAMPLE_TYPE_1_SAMPLES:
|
||||||
|
return VK_SAMPLE_COUNT_1_BIT;
|
||||||
|
case MULTISAMPLE_TYPE_2_SAMPLES:
|
||||||
|
return VK_SAMPLE_COUNT_2_BIT;
|
||||||
|
case MULTISAMPLE_TYPE_4_SAMPLES:
|
||||||
|
return VK_SAMPLE_COUNT_4_BIT;
|
||||||
|
case MULTISAMPLE_TYPE_8_SAMPLES:
|
||||||
|
return VK_SAMPLE_COUNT_8_BIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CVkImage::CreateImage( uint32_t nWidth, uint32_t nHeight, EImageFormat eFormat, EMultisampleType eMultisampleType, VkImageUsageFlagBits eUsage )
|
void CVkImage::CreateImage( uint32_t nWidth, uint32_t nHeight, EImageFormat eFormat, EMultisampleType eMultisampleType, VkImageUsageFlagBits eUsage )
|
||||||
{
|
{
|
||||||
VkImageCreateInfo stCreateInfo = {};
|
VkImageCreateInfo stCreateInfo = {};
|
||||||
@@ -135,7 +150,7 @@ void CVkImage::CreateImage( uint32_t nWidth, uint32_t nHeight, EImageFormat eFor
|
|||||||
stCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
|
stCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||||
stCreateInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
stCreateInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
stCreateInfo.format = GetImageFormat(eFormat);
|
stCreateInfo.format = GetImageFormat(eFormat);
|
||||||
stCreateInfo.samples = VK_SAMPLE_COUNT_1_BIT;
|
stCreateInfo.samples = GetMultisampling(eMultisampleType);
|
||||||
|
|
||||||
stAlloc.usage = VMA_MEMORY_USAGE_AUTO;
|
stAlloc.usage = VMA_MEMORY_USAGE_AUTO;
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ void CVkShader::SetDepthImage( EImageFormat eFormat )
|
|||||||
{
|
{
|
||||||
m_eDepthFormat = CVkImage::GetImageFormat(eFormat);
|
m_eDepthFormat = CVkImage::GetImageFormat(eFormat);
|
||||||
}
|
}
|
||||||
|
void CVkShader::SetMultisampling( EMultisampleType eFormat )
|
||||||
|
{
|
||||||
|
m_eMultiSampling = eFormat;
|
||||||
|
}
|
||||||
void CVkShader::DisablePixelShader( bool bDisable )
|
void CVkShader::DisablePixelShader( bool bDisable )
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -143,7 +147,8 @@ void CVkShader::Build()
|
|||||||
viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
|
viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
|
||||||
|
|
||||||
msaa.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
msaa.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
||||||
msaa.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
|
msaa.rasterizationSamples = CVkImage::GetMultisampling(m_eMultiSampling);
|
||||||
|
|
||||||
|
|
||||||
render.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO;
|
render.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO;
|
||||||
render.colorAttachmentCount = m_eFormats.GetSize();
|
render.colorAttachmentCount = m_eFormats.GetSize();
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ public:
|
|||||||
|
|
||||||
static VkImageViewType GetImageViewType( enum EImageType eImageType );
|
static VkImageViewType GetImageViewType( enum EImageType eImageType );
|
||||||
static VkFormat GetImageFormat( enum EImageFormat eImageFormat );
|
static VkFormat GetImageFormat( enum EImageFormat eImageFormat );
|
||||||
|
static VkSampleCountFlagBits GetMultisampling( enum EMultisampleType eImageFormat );
|
||||||
|
|
||||||
uint32_t m_nWidth;
|
uint32_t m_nWidth;
|
||||||
uint32_t m_nHeight;
|
uint32_t m_nHeight;
|
||||||
@@ -265,6 +266,7 @@ public:
|
|||||||
virtual void SetTopology( ETopologyMode eTopology ) override;
|
virtual void SetTopology( ETopologyMode eTopology ) override;
|
||||||
virtual void AddOutputImage( int iImageIndex, EImageFormat eFormat ) override;
|
virtual void AddOutputImage( int iImageIndex, EImageFormat eFormat ) override;
|
||||||
virtual void SetDepthImage( EImageFormat eFormat ) override;
|
virtual void SetDepthImage( EImageFormat eFormat ) override;
|
||||||
|
virtual void SetMultisampling( EMultisampleType eFormat ) override;
|
||||||
virtual void DisablePixelShader( bool bDisable) override;
|
virtual void DisablePixelShader( bool bDisable) override;
|
||||||
virtual void Build() override;
|
virtual void Build() override;
|
||||||
|
|
||||||
@@ -279,6 +281,7 @@ private:
|
|||||||
CUtlVector<VkVertexInputBindingDescription> m_layouts;
|
CUtlVector<VkVertexInputBindingDescription> m_layouts;
|
||||||
CUtlVector<VkVertexInputAttributeDescription> m_attributes;
|
CUtlVector<VkVertexInputAttributeDescription> m_attributes;
|
||||||
CUtlVector<VkFormat> m_eFormats;
|
CUtlVector<VkFormat> m_eFormats;
|
||||||
|
EMultisampleType m_eMultiSampling;
|
||||||
VkFormat m_eDepthFormat;
|
VkFormat m_eDepthFormat;
|
||||||
bool m_bIsFragmentEnabled;
|
bool m_bIsFragmentEnabled;
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ enum EImageType
|
|||||||
enum EMultisampleType
|
enum EMultisampleType
|
||||||
{
|
{
|
||||||
MULTISAMPLE_TYPE_NONE,
|
MULTISAMPLE_TYPE_NONE,
|
||||||
|
MULTISAMPLE_TYPE_1_SAMPLES = MULTISAMPLE_TYPE_NONE,
|
||||||
MULTISAMPLE_TYPE_2_SAMPLES,
|
MULTISAMPLE_TYPE_2_SAMPLES,
|
||||||
MULTISAMPLE_TYPE_4_SAMPLES,
|
MULTISAMPLE_TYPE_4_SAMPLES,
|
||||||
MULTISAMPLE_TYPE_8_SAMPLES,
|
MULTISAMPLE_TYPE_8_SAMPLES,
|
||||||
@@ -145,6 +146,7 @@ public:
|
|||||||
virtual void SetTopology( ETopologyMode eTopology ) = 0;
|
virtual void SetTopology( ETopologyMode eTopology ) = 0;
|
||||||
virtual void AddOutputImage( int iImageIndex, EImageFormat eFormat ) = 0;
|
virtual void AddOutputImage( int iImageIndex, EImageFormat eFormat ) = 0;
|
||||||
virtual void SetDepthImage( EImageFormat eFormat ) = 0;
|
virtual void SetDepthImage( EImageFormat eFormat ) = 0;
|
||||||
|
virtual void SetMultisampling( EMultisampleType eFormat ) = 0;
|
||||||
virtual void DisablePixelShader( bool bDisable) = 0;
|
virtual void DisablePixelShader( bool bDisable) = 0;
|
||||||
virtual void Build() = 0;
|
virtual void Build() = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -42,21 +42,20 @@ def export_my_format(filepath):
|
|||||||
for loop_index in tri.loops:
|
for loop_index in tri.loops:
|
||||||
vert = mesh.vertices[mesh.loops[loop_index].vertex_index]
|
vert = mesh.vertices[mesh.loops[loop_index].vertex_index]
|
||||||
world_pos = obj.matrix_world @ vert.co
|
world_pos = obj.matrix_world @ vert.co
|
||||||
print(world_pos.x)
|
world_normal = obj.matrix_world @ vert.normal
|
||||||
f.write(struct.pack('f', world_pos.x))
|
f.write(struct.pack('f', world_pos.x))
|
||||||
print(world_pos.y)
|
|
||||||
f.write(struct.pack('f', world_pos.y))
|
f.write(struct.pack('f', world_pos.y))
|
||||||
print(world_pos.z)
|
|
||||||
f.write(struct.pack('f', world_pos.z))
|
f.write(struct.pack('f', world_pos.z))
|
||||||
if uv_layer:
|
if uv_layer:
|
||||||
uv = uv_layer[loop_index].uv
|
uv = uv_layer[loop_index].uv
|
||||||
print(uv.x)
|
|
||||||
f.write(struct.pack('f', uv.x))
|
f.write(struct.pack('f', uv.x))
|
||||||
print(uv.y)
|
|
||||||
f.write(struct.pack('f', uv.y))
|
f.write(struct.pack('f', uv.y))
|
||||||
else:
|
else:
|
||||||
f.write(struct.pack('f', 0))
|
f.write(struct.pack('f', 0))
|
||||||
f.write(struct.pack('f', 0))
|
f.write(struct.pack('f', 0))
|
||||||
|
f.write(struct.pack('f', world_normal.x))
|
||||||
|
f.write(struct.pack('f', world_normal.y))
|
||||||
|
f.write(struct.pack('f', world_normal.z))
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|||||||
BIN
tools/cube.fmesh_c
Normal file
BIN
tools/cube.fmesh_c
Normal file
Binary file not shown.
Reference in New Issue
Block a user