Showing the changes to libraries/render-utils/src/Model.cpp (1 of 2 files). Show all
Unified · Split
| @@ -93,46 +93,7 @@ Model::Model(QObject* parent) : · 92 unmodified lines | ||
| 93 | 93 | Model::~Model() { |
| 94 | 94 | deleteGeometry(); |
| 95 | 95 | } |
| 96 | −/* | |
| 97 | −ProgramObject Model::_POprogram; | |
| 98 | −ProgramObject Model::_POnormalMapProgram; | |
| 99 | −ProgramObject Model::_POspecularMapProgram; | |
| 100 | −ProgramObject Model::_POnormalSpecularMapProgram; | |
| 101 | −ProgramObject Model::_POtranslucentProgram; | |
| 102 | − | |
| 103 | −ProgramObject Model::_POlightmapProgram; | |
| 104 | −ProgramObject Model::_POlightmapNormalMapProgram; | |
| 105 | −ProgramObject Model::_POlightmapSpecularMapProgram; | |
| 106 | −ProgramObject Model::_POlightmapNormalSpecularMapProgram; | |
| 107 | − | |
| 108 | −ProgramObject Model::_POshadowProgram; | |
| 109 | − | |
| 110 | −ProgramObject Model::_POskinProgram; | |
| 111 | −ProgramObject Model::_POskinNormalMapProgram; | |
| 112 | −ProgramObject Model::_POskinSpecularMapProgram; | |
| 113 | −ProgramObject Model::_POskinNormalSpecularMapProgram; | |
| 114 | −ProgramObject Model::_POskinTranslucentProgram; | |
| 115 | − | |
| 116 | −ProgramObject Model::_POskinShadowProgram; | |
| 117 | − | |
| 118 | −Model::Locations Model::_POlocations; | |
| 119 | −Model::Locations Model::_POnormalMapLocations; | |
| 120 | −Model::Locations Model::_POspecularMapLocations; | |
| 121 | −Model::Locations Model::_POnormalSpecularMapLocations; | |
| 122 | −Model::Locations Model::_POtranslucentLocations; | |
| 123 | − | |
| 124 | −Model::Locations Model::_POlightmapLocations; | |
| 125 | −Model::Locations Model::_POlightmapNormalMapLocations; | |
| 126 | −Model::Locations Model::_POlightmapSpecularMapLocations; | |
| 127 | −Model::Locations Model::_POlightmapNormalSpecularMapLocations; | |
| 128 | − | |
| 129 | −Model::SkinLocations Model::_POskinLocations; | |
| 130 | −Model::SkinLocations Model::_POskinNormalMapLocations; | |
| 131 | −Model::SkinLocations Model::_POskinSpecularMapLocations; | |
| 132 | −Model::SkinLocations Model::_POskinNormalSpecularMapLocations; | |
| 133 | −Model::SkinLocations Model::_POskinShadowLocations; | |
| 134 | −Model::SkinLocations Model::_POskinTranslucentLocations; | |
| 135 | −*/ | |
| 96 | + | |
| 136 | 97 | gpu::ShaderPointer Model::_program; |
| 137 | 98 | gpu::ShaderPointer Model::_normalMapProgram; |
| 138 | 99 | gpu::ShaderPointer Model::_specularMapProgram; |
| @@ -232,100 +193,6 @@ void Model::initSkinProgram(gpu::ShaderPointer& program, Model::SkinLocations& l · 93 unmodified lines | ||
| 232 | 193 | locations.clusterIndices = program->getInputs().findLocation("clusterIndices");; |
| 233 | 194 | locations.clusterWeights = program->getInputs().findLocation("clusterWeights");; |
| 234 | 195 | } |
| 235 | −/* | |
| 236 | −void Model::initProgram(ProgramObject& program, Model::Locations& locations, bool link) { | |
| 237 | − if (link) { | |
| 238 | − program.bindAttributeLocation("tangent", gpu::Stream::TANGENT); | |
| 239 | − program.bindAttributeLocation("texcoord1", gpu::Stream::TEXCOORD1); | |
| 240 | − program.link(); | |
| 241 | − } | |
| 242 | − program.bind(); | |
| 243 | − | |
| 244 | − locations.tangent = program.attributeLocation("tangent"); | |
| 245 | − | |
| 246 | − locations.alphaThreshold = program.uniformLocation("alphaThreshold"); | |
| 247 | − locations.texcoordMatrices = program.uniformLocation("texcoordMatrices"); | |
| 248 | − locations.emissiveParams = program.uniformLocation("emissiveParams"); | |
| 249 | − locations.glowIntensity = program.uniformLocation("glowIntensity"); | |
| 250 | − program.setUniformValue("diffuseMap", 0); | |
| 251 | − program.setUniformValue("normalMap", 1); | |
| 252 | − | |
| 253 | − int loc = program.uniformLocation("specularMap"); | |
| 254 | − if (loc >= 0) { | |
| 255 | − program.setUniformValue("specularMap", 2); | |
| 256 | − locations.specularTextureUnit = 2; | |
| 257 | − } else { | |
| 258 | − locations.specularTextureUnit = -1; | |
| 259 | − } | |
| 260 | − | |
| 261 | − loc = program.uniformLocation("emissiveMap"); | |
| 262 | − if (loc >= 0) { | |
| 263 | − program.setUniformValue("emissiveMap", 3); | |
| 264 | − locations.emissiveTextureUnit = 3; | |
| 265 | − } else { | |
| 266 | − locations.emissiveTextureUnit = -1; | |
| 267 | − } | |
| 268 | − | |
| 269 | − // bindable uniform version | |
| 270 | − | |
| 271 | −#if (GPU_FEATURE_PROFILE == GPU_CORE) | |
| 272 | − loc = glGetUniformBlockIndex(program.programId(), "materialBuffer"); | |
| 273 | − if (loc >= 0) { | |
| 274 | − glUniformBlockBinding(program.programId(), loc, MATERIAL_GPU_SLOT); | |
| 275 | − locations.materialBufferUnit = MATERIAL_GPU_SLOT; | |
| 276 | − } else { | |
| 277 | − locations.materialBufferUnit = -1; | |
| 278 | − } | |
| 279 | −#else | |
| 280 | − loc = program.uniformLocation("materialBuffer"); | |
| 281 | − if (loc >= 0) { | |
| 282 | − locations.materialBufferUnit = loc; | |
| 283 | − } else { | |
| 284 | − locations.materialBufferUnit = -1; | |
| 285 | − } | |
| 286 | −#endif | |
| 287 | − | |
| 288 | −#if (GPU_FEATURE_PROFILE == GPU_CORE) | |
| 289 | − loc = glGetUniformBlockIndex(program.programId(), "transformObjectBuffer"); | |
| 290 | − if (loc >= 0) { | |
| 291 | − glUniformBlockBinding(program.programId(), loc, gpu::TRANSFORM_OBJECT_SLOT); | |
| 292 | − // locations.materialBufferUnit = 1; | |
| 293 | − } | |
| 294 | −#endif | |
| 295 | − | |
| 296 | −#if (GPU_FEATURE_PROFILE == GPU_CORE) | |
| 297 | − loc = glGetUniformBlockIndex(program.programId(), "transformCameraBuffer"); | |
| 298 | − if (loc >= 0) { | |
| 299 | − glUniformBlockBinding(program.programId(), loc, gpu::TRANSFORM_CAMERA_SLOT); | |
| 300 | − // locations.materialBufferUnit = 1; | |
| 301 | − } | |
| 302 | −#endif | |
| 303 | − | |
| 304 | − //program.link(); | |
| 305 | − if (!program.isLinked()) { | |
| 306 | − program.release(); | |
| 307 | − } | |
| 308 | − | |
| 309 | − program.release(); | |
| 310 | −}*/ | |
| 311 | −/* | |
| 312 | −void Model::initSkinProgram(ProgramObject& program, Model::SkinLocations& locations) { | |
| 313 | − program.bindAttributeLocation("tangent", gpu::Stream::TANGENT); | |
| 314 | − program.bindAttributeLocation("texcoord1", gpu::Stream::TEXCOORD1); | |
| 315 | − program.bindAttributeLocation("clusterIndices", gpu::Stream::SKIN_CLUSTER_INDEX); | |
| 316 | − program.bindAttributeLocation("clusterWeights", gpu::Stream::SKIN_CLUSTER_WEIGHT); | |
| 317 | − program.link(); | |
| 318 | − | |
| 319 | − initProgram(program, locations, false); | |
| 320 | − | |
| 321 | − program.bind(); | |
| 322 | − | |
| 323 | − locations.clusterMatrices = program.uniformLocation("clusterMatrices"); | |
| 324 | − locations.clusterIndices = program.attributeLocation("clusterIndices"); | |
| 325 | − locations.clusterWeights = program.attributeLocation("clusterWeights"); | |
| 326 | − | |
| 327 | − program.release(); | |
| 328 | −}*/ | |
| 329 | 196 | |
| 330 | 197 | QVector<JointState> Model::createJointStates(const FBXGeometry& geometry) { |
| 331 | 198 | QVector<JointState> jointStates; |
| @@ -361,8 +228,6 @@ void Model::initJointTransforms() { · 29 unmodified lines | ||
| 361 | 228 | |
| 362 | 229 | void Model::init() { |
| 363 | 230 | if (_program.isNull()) { |
| 364 | − // if (!_program.isLinked()) { | |
| 365 | − //Work in progress not used yet | |
| 366 | 231 | gpu::Shader::BindingSet slotBindings; |
| 367 | 232 | slotBindings.insert(gpu::Shader::Binding(std::string("materialBuffer"), MATERIAL_GPU_SLOT)); |
| 368 | 233 | slotBindings.insert(gpu::Shader::Binding(std::string("diffuseMap"), 0)); |
| @@ -460,78 +325,6 @@ void Model::init() { · 91 unmodified lines | ||
| 460 | 325 | _skinTranslucentProgram = gpu::ShaderPointer(gpu::Shader::createProgram(skinModelVertex, modelTranslucentPixel)); |
| 461 | 326 | makeResult = gpu::Shader::makeProgram(*_skinTranslucentProgram, slotBindings); |
| 462 | 327 | initSkinProgram(_skinTranslucentProgram, _skinTranslucentLocations); |
| 463 | − | |
| 464 | − /* | |
| 465 | − _POprogram.addShaderFromSourceCode(QGLShader::Vertex, model_vert); | |
| 466 | − _POprogram.addShaderFromSourceCode(QGLShader::Fragment, model_frag); | |
| 467 | − initProgram(_POprogram, _POlocations); | |
| 468 | − | |
| 469 | − _POnormalMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_normal_map_vert); | |
| 470 | − _POnormalMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_map_frag); | |
| 471 | − initProgram(_POnormalMapProgram, _POnormalMapLocations); | |
| 472 | − | |
| 473 | − _POspecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert); | |
| 474 | − _POspecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_specular_map_frag); | |
| 475 | − initProgram(_POspecularMapProgram, _POspecularMapLocations); | |
| 476 | − | |
| 477 | − _POnormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_normal_map_vert); | |
| 478 | − _POnormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_specular_map_frag); | |
| 479 | − initProgram(_POnormalSpecularMapProgram, _POnormalSpecularMapLocations); | |
| 480 | − | |
| 481 | − _POtranslucentProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert); | |
| 482 | − _POtranslucentProgram.addShaderFromSourceCode(QGLShader::Fragment, model_translucent_frag); | |
| 483 | − initProgram(_POtranslucentProgram, _POtranslucentLocations); | |
| 484 | − | |
| 485 | − // Lightmap | |
| 486 | − _POlightmapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_vert); | |
| 487 | − _POlightmapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_frag); | |
| 488 | − initProgram(_POlightmapProgram, _POlightmapLocations); | |
| 489 | − | |
| 490 | − _POlightmapNormalMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_normal_map_vert); | |
| 491 | − _POlightmapNormalMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_normal_map_frag); | |
| 492 | − initProgram(_POlightmapNormalMapProgramddd, _POlightmapNormalMapLocations); | |
| 493 | − | |
| 494 | − _POlightmapSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_vert); | |
| 495 | − _POlightmapSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_specular_map_frag); | |
| 496 | − initProgram(_POlightmapSpecularMapProgram, _POlightmapSpecularMapLocations); | |
| 497 | − | |
| 498 | − _POlightmapNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_normal_map_vert); | |
| 499 | − _POlightmapNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_normal_specular_map_frag); | |
| 500 | − initProgram(_POlightmapNormalSpecularMapProgram, _POlightmapNormalSpecularMapLocations); | |
| 501 | − // end lightmap | |
| 502 | − | |
| 503 | − | |
| 504 | − _POshadowProgram.addShaderFromSourceCode(QGLShader::Vertex, model_shadow_vert); | |
| 505 | − _POshadowProgram.addShaderFromSourceCode(QGLShader::Fragment, model_shadow_frag); | |
| 506 | − // Shadow program uses the same locations as standard rendering path but we still need to set the bindings | |
| 507 | − Model::Locations tempLoc; | |
| 508 | − initProgram(_POshadowProgram, tempLoc); | |
| 509 | − | |
| 510 | − _POskinProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_vert); | |
| 511 | − _POskinProgram.addShaderFromSourceCode(QGLShader::Fragment, model_frag); | |
| 512 | − initSkinProgram(_POskinProgram, _POskinLocations); | |
| 513 | − | |
| 514 | − _POskinNormalMapProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_normal_map_vert); | |
| 515 | − _POskinNormalMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_map_frag); | |
| 516 | − initSkinProgram(_POskinNormalMapProgram, _PaOskinNormalMapLocations); | |
| 517 | − | |
| 518 | − _POskinSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert); | |
| 519 | − _POskinSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_specular_map_frag); | |
| 520 | − initSkinProgram(_POskinSpecularMapProgram, _POskinSpecularMapLocations); | |
| 521 | − | |
| 522 | − _POskinNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_normal_map_vert); | |
| 523 | − _POskinNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_specular_map_frag); | |
| 524 | − initSkinProgram(_POskinNormalSpecularMapProgram, _POskinNormalSpecularMapLocations); | |
| 525 | − | |
| 526 | − _POskinShadowProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_shadow_vert); | |
| 527 | − _POskinShadowProgram.addShaderFromSourceCode(QGLShader::Fragment, model_shadow_frag); | |
| 528 | − initSkinProgram(_POskinShadowProgram, _POskinShadowLocations); | |
| 529 | − | |
| 530 | − | |
| 531 | − _POskinTranslucentProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_vert); | |
| 532 | − _POskinTranslucentProgram.addShaderFromSourceCode(QGLShader::Fragment, model_translucent_frag); | |
| 533 | − initSkinProgram(_POskinTranslucentProgram, _POskinTranslucentLocations); | |
| 534 | − */ | |
| 535 | 328 | } |
| 536 | 329 | } |
| 537 | 330 | |
| @@ -2397,165 +2190,80 @@ QVector<int>* Model::pickMeshList(bool translucent, float alphaThreshold, bool h · 1859 unmodified lines | ||
| 2397 | 2190 | void Model::pickPrograms(gpu::Batch& batch, RenderMode mode, bool translucent, float alphaThreshold, |
| 2398 | 2191 | bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, RenderArgs* args, |
| 2399 | 2192 | Locations*& locations, SkinLocations*& skinLocations) { |
| 2400 | −/* if (false) | |
| 2401 | − { | |
| 2402 | − ProgramObject* program = &_POprogram; | |
| 2403 | − locations = &_POlocations; | |
| 2404 | − ProgramObject* skinProgram = &_POskinProgram; | |
| 2405 | − skinLocations = &_POskinLocations; | |
| 2406 | − if (mode == SHADOW_RENDER_MODE) { | |
| 2407 | − program = &_POshadowProgram; | |
| 2408 | − skinProgram = &_POskinShadowProgram; | |
| 2409 | − skinLocations = &_POskinShadowLocations; | |
| 2410 | − } else if (translucent && alphaThreshold == 0.0f) { | |
| 2411 | − program = &_POtranslucentProgram; | |
| 2412 | − locations = &_POtranslucentLocations; | |
| 2413 | − skinProgram = &_POskinTranslucentProgram; | |
| 2414 | − skinLocations = &_POskinTranslucentLocations; | |
| 2415 | − | |
| 2416 | − } else if (hasLightmap) { | |
| 2417 | − if (hasTangents) { | |
| 2418 | − if (hasSpecular) { | |
| 2419 | − program = &_POlightmapNormalSpecularMapProgram; | |
| 2420 | − locations = &_POlightmapNormalSpecularMapLocations; | |
| 2421 | − skinProgram = NULL; | |
| 2422 | − skinLocations = NULL; | |
| 2423 | − } else { | |
| 2424 | − program = &_POlightmapNormalMapProgram; | |
| 2425 | − locations = &_POlightmapNormalMapLocations; | |
| 2426 | − skinProgram = NULL; | |
| 2427 | − skinLocations = NULL; | |
| 2428 | − } | |
| 2429 | − } else if (hasSpecular) { | |
| 2430 | − program = &_POlightmapSpecularMapProgram; | |
| 2431 | − locations = &_POlightmapSpecularMapLocations; | |
| 2432 | − skinProgram = NULL; | |
| 2433 | − skinLocations = NULL; | |
| 2434 | − } else { | |
| 2435 | − program = &_POlightmapProgram; | |
| 2436 | − locations = &_POlightmapLocations; | |
| 2437 | − skinProgram = NULL; | |
| 2438 | − skinLocations = NULL; | |
| 2439 | − } | |
| 2440 | − } else { | |
| 2441 | − if (hasTangents) { | |
| 2442 | − if (hasSpecular) { | |
| 2443 | − program = &_POnormalSpecularMapProgram; | |
| 2444 | − locations = &_POnormalSpecularMapLocations; | |
| 2445 | − skinProgram = &_POskinNormalSpecularMapProgram; | |
| 2446 | − skinLocations = &_POskinNormalSpecularMapLocations; | |
| 2447 | − } else { | |
| 2448 | − program = &_POnormalMapProgram; | |
| 2449 | − locations = &_POnormalMapLocations; | |
| 2450 | − skinProgram = &_POskinNormalMapProgram; | |
| 2451 | − skinLocations = &_POskinNormalMapLocations; | |
| 2452 | − } | |
| 2453 | − } else if (hasSpecular) { | |
| 2454 | − program = &_POspecularMapProgram; | |
| 2455 | − locations = &_POspecularMapLocations; | |
| 2456 | − skinProgram = &_POskinSpecularMapProgram; | |
| 2457 | − skinLocations = &_POskinSpecularMapLocations; | |
| 2458 | − } | |
| 2459 | − } | |
| 2460 | − | |
| 2461 | − ProgramObject* activeProgram = program; | |
| 2462 | − Locations* activeLocations = locations; | |
| 2463 | − | |
| 2464 | − if (isSkinned) { | |
| 2465 | − activeProgram = skinProgram; | |
| 2466 | − activeLocations = skinLocations; | |
| 2467 | − locations = skinLocations; | |
| 2468 | − } | |
| 2469 | − // This code replace the "bind()" on the QGLProgram | |
| 2470 | − if (!activeProgram->isLinked()) { | |
| 2471 | − activeProgram->link(); | |
| 2472 | − } | |
| 2473 | − | |
| 2474 | − GLBATCH(glUseProgram)(activeProgram->programId()); | |
| 2475 | − | |
| 2476 | − | |
| 2477 | − if ((activeLocations->alphaThreshold > -1) && (mode != SHADOW_RENDER_MODE)) { | |
| 2478 | − GLBATCH(glUniform1f)(activeLocations->alphaThreshold, alphaThreshold); | |
| 2479 | − } | |
| 2480 | − | |
| 2481 | − } | |
| 2482 | − else */ | |
| 2483 | − { | |
| 2484 | − gpu::ShaderPointer program = _program; | |
| 2485 | − locations = &_locations; | |
| 2486 | − gpu::ShaderPointer skinProgram = _skinProgram; | |
| 2487 | − skinLocations = &_skinLocations; | |
| 2488 | − if (mode == SHADOW_RENDER_MODE) { | |
| 2489 | − program = _shadowProgram; | |
| 2490 | − skinProgram = _skinShadowProgram; | |
| 2491 | − skinLocations = &_skinShadowLocations; | |
| 2492 | − } else if (translucent && alphaThreshold == 0.0f) { | |
| 2493 | − program = _translucentProgram; | |
| 2494 | − locations = &_translucentLocations; | |
| 2495 | − skinProgram = _skinTranslucentProgram; | |
| 2496 | − skinLocations = &_skinTranslucentLocations; | |
| 2193 | + gpu::ShaderPointer program = _program; | |
| 2194 | + locations = &_locations; | |
| 2195 | + gpu::ShaderPointer skinProgram = _skinProgram; | |
| 2196 | + skinLocations = &_skinLocations; | |
| 2197 | + if (mode == SHADOW_RENDER_MODE) { | |
| 2198 | + program = _shadowProgram; | |
| 2199 | + skinProgram = _skinShadowProgram; | |
| 2200 | + skinLocations = &_skinShadowLocations; | |
| 2201 | + } else if (translucent && alphaThreshold == 0.0f) { | |
| 2202 | + program = _translucentProgram; | |
| 2203 | + locations = &_translucentLocations; | |
| 2204 | + skinProgram = _skinTranslucentProgram; | |
| 2205 | + skinLocations = &_skinTranslucentLocations; | |
| 2497 | 2206 | |
| 2498 | − } else if (hasLightmap) { | |
| 2499 | − if (hasTangents) { | |
| 2500 | − if (hasSpecular) { | |
| 2501 | − program = _lightmapNormalSpecularMapProgram; | |
| 2502 | − locations = &_lightmapNormalSpecularMapLocations; | |
| 2503 | − skinProgram.reset(nullptr); | |
| 2504 | − skinLocations = NULL; | |
| 2505 | − } else { | |
| 2506 | − program = _lightmapNormalMapProgram; | |
| 2507 | − locations = &_lightmapNormalMapLocations; | |
| 2508 | − skinProgram.reset(nullptr); | |
| 2509 | − skinLocations = NULL; | |
| 2510 | − } | |
| 2511 | − } else if (hasSpecular) { | |
| 2512 | − program = _lightmapSpecularMapProgram; | |
| 2513 | − locations = &_lightmapSpecularMapLocations; | |
| 2207 | + } else if (hasLightmap) { | |
| 2208 | + if (hasTangents) { | |
| 2209 | + if (hasSpecular) { | |
| 2210 | + program = _lightmapNormalSpecularMapProgram; | |
| 2211 | + locations = &_lightmapNormalSpecularMapLocations; | |
| 2514 | 2212 | skinProgram.reset(nullptr); |
| 2515 | 2213 | skinLocations = NULL; |
| 2516 | 2214 | } else { |
| 2517 | − program = _lightmapProgram; | |
| 2518 | − locations = &_lightmapLocations; | |
| 2215 | + program = _lightmapNormalMapProgram; | |
| 2216 | + locations = &_lightmapNormalMapLocations; | |
| 2519 | 2217 | skinProgram.reset(nullptr); |
| 2520 | 2218 | skinLocations = NULL; |
| 2521 | 2219 | } |
| 2220 | + } else if (hasSpecular) { | |
| 2221 | + program = _lightmapSpecularMapProgram; | |
| 2222 | + locations = &_lightmapSpecularMapLocations; | |
| 2223 | + skinProgram.reset(nullptr); | |
| 2224 | + skinLocations = NULL; | |
| 2522 | 2225 | } else { |
| 2523 | − if (hasTangents) { | |
| 2524 | − if (hasSpecular) { | |
| 2525 | − program = _normalSpecularMapProgram; | |
| 2526 | − locations = &_normalSpecularMapLocations; | |
| 2527 | − skinProgram = _skinNormalSpecularMapProgram; | |
| 2528 | − skinLocations = &_skinNormalSpecularMapLocations; | |
| 2529 | − } else { | |
| 2530 | − program = _normalMapProgram; | |
| 2531 | − locations = &_normalMapLocations; | |
| 2532 | − skinProgram = _skinNormalMapProgram; | |
| 2533 | − skinLocations = &_skinNormalMapLocations; | |
| 2534 | − } | |
| 2535 | − } else if (hasSpecular) { | |
| 2536 | − program = _specularMapProgram; | |
| 2537 | − locations = &_specularMapLocations; | |
| 2538 | − skinProgram = _skinSpecularMapProgram; | |
| 2539 | − skinLocations = &_skinSpecularMapLocations; | |
| 2226 | + program = _lightmapProgram; | |
| 2227 | + locations = &_lightmapLocations; | |
| 2228 | + skinProgram.reset(nullptr); | |
| 2229 | + skinLocations = NULL; | |
| 2230 | + } | |
| 2231 | + } else { | |
| 2232 | + if (hasTangents) { | |
| 2233 | + if (hasSpecular) { | |
| 2234 | + program = _normalSpecularMapProgram; | |
| 2235 | + locations = &_normalSpecularMapLocations; | |
| 2236 | + skinProgram = _skinNormalSpecularMapProgram; | |
| 2237 | + skinLocations = &_skinNormalSpecularMapLocations; | |
| 2238 | + } else { | |
| 2239 | + program = _normalMapProgram; | |
| 2240 | + locations = &_normalMapLocations; | |
| 2241 | + skinProgram = _skinNormalMapProgram; | |
| 2242 | + skinLocations = &_skinNormalMapLocations; | |
| 2540 | 2243 | } |
| 2541 | − } | |
| 2244 | + } else if (hasSpecular) { | |
| 2245 | + program = _specularMapProgram; | |
| 2246 | + locations = &_specularMapLocations; | |
| 2247 | + skinProgram = _skinSpecularMapProgram; | |
| 2248 | + skinLocations = &_skinSpecularMapLocations; | |
| 2249 | + } | |
| 2250 | + } | |
| 2542 | 2251 | |
| 2543 | − gpu::ShaderPointer activeProgram = program; | |
| 2544 | − Locations* activeLocations = locations; | |
| 2252 | + gpu::ShaderPointer activeProgram = program; | |
| 2253 | + Locations* activeLocations = locations; | |
| 2545 | 2254 | |
| 2546 | − if (isSkinned) { | |
| 2547 | − activeProgram = skinProgram; | |
| 2548 | − activeLocations = skinLocations; | |
| 2549 | − locations = skinLocations; | |
| 2550 | − } | |
| 2255 | + if (isSkinned) { | |
| 2256 | + activeProgram = skinProgram; | |
| 2257 | + activeLocations = skinLocations; | |
| 2258 | + locations = skinLocations; | |
| 2259 | + } | |
| 2551 | 2260 | |
| 2552 | − GLuint glprogram = gpu::GLBackend::getShaderID(activeProgram); | |
| 2553 | − GLBATCH(glUseProgram)(glprogram); | |
| 2261 | + GLuint glprogram = gpu::GLBackend::getShaderID(activeProgram); | |
| 2262 | + GLBATCH(glUseProgram)(glprogram); | |
| 2554 | 2263 | |
| 2555 | 2264 | |
| 2556 | − if ((activeLocations->alphaThreshold > -1) && (mode != SHADOW_RENDER_MODE)) { | |
| 2557 | − GLBATCH(glUniform1f)(activeLocations->alphaThreshold, alphaThreshold); | |
| 2558 | − } | |
| 2265 | + if ((activeLocations->alphaThreshold > -1) && (mode != SHADOW_RENDER_MODE)) { | |
| 2266 | + GLBATCH(glUniform1f)(activeLocations->alphaThreshold, alphaThreshold); | |
| 2559 | 2267 | } |
| 2560 | 2268 | } |
| 2561 | 2269 | |