mirror of
https://github.com/mwpenny/portal64-still-alive.git
synced 2024-11-26 22:00:25 +00:00
Work on static lighting
This commit is contained in:
parent
0e2a45665d
commit
a16c7f9732
@ -21,6 +21,13 @@ materials:
|
||||
tileSizeS: 1
|
||||
tileSizeT: 2
|
||||
|
||||
staticLit: true
|
||||
|
||||
defaultVertexColor:
|
||||
r: 255
|
||||
g: 255
|
||||
b: 255
|
||||
|
||||
concrete/observationwall_001a:
|
||||
gDPSetTile:
|
||||
filename: ../../portal_pak_modified/materials/concrete/observationwall_001a.png
|
||||
|
@ -704,6 +704,8 @@
|
||||
"type": "number"
|
||||
}, {
|
||||
"type": "string"
|
||||
}, {
|
||||
"type": "boolean"
|
||||
}]
|
||||
}
|
||||
},
|
||||
@ -715,6 +717,9 @@
|
||||
},
|
||||
"sortOrder": {
|
||||
"type": "integer"
|
||||
},
|
||||
"defaultVertexColor": {
|
||||
"$ref": "#/definitions/color"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ unsigned convertByteRange(float value) {
|
||||
}
|
||||
}
|
||||
|
||||
ErrorResult VertexBufferDefinition::Generate(float fixedPointScale, float modelScale, aiQuaternion rotate, std::unique_ptr<FileDefinition>& output, const std::string& fileSuffix) {
|
||||
ErrorResult VertexBufferDefinition::Generate(float fixedPointScale, float modelScale, aiQuaternion rotate, std::unique_ptr<FileDefinition>& output, const std::string& fileSuffix, const PixelRGBAu8& defaultVertexColor) {
|
||||
std::unique_ptr<StructureDataChunk> dataChunk(new StructureDataChunk());
|
||||
|
||||
// aiQuaternion rotateInverse = rotate;
|
||||
@ -182,10 +182,10 @@ unsigned convertByteRange(float value) {
|
||||
vertexNormal->AddPrimitive(convertByteRange(color.b));
|
||||
vertexNormal->AddPrimitive(convertByteRange(color.a));
|
||||
} else {
|
||||
vertexNormal->AddPrimitive(0);
|
||||
vertexNormal->AddPrimitive(0);
|
||||
vertexNormal->AddPrimitive(0);
|
||||
vertexNormal->AddPrimitive(255);
|
||||
vertexNormal->AddPrimitive((int)defaultVertexColor.r);
|
||||
vertexNormal->AddPrimitive((int)defaultVertexColor.g);
|
||||
vertexNormal->AddPrimitive((int)defaultVertexColor.b);
|
||||
vertexNormal->AddPrimitive((int)defaultVertexColor.a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -232,7 +232,7 @@ void CFileDefinition::AddHeader(const std::string& name) {
|
||||
mHeaders.insert(name);
|
||||
}
|
||||
|
||||
std::string CFileDefinition::GetVertexBuffer(std::shared_ptr<ExtendedMesh> mesh, VertexType vertexType, int textureWidth, int textureHeight, const std::string& modelSuffix) {
|
||||
std::string CFileDefinition::GetVertexBuffer(std::shared_ptr<ExtendedMesh> mesh, VertexType vertexType, int textureWidth, int textureHeight, const std::string& modelSuffix, const PixelRGBAu8& defaultVertexColor) {
|
||||
for (auto existing = mVertexBuffers.begin(); existing != mVertexBuffers.end(); ++existing) {
|
||||
if (existing->second.mTargetMesh == mesh && existing->second.mVertexType == vertexType) {
|
||||
return existing->first;
|
||||
@ -284,7 +284,7 @@ std::string CFileDefinition::GetVertexBuffer(std::shared_ptr<ExtendedMesh> mesh,
|
||||
|
||||
std::unique_ptr<FileDefinition> vtxDef;
|
||||
|
||||
ErrorResult result = mVertexBuffers.find(name)->second.Generate(mFixedPointScale, mModelScale, mModelRotate, vtxDef, modelSuffix);
|
||||
ErrorResult result = mVertexBuffers.find(name)->second.Generate(mFixedPointScale, mModelScale, mModelRotate, vtxDef, modelSuffix, defaultVertexColor);
|
||||
|
||||
if (result.HasError()) {
|
||||
std::cerr << "Error generating vertex buffer " << name << " error: " << result.GetMessage() << std::endl;
|
||||
@ -311,7 +311,7 @@ std::string CFileDefinition::GetCullingBuffer(const std::string& name, const aiV
|
||||
mesh->mVertices[7] = aiVector3D(max.x, max.y, max.z);
|
||||
|
||||
BoneHierarchy boneHierarchy;
|
||||
return GetVertexBuffer(std::shared_ptr<ExtendedMesh>(new ExtendedMesh(mesh, boneHierarchy)), VertexType::PosUVNormal, 0, 0, modelSuffix);
|
||||
return GetVertexBuffer(std::shared_ptr<ExtendedMesh>(new ExtendedMesh(mesh, boneHierarchy)), VertexType::PosUVNormal, 0, 0, modelSuffix, PixelRGBAu8());
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "./ErrorResult.h"
|
||||
#include "./ExtendedMesh.h"
|
||||
#include "./definitions/FileDefinition.h"
|
||||
#include "./materials/TextureDefinition.h"
|
||||
|
||||
class VertexBufferDefinition {
|
||||
public:
|
||||
@ -22,7 +23,7 @@ public:
|
||||
int mTextureWidth;
|
||||
int mTextureHeight;
|
||||
|
||||
ErrorResult Generate(float fixedPointScale, float modelScale, aiQuaternion rotate, std::unique_ptr<FileDefinition>& output, const std::string& fileSuffix);
|
||||
ErrorResult Generate(float fixedPointScale, float modelScale, aiQuaternion rotate, std::unique_ptr<FileDefinition>& output, const std::string& fileSuffix, const PixelRGBAu8& defaultVertexColor);
|
||||
private:
|
||||
};
|
||||
|
||||
@ -36,7 +37,7 @@ public:
|
||||
|
||||
void AddHeader(const std::string& name);
|
||||
|
||||
std::string GetVertexBuffer(std::shared_ptr<ExtendedMesh> mesh, VertexType vertexType, int textureWidth, int textureHeight, const std::string& modelSuffix);
|
||||
std::string GetVertexBuffer(std::shared_ptr<ExtendedMesh> mesh, VertexType vertexType, int textureWidth, int textureHeight, const std::string& modelSuffix, const PixelRGBAu8& defaultVertexColor);
|
||||
std::string GetCullingBuffer(const std::string& name, const aiVector3D& min, const aiVector3D& max, const std::string& modelSuffix);
|
||||
|
||||
std::string GetUniqueName(std::string requestedName);
|
||||
|
@ -113,7 +113,8 @@ void generateMeshIntoDLWithMaterials(const aiScene* scene, CFileDefinition& file
|
||||
Material::GetVertexType(chunk->mMaterial),
|
||||
Material::TextureWidth(chunk->mMaterial),
|
||||
Material::TextureHeight(chunk->mMaterial),
|
||||
modelSuffix
|
||||
modelSuffix,
|
||||
chunk->mMaterial->mDefaultVertexColor
|
||||
);
|
||||
generateGeometry(*chunk, rcpState, vertexBuffer, displayList, settings.mHasTri2);
|
||||
} else if (chunk->mAttachedDLIndex != -1) {
|
||||
|
@ -141,6 +141,13 @@ void toLua(lua_State* L, Material* material) {
|
||||
toLua(L, MaterialGenerator::MaterialIndexMacroName(material->mName));
|
||||
lua_setfield(L, -2, "macro_name");
|
||||
|
||||
lua_createtable(L, 0, material->mProperties.size());
|
||||
for (auto it : material->mProperties) {
|
||||
toLua(L, it.second);
|
||||
lua_setfield(L, -2, it.first.c_str());
|
||||
}
|
||||
lua_setfield(L, -2, "properties");
|
||||
|
||||
lua_pushlightuserdata(L, material);
|
||||
lua_setfield(L, -2, "ptr");
|
||||
}
|
||||
@ -418,7 +425,8 @@ int luaGetMeshVertexBuffer(lua_State* L) {
|
||||
Material::GetVertexType(material),
|
||||
Material::TextureWidth(material),
|
||||
Material::TextureHeight(material),
|
||||
suffix
|
||||
suffix,
|
||||
material->mDefaultVertexColor
|
||||
);
|
||||
|
||||
luaLoadModuleFunction(L, "sk_definition_writer", "raw");
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
NormalSource mNormalSource;
|
||||
bool mExcludeFromOutut;
|
||||
int mSortOrder;
|
||||
PixelRGBAu8 mDefaultVertexColor;
|
||||
|
||||
void Write(CFileDefinition& fileDef, const MaterialState& from, StructureDataChunk& output, bool targetCIBuffer);
|
||||
|
||||
|
@ -799,6 +799,10 @@ std::shared_ptr<Material> parseMaterial(const std::string& name, const YAML::Nod
|
||||
|
||||
material->mSortOrder = parseOptionalInteger(node["sortOrder"], output, std::numeric_limits<int>::min(), std::numeric_limits<int>::max(), 0);
|
||||
|
||||
if (!parseMaterialColor(node["defaultVertexColor"], material->mDefaultVertexColor, output)) {
|
||||
material->mDefaultVertexColor = PixelRGBAu8(255, 255, 255, 255);
|
||||
}
|
||||
|
||||
return material;
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ local sk_mesh = require('sk_mesh')
|
||||
local sk_input = require('sk_input')
|
||||
local room_export = require('tools.level_scripts.room_export')
|
||||
local animation = require('tools.level_scripts.animation')
|
||||
local static_lighting = require('tools.level_scripts.static_lighting');
|
||||
|
||||
sk_definition_writer.add_header('"../build/assets/materials/static.h"')
|
||||
sk_definition_writer.add_header('"levels/level_definition.h"')
|
||||
@ -30,6 +31,12 @@ local function proccessStaticNodes(nodes)
|
||||
original_bb.max = original_bb.max - parent_pos
|
||||
end
|
||||
|
||||
if chunkV.material.properties.staticLit == "true" then
|
||||
for index, pos in pairs(chunkV.mesh.vertices) do
|
||||
-- chunkV.mesh.colors[index] = static_lighting.light_vertex(pos, chunkV.mesh.normals[index])
|
||||
end
|
||||
end
|
||||
|
||||
local gfxName = sk_mesh.generate_mesh({chunkV}, "_geo", {defaultMaterial = chunkV.material})
|
||||
|
||||
local mesh_bb = original_bb * bb_scale
|
||||
|
Loading…
Reference in New Issue
Block a user