add .material version check.

This commit is contained in:
hyzboy 2020-09-17 21:56:16 +08:00
parent 37ffb5dc8c
commit e7ed72d6e2
4 changed files with 75 additions and 72 deletions

View File

@ -42,7 +42,7 @@ private:
bool InitMaterial()
{
material=shader_manage->CreateMaterial(OS_TEXT("res/material/Atmosphere"));
material=shader_manage->CreateMaterial(OS_TEXT("res/material/Atmosphere")); //不需要写.material的扩展名
if(!material)
return(false);

View File

@ -46,6 +46,8 @@ SOURCE_GROUP("Descriptor Sets" FILES ${VK_DESCRIPTOR_SETS_SOURCE})
SET(VK_SHADER_SOURCE ${RD_INCLUDE_PATH}/VKShaderModule.h
${RD_INCLUDE_PATH}/VKShaderModuleManage.h
${RD_INCLUDE_PATH}/ShaderModuleMap.h
ShaderModuleMap.cpp
VKShaderModule.cpp
VKShaderModuleManage.cpp)
@ -59,8 +61,6 @@ SET(VK_TEXTURE_SOURCE ${RD_INCLUDE_PATH}/VKImageView.h
SET(VK_MATERIAL_SOURCE ${RD_INCLUDE_PATH}/VKMaterial.h
${RD_INCLUDE_PATH}/VKMaterialInstance.h
${RD_INCLUDE_PATH}/ShaderModuleMap.h
ShaderModuleMap.cpp
VKMaterial.cpp
VKMaterialInstance.cpp)

View File

@ -231,6 +231,9 @@ Material *ShaderModuleManage::CreateMaterial(const OSString &filename)
++sp;
--left;
if(ver!=1)
return(nullptr);
const uint32_t shader_bits=*(uint32_t *)sp;
sp+=sizeof(uint32_t);
left-=sizeof(uint32_t);

View File

@ -709,7 +709,7 @@ namespace hgl
for (i = 0; i < numberSlices; i++)
{
*tp = centerIndex; ++tp;
*tp = centerIndex; ++tp;
*tp = indexCounter; ++tp;
*tp = indexCounter + 1; ++tp;
@ -723,7 +723,7 @@ namespace hgl
for (i = 0; i < numberSlices; i++)
{
*tp = centerIndex; ++tp;
*tp = centerIndex; ++tp;
*tp = indexCounter + 1; ++tp;
*tp = indexCounter; ++tp;
@ -734,11 +734,11 @@ namespace hgl
// Sides
for (i = 0; i < numberSlices; i++)
{
*tp = indexCounter; ++tp;
*tp = indexCounter; ++tp;
*tp = indexCounter + 1; ++tp;
*tp = indexCounter + 2; ++tp;
*tp = indexCounter + 2; ++tp;
*tp = indexCounter + 2; ++tp;
*tp = indexCounter + 1; ++tp;
*tp = indexCounter + 3; ++tp;
@ -802,11 +802,11 @@ namespace hgl
for(uint i = 0; i < cci->numberSlices + 1; i++)
{
float currentAngle = angleStep * (float)i;
float currentAngle = angleStep * (float)i;
*vp = cos(currentAngle) * cci->radius; ++vp;
*vp = -sin(currentAngle) * cci->radius; ++vp;
*vp = -cci->halfExtend; ++vp;
*vp = cos(currentAngle) * cci->radius; ++vp;
*vp = -sin(currentAngle) * cci->radius; ++vp;
*vp = -cci->halfExtend; ++vp;
if(np)
{
@ -855,11 +855,11 @@ namespace hgl
for(uint i = 0; i < cci->numberSlices + 1; i++)
{
float currentAngle = angleStep * (float)i;
float currentAngle = angleStep * (float)i;
*vp = cos(currentAngle) * cci->radius; ++vp;
*vp = -sin(currentAngle) * cci->radius; ++vp;
*vp = cci->halfExtend; ++vp;
*vp = cos(currentAngle) * cci->radius; ++vp;
*vp = -sin(currentAngle) * cci->radius; ++vp;
*vp = cci->halfExtend; ++vp;
if(np)
{
@ -884,37 +884,37 @@ namespace hgl
for(uint i = 0; i < cci->numberSlices + 1; i++)
{
float currentAngle = angleStep * (float)i;
float currentAngle = angleStep * (float)i;
float sign = -1.0f;
float sign = -1.0f;
for (uint j = 0; j < 2; j++)
for (uint j = 0; j < 2; j++)
{
*vp = cos(currentAngle) * cci->radius; ++vp;
*vp = -sin(currentAngle) * cci->radius; ++vp;
*vp = cci->halfExtend * sign; ++vp;
*vp = cos(currentAngle) * cci->radius; ++vp;
*vp = -sin(currentAngle) * cci->radius; ++vp;
*vp = cci->halfExtend * sign; ++vp;
if(np)
{
*np = cos(currentAngle); ++np;
*np = -sin(currentAngle); ++np;
*np = 0.0f; ++np;
*np = cos(currentAngle); ++np;
*np = -sin(currentAngle); ++np;
*np = 0.0f; ++np;
}
if(tp)
{
*tp = -sin(currentAngle); ++tp;
*tp = -cos(currentAngle); ++tp;
*tp = 0.0f; ++tp;
*tp = -sin(currentAngle); ++tp;
*tp = -cos(currentAngle); ++tp;
*tp = 0.0f; ++tp;
}
if(tcp)
{
*tcp = (float)i / (float)cci->numberSlices; ++tcp;
*tcp = (sign + 1.0f) / 2.0f; ++tcp;
*tcp = (float)i / (float)cci->numberSlices; ++tcp;
*tcp = (sign + 1.0f) / 2.0f; ++tcp;
}
sign = 1.0f;
sign = 1.0f;
}
}
@ -938,7 +938,7 @@ namespace hgl
for (i = 0; i < numberSlices; i++)
{
*tp = centerIndex; ++tp;
*tp = centerIndex; ++tp;
*tp = indexCounter; ++tp;
*tp = indexCounter + 1; ++tp;
@ -947,21 +947,21 @@ namespace hgl
indexCounter++;
// Sides
for (j = 0; j < numberStacks; j++)
{
for (i = 0; i < numberSlices; i++)
{
*tp = indexCounter; ++tp;
*tp = indexCounter + numberSlices + 1; ++tp;
*tp = indexCounter + 1; ++tp;
for (j = 0; j < numberStacks; j++)
{
for (i = 0; i < numberSlices; i++)
{
*tp = indexCounter; ++tp;
*tp = indexCounter + numberSlices + 1; ++tp;
*tp = indexCounter + 1; ++tp;
*tp = indexCounter + 1; ++tp;
*tp = indexCounter + numberSlices + 1; ++tp;
*tp = indexCounter + numberSlices + 2; ++tp;
*tp = indexCounter + 1; ++tp;
*tp = indexCounter + numberSlices + 1; ++tp;
*tp = indexCounter + numberSlices + 2; ++tp;
indexCounter++;
}
indexCounter++;
indexCounter++;
}
indexCounter++;
}
}
}//namespace
@ -1024,63 +1024,63 @@ namespace hgl
for (i = 0; i < cci->numberSlices + 1; i++)
{
float currentAngle = angleStep * (float)i;
float currentAngle = angleStep * (float)i;
*vp = cos(currentAngle) * cci->radius; ++vp;
*vp = -sin(currentAngle) * cci->radius; ++vp;
*vp = -cci->halfExtend; ++vp;
*vp = cos(currentAngle) * cci->radius; ++vp;
*vp = -sin(currentAngle) * cci->radius; ++vp;
*vp = -cci->halfExtend; ++vp;
if(np)
{
*np = 0.0f;++np;
*np = 0.0f;++np;
*np =-1.0f;++np;
*np = 0.0f;++np;
*np = 0.0f;++np;
*np =-1.0f;++np;
}
if(tp)
{
*tp = sin(currentAngle); ++tp;
*tp = cos(currentAngle); ++tp;
*tp = 0.0f; ++tp;
*tp = sin(currentAngle); ++tp;
*tp = cos(currentAngle); ++tp;
*tp = 0.0f; ++tp;
}
if(tcp)
{
*tcp = 0.0f; ++tcp;
*tcp = 0.0f; ++tcp;
*tcp = 0.0f; ++tcp;
*tcp = 0.0f; ++tcp;
}
}
for (j = 0; j < cci->numberStacks + 1; j++)
for (j = 0; j < cci->numberStacks + 1; j++)
{
float level = (float)j / (float)cci->numberStacks;
float level = (float)j / (float)cci->numberStacks;
for (i = 0; i < cci->numberSlices + 1; i++)
{
float currentAngle = angleStep * (float)i;
for (i = 0; i < cci->numberSlices + 1; i++)
{
float currentAngle = angleStep * (float)i;
*vp = cos(currentAngle) * cci->radius * (1.0f - level); ++vp;
*vp = -sin(currentAngle) * cci->radius * (1.0f - level); ++vp;
*vp = -cci->halfExtend + 2.0f * cci->halfExtend * level; ++vp;
*vp = cos(currentAngle) * cci->radius * (1.0f - level); ++vp;
*vp = -sin(currentAngle) * cci->radius * (1.0f - level); ++vp;
*vp = -cci->halfExtend + 2.0f * cci->halfExtend * level; ++vp;
if(np)
{
*np = h / l * cos(currentAngle); ++np;
*np = h / l * -sin(currentAngle); ++np;
*np = r / l; ++np;
*np = h / l * cos(currentAngle); ++np;
*np = h / l * -sin(currentAngle); ++np;
*np = r / l; ++np;
}
if(tp)
{
*tp = -sin(currentAngle); ++tp;
*tp = -cos(currentAngle); ++tp;
*tp = 0.0f; ++tp;
*tp = -sin(currentAngle); ++tp;
*tp = -cos(currentAngle); ++tp;
*tp = 0.0f; ++tp;
}
if(tcp)
{
*tcp = (float)i / (float)cci->numberSlices; ++tcp;
*tcp = level; ++tcp;
*tcp = (float)i / (float)cci->numberSlices; ++tcp;
*tcp = level; ++tcp;
}
}
}