Showing the changes to libraries/render-utils/src/Model.cpp (1 of 1 file). Show all
Unified · Split
| @@ -198,51 +198,51 @@ void Model::initProgram(ProgramObject& program, Model::Locations& locations, boo · 197 unmodified lines | |||
| 198 | locations.emissiveTextureUnit = -1; | 198 | locations.emissiveTextureUnit = -1; |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | // bindable uniform version | 201 | // bindable uniform version |
| 202 | #if defined(Q_OS_MAC) | 202 | #if defined(Q_OS_MAC) |
| 203 | loc = program.uniformLocation("materialBuffer"); | 203 | loc = program.uniformLocation("materialBuffer"); |
| 204 | if (loc >= 0) { | 204 | if (loc >= 0) { |
| 205 | locations.materialBufferUnit = loc; | 205 | locations.materialBufferUnit = loc; |
| 206 | } else { | 206 | } else { |
| 207 | locations.materialBufferUnit = -1; | 207 | locations.materialBufferUnit = -1; |
| 208 | } | 208 | } |
| 209 | #elif defined(Q_OS_WIN) | 209 | #elif defined(Q_OS_WIN) |
| 210 | loc = glGetUniformBlockIndex(program.programId(), "materialBuffer"); | 210 | loc = glGetUniformBlockIndex(program.programId(), "materialBuffer"); |
| 211 | if (loc >= 0) { | 211 | if (loc >= 0) { |
| 212 | glUniformBlockBinding(program.programId(), loc, 1); | 212 | glUniformBlockBinding(program.programId(), loc, 1); |
| 213 | locations.materialBufferUnit = 1; | 213 | locations.materialBufferUnit = 1; |
| 214 | } else { | 214 | } else { |
| 215 | locations.materialBufferUnit = -1; | 215 | locations.materialBufferUnit = -1; |
| 216 | } | 216 | } |
| 217 | #else | 217 | #else |
| 218 | loc = program.uniformLocation("materialBuffer"); | 218 | loc = program.uniformLocation("materialBuffer"); |
| 219 | if (loc >= 0) { | 219 | if (loc >= 0) { |
| 220 | locations.materialBufferUnit = loc; | 220 | locations.materialBufferUnit = loc; |
| 221 | } else { | 221 | } else { |
| 222 | locations.materialBufferUnit = -1; | 222 | locations.materialBufferUnit = -1; |
| 223 | } | 223 | } |
| 224 | #endif | 224 | #endif |
| 225 | 225 | ||
| 226 | #if defined(Q_OS_WIN) | 226 | #if defined(Q_OS_WIN) |
| 227 | loc = glGetUniformBlockIndex(program.programId(), "transformObjectBuffer"); | 227 | loc = glGetUniformBlockIndex(program.programId(), "transformObjectBuffer"); |
| 228 | if (loc >= 0) { | 228 | if (loc >= 0) { |
| 229 | glUniformBlockBinding(program.programId(), loc, gpu::TRANSFORM_OBJECT_SLOT); | 229 | glUniformBlockBinding(program.programId(), loc, gpu::TRANSFORM_OBJECT_SLOT); |
| 230 | // locations.materialBufferUnit = 1; | 230 | // locations.materialBufferUnit = 1; |
| 231 | } | 231 | } |
| 232 | #endif | 232 | #endif |
| 233 | 233 | ||
| 234 | #if defined(Q_OS_WIN) | 234 | #if defined(Q_OS_WIN) |
| 235 | loc = glGetUniformBlockIndex(program.programId(), "transformCameraBuffer"); | 235 | loc = glGetUniformBlockIndex(program.programId(), "transformCameraBuffer"); |
| 236 | if (loc >= 0) { | 236 | if (loc >= 0) { |
| 237 | glUniformBlockBinding(program.programId(), loc, gpu::TRANSFORM_CAMERA_SLOT); | 237 | glUniformBlockBinding(program.programId(), loc, gpu::TRANSFORM_CAMERA_SLOT); |
| 238 | // locations.materialBufferUnit = 1; | 238 | // locations.materialBufferUnit = 1; |
| 239 | } | 239 | } |
| 240 | #endif | 240 | #endif |
| 241 | 241 | ||
| 242 | //program.link(); | 242 | //program.link(); |
| 243 | if (!program.isLinked()) { | 243 | if (!program.isLinked()) { |
| 244 | program.release(); | 244 | program.release(); |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | program.release(); | 247 | program.release(); |
| 248 | } | 248 | } |
| @@ -303,70 +303,70 @@ void Model::init() { · 54 unmodified lines | |||
| 303 | _program.addShaderFromSourceCode(QGLShader::Fragment, model_frag); | 303 | _program.addShaderFromSourceCode(QGLShader::Fragment, model_frag); |
| 304 | initProgram(_program, _locations); | 304 | initProgram(_program, _locations); |
| 305 | 305 | ||
| 306 | _normalMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_normal_map_vert); | 306 | _normalMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_normal_map_vert); |
| 307 | _normalMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_map_frag); | 307 | _normalMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_map_frag); |
| 308 | initProgram(_normalMapProgram, _normalMapLocations); | 308 | initProgram(_normalMapProgram, _normalMapLocations); |
| 309 | 309 | ||
| 310 | _specularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert); | 310 | _specularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert); |
| 311 | _specularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_specular_map_frag); | 311 | _specularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_specular_map_frag); |
| 312 | initProgram(_specularMapProgram, _specularMapLocations); | 312 | initProgram(_specularMapProgram, _specularMapLocations); |
| 313 | 313 | ||
| 314 | _normalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_normal_map_vert); | 314 | _normalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_normal_map_vert); |
| 315 | _normalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_specular_map_frag); | 315 | _normalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_specular_map_frag); |
| 316 | initProgram(_normalSpecularMapProgram, _normalSpecularMapLocations); | 316 | initProgram(_normalSpecularMapProgram, _normalSpecularMapLocations); |
| 317 | 317 | ||
| 318 | _translucentProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert); | 318 | _translucentProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert); |
| 319 | _translucentProgram.addShaderFromSourceCode(QGLShader::Fragment, model_translucent_frag); | 319 | _translucentProgram.addShaderFromSourceCode(QGLShader::Fragment, model_translucent_frag); |
| 320 | initProgram(_translucentProgram, _translucentLocations); | 320 | initProgram(_translucentProgram, _translucentLocations); |
| 321 | 321 | ||
| 322 | // Lightmap | 322 | // Lightmap |
| 323 | _lightmapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_vert); | 323 | _lightmapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_vert); |
| 324 | _lightmapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_frag); | 324 | _lightmapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_frag); |
| 325 | initProgram(_lightmapProgram, _lightmapLocations); | 325 | initProgram(_lightmapProgram, _lightmapLocations); |
| 326 | 326 | ||
| 327 | _lightmapNormalMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_normal_map_vert); | 327 | _lightmapNormalMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_normal_map_vert); |
| 328 | _lightmapNormalMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_normal_map_frag); | 328 | _lightmapNormalMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_normal_map_frag); |
| 329 | initProgram(_lightmapNormalMapProgram, _lightmapNormalMapLocations); | 329 | initProgram(_lightmapNormalMapProgram, _lightmapNormalMapLocations); |
| 330 | 330 | ||
| 331 | _lightmapSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_vert); | 331 | _lightmapSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_vert); |
| 332 | _lightmapSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_specular_map_frag); | 332 | _lightmapSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_specular_map_frag); |
| 333 | initProgram(_lightmapSpecularMapProgram, _lightmapSpecularMapLocations); | 333 | initProgram(_lightmapSpecularMapProgram, _lightmapSpecularMapLocations); |
| 334 | 334 | ||
| 335 | _lightmapNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_normal_map_vert); | 335 | _lightmapNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_lightmap_normal_map_vert); |
| 336 | _lightmapNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_normal_specular_map_frag); | 336 | _lightmapNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_lightmap_normal_specular_map_frag); |
| 337 | initProgram(_lightmapNormalSpecularMapProgram, _lightmapNormalSpecularMapLocations); | 337 | initProgram(_lightmapNormalSpecularMapProgram, _lightmapNormalSpecularMapLocations); |
| 338 | // end lightmap | 338 | // end lightmap |
| 339 | 339 | ||
| 340 | 340 | ||
| 341 | _shadowProgram.addShaderFromSourceCode(QGLShader::Vertex, model_shadow_vert); | 341 | _shadowProgram.addShaderFromSourceCode(QGLShader::Vertex, model_shadow_vert); |
| 342 | _shadowProgram.addShaderFromSourceCode(QGLShader::Fragment, model_shadow_frag); | 342 | _shadowProgram.addShaderFromSourceCode(QGLShader::Fragment, model_shadow_frag); |
| 343 | // Shadow program uses the same locations as standard rendering path but we still need to set the bindings | 343 | // Shadow program uses the same locations as standard rendering path but we still need to set the bindings |
| 344 | Model::Locations tempLoc; | 344 | Model::Locations tempLoc; |
| 345 | initProgram(_shadowProgram, tempLoc); | 345 | initProgram(_shadowProgram, tempLoc); |
| 346 | 346 | ||
| 347 | _skinProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_vert); | 347 | _skinProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_vert); |
| 348 | _skinProgram.addShaderFromSourceCode(QGLShader::Fragment, model_frag); | 348 | _skinProgram.addShaderFromSourceCode(QGLShader::Fragment, model_frag); |
| 349 | initSkinProgram(_skinProgram, _skinLocations); | 349 | initSkinProgram(_skinProgram, _skinLocations); |
| 350 | 350 | ||
| 351 | _skinNormalMapProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_normal_map_vert); | 351 | _skinNormalMapProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_normal_map_vert); |
| 352 | _skinNormalMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_map_frag); | 352 | _skinNormalMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_map_frag); |
| 353 | initSkinProgram(_skinNormalMapProgram, _skinNormalMapLocations); | 353 | initSkinProgram(_skinNormalMapProgram, _skinNormalMapLocations); |
| 354 | 354 | ||
| 355 | _skinSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert); | 355 | _skinSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, model_vert); |
| 356 | _skinSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_specular_map_frag); | 356 | _skinSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_specular_map_frag); |
| 357 | initSkinProgram(_skinSpecularMapProgram, _skinSpecularMapLocations); | 357 | initSkinProgram(_skinSpecularMapProgram, _skinSpecularMapLocations); |
| 358 | 358 | ||
| 359 | _skinNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_normal_map_vert); | 359 | _skinNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_normal_map_vert); |
| 360 | _skinNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_specular_map_frag); | 360 | _skinNormalSpecularMapProgram.addShaderFromSourceCode(QGLShader::Fragment, model_normal_specular_map_frag); |
| 361 | initSkinProgram(_skinNormalSpecularMapProgram, _skinNormalSpecularMapLocations); | 361 | initSkinProgram(_skinNormalSpecularMapProgram, _skinNormalSpecularMapLocations); |
| 362 | 362 | ||
| 363 | _skinShadowProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_shadow_vert); | 363 | _skinShadowProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_shadow_vert); |
| 364 | _skinShadowProgram.addShaderFromSourceCode(QGLShader::Fragment, model_shadow_frag); | 364 | _skinShadowProgram.addShaderFromSourceCode(QGLShader::Fragment, model_shadow_frag); |
| 365 | initSkinProgram(_skinShadowProgram, _skinShadowLocations); | 365 | initSkinProgram(_skinShadowProgram, _skinShadowLocations); |
| 366 | 366 | ||
| 367 | 367 | ||
| 368 | _skinTranslucentProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_vert); | 368 | _skinTranslucentProgram.addShaderFromSourceCode(QGLShader::Vertex, skin_model_vert); |
| 369 | _skinTranslucentProgram.addShaderFromSourceCode(QGLShader::Fragment, model_translucent_frag); | 369 | _skinTranslucentProgram.addShaderFromSourceCode(QGLShader::Fragment, model_translucent_frag); |
| 370 | initSkinProgram(_skinTranslucentProgram, _skinTranslucentLocations); | 370 | initSkinProgram(_skinTranslucentProgram, _skinTranslucentLocations); |
| 371 | } | 371 | } |
| 372 | } | 372 | } |
| @@ -2470,16 +2470,16 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod · 2097 unmodified lines | |||
| 2470 | qDebug() << "part INDEX:" << j; | 2470 | qDebug() << "part INDEX:" << j; |
| 2471 | qDebug() << "NEW part.materialID:" << part.materialID; | 2471 | qDebug() << "NEW part.materialID:" << part.materialID; |
| 2472 | } | 2472 | } |
| 2473 | 2473 | ||
| 2474 | if (locations->glowIntensity >= 0) { | 2474 | if (locations->glowIntensity >= 0) { |
| 2475 | GLBATCH(glUniform1f)(locations->glowIntensity, glowEffect->getIntensity()); | 2475 | GLBATCH(glUniform1f)(locations->glowIntensity, glowEffect->getIntensity()); |
| 2476 | } | 2476 | } |
| 2477 | if (!(translucent && alphaThreshold == 0.0f)) { | 2477 | if (!(translucent && alphaThreshold == 0.0f)) { |
| 2478 | GLBATCH(glAlphaFunc)(GL_EQUAL, glowEffect->getIntensity()); | 2478 | GLBATCH(glAlphaFunc)(GL_EQUAL, glowEffect->getIntensity()); |
| 2479 | } | 2479 | } |
| 2480 | 2480 | ||
| 2481 | if (locations->materialBufferUnit >= 0) { | 2481 | if (locations->materialBufferUnit >= 0) { |
| 2482 | batch.setUniformBuffer(locations->materialBufferUnit, material->getSchemaBuffer()); | 2482 | batch.setUniformBuffer(locations->materialBufferUnit, material->getSchemaBuffer()); |
| 2483 | } | 2483 | } |
| 2484 | 2484 | ||
| 2485 | Texture* diffuseMap = networkPart.diffuseTexture.data(); | 2485 | Texture* diffuseMap = networkPart.diffuseTexture.data(); |