Skip to content

Commit

Permalink
GRAPHICS: Refactor buildMaterial method of ModelNode
Browse files Browse the repository at this point in the history
This also fixes rendering of KotOR and Jade Empire models with more than
one texture.
  • Loading branch information
vkremianskii authored and DrMcCoy committed Feb 10, 2019
1 parent 1ce3e31 commit 2c57581
Show file tree
Hide file tree
Showing 4 changed files with 267 additions and 214 deletions.
27 changes: 27 additions & 0 deletions src/graphics/aurora/model_kotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,33 @@ void ModelNode_KotOR::buildMaterial() {
ModelNode::buildMaterial();
}

void ModelNode_KotOR::declareShaderInputs(MaterialConfiguration &config, Shader::ShaderDescriptor &cripter) {
ModelNode::declareShaderInputs(config, cripter);
cripter.declareInput(Shader::ShaderDescriptor::INPUT_UV1);
}

void ModelNode_KotOR::setupShaderTexture(MaterialConfiguration &config, int textureIndex, Shader::ShaderDescriptor &cripter) {
if (textureIndex == 1) {
if (config.phandles[1].empty())
return;

config.materialName += "." + config.phandles[1].getName();

cripter.declareSampler(Shader::ShaderDescriptor::SAMPLER_TEXTURE_1,
Shader::ShaderDescriptor::SAMPLER_2D);

cripter.connect(Shader::ShaderDescriptor::SAMPLER_TEXTURE_1,
Shader::ShaderDescriptor::INPUT_UV1,
Shader::ShaderDescriptor::TEXTURE_LIGHTMAP);

cripter.addPass(Shader::ShaderDescriptor::TEXTURE_LIGHTMAP,
Shader::ShaderDescriptor::BLEND_MULTIPLY);

} else {
ModelNode::setupShaderTexture(config, textureIndex, cripter);
}
}

void ModelNode_KotOR::readPositionController(uint8 columnCount, uint16 rowCount, uint16 timeIndex,
uint16 dataIndex, std::vector<float> &data) {
bool bezier = columnCount & 16;
Expand Down
3 changes: 3 additions & 0 deletions src/graphics/aurora/model_kotor.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ class ModelNode_KotOR : public ModelNode {

void buildMaterial();

void declareShaderInputs(MaterialConfiguration &config, Shader::ShaderDescriptor &cripter);
void setupShaderTexture(MaterialConfiguration &config, int textureIndex, Shader::ShaderDescriptor &cripter);

private:
void readNodeControllers(Model_KotOR::ParserContext &ctx, uint32 offset,
uint32 count, std::vector<float> &dataFloat, std::vector<uint32> &dataInt);
Expand Down

0 comments on commit 2c57581

Please sign in to comment.