Introducing gpu::State and using it in the Model rendering path and more...
Showing the changes to libraries/render-utils/src/Model.cpp (1 of 37 files). Show all
Unified · Split
| @@ -96,50 +96,89 @@ Model::~Model() { · 95 unmodified lines | ||
| 96 | 96 | deleteGeometry(); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | −gpu::ShaderPointer Model::_program; | |
| 100 | −gpu::ShaderPointer Model::_normalMapProgram; | |
| 101 | −gpu::ShaderPointer Model::_specularMapProgram; | |
| 102 | −gpu::ShaderPointer Model::_normalSpecularMapProgram; | |
| 103 | −gpu::ShaderPointer Model::_translucentProgram; | |
| 104 | − | |
| 105 | −gpu::ShaderPointer Model::_lightmapProgram; | |
| 106 | −gpu::ShaderPointer Model::_lightmapNormalMapProgram; | |
| 107 | −gpu::ShaderPointer Model::_lightmapSpecularMapProgram; | |
| 108 | −gpu::ShaderPointer Model::_lightmapNormalSpecularMapProgram; | |
| 109 | − | |
| 110 | −gpu::ShaderPointer Model::_shadowProgram; | |
| 111 | − | |
| 112 | −gpu::ShaderPointer Model::_skinProgram; | |
| 113 | −gpu::ShaderPointer Model::_skinNormalMapProgram; | |
| 114 | −gpu::ShaderPointer Model::_skinSpecularMapProgram; | |
| 115 | −gpu::ShaderPointer Model::_skinNormalSpecularMapProgram; | |
| 116 | −gpu::ShaderPointer Model::_skinTranslucentProgram; | |
| 117 | − | |
| 118 | −gpu::ShaderPointer Model::_skinShadowProgram; | |
| 119 | − | |
| 120 | −Model::Locations Model::_locations; | |
| 121 | −Model::Locations Model::_normalMapLocations; | |
| 122 | −Model::Locations Model::_specularMapLocations; | |
| 123 | −Model::Locations Model::_normalSpecularMapLocations; | |
| 124 | −Model::Locations Model::_translucentLocations; | |
| 125 | −Model::Locations Model::_shadowLocations; | |
| 126 | − | |
| 127 | −Model::Locations Model::_lightmapLocations; | |
| 128 | −Model::Locations Model::_lightmapNormalMapLocations; | |
| 129 | −Model::Locations Model::_lightmapSpecularMapLocations; | |
| 130 | −Model::Locations Model::_lightmapNormalSpecularMapLocations; | |
| 131 | − | |
| 132 | − | |
| 133 | −Model::SkinLocations Model::_skinLocations; | |
| 134 | −Model::SkinLocations Model::_skinNormalMapLocations; | |
| 135 | −Model::SkinLocations Model::_skinSpecularMapLocations; | |
| 136 | −Model::SkinLocations Model::_skinNormalSpecularMapLocations; | |
| 137 | −Model::SkinLocations Model::_skinTranslucentLocations; | |
| 138 | −Model::SkinLocations Model::_skinShadowLocations; | |
| 99 | +Model::RenderPipelineLib Model::_renderPipelineLib; | |
| 100 | +const GLint MATERIAL_GPU_SLOT = 3; | |
| 101 | + | |
| 102 | +void Model::RenderPipelineLib::addRenderPipeline(Model::RenderKey key, | |
| 103 | + gpu::ShaderPointer& vertexShader, | |
| 104 | + gpu::ShaderPointer& pixelShader ) { | |
| 105 | + | |
| 106 | + gpu::Shader::BindingSet slotBindings; | |
| 107 | + slotBindings.insert(gpu::Shader::Binding(std::string("materialBuffer"), MATERIAL_GPU_SLOT)); | |
| 108 | + slotBindings.insert(gpu::Shader::Binding(std::string("diffuseMap"), 0)); | |
| 109 | + slotBindings.insert(gpu::Shader::Binding(std::string("normalMap"), 1)); | |
| 110 | + slotBindings.insert(gpu::Shader::Binding(std::string("specularMap"), 2)); | |
| 111 | + slotBindings.insert(gpu::Shader::Binding(std::string("emissiveMap"), 3)); | |
| 112 | + | |
| 113 | + gpu::ShaderPointer program = gpu::ShaderPointer(gpu::Shader::createProgram(vertexShader, pixelShader)); | |
| 114 | + bool makeResult = gpu::Shader::makeProgram(*program, slotBindings); | |
| 115 | + | |
| 116 | + | |
| 117 | + auto locations = std::shared_ptr<Locations>(new Locations()); | |
| 118 | + initLocations(program, *locations); | |
| 119 | + | |
| 120 | + | |
| 121 | + gpu::StatePointer state = gpu::StatePointer(new gpu::State()); | |
| 122 | + | |
| 123 | + // Backface on shadow | |
| 124 | + if (key.isShadow()) { | |
| 125 | + state->setCullMode(gpu::State::CULL_FRONT); | |
| 126 | + state->setDepthBias(1.0f); | |
| 127 | + state->setDepthBiasSlopeScale(4.0f); | |
| 128 | + } else { | |
| 129 | + state->setCullMode(gpu::State::CULL_BACK); | |
| 130 | + } | |
| 131 | + | |
| 132 | + // Z test depends if transparent or not | |
| 133 | + state->setDepthTest(true, !key.isTranslucent(), gpu::State::LESS_EQUAL); | |
| 134 | + | |
| 135 | + // Blend on transparent | |
| 136 | + state->setBlendFunction(key.isTranslucent(), | |
| 137 | + gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, | |
| 138 | + gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); | |
| 139 | + | |
| 140 | + // Good to go add the brand new pipeline | |
| 141 | + auto pipeline = gpu::PipelinePointer(gpu::Pipeline::create(program, state)); | |
| 142 | + auto it = insert(value_type(key.getRaw(), RenderPipeline(pipeline, locations))); | |
| 143 | + | |
| 144 | + // If not a shadow pass, create the mirror version from the same state, just change the FrontFace | |
| 145 | + if (!key.isShadow()) { | |
| 146 | + | |
| 147 | + RenderKey mirrorKey(key.getRaw() | RenderKey::IS_MIRROR); | |
| 148 | + gpu::StatePointer mirrorState = gpu::StatePointer(new gpu::State(state->getValues())); | |
| 149 | + | |
| 150 | + mirrorState->setFrontFaceClockwise(true); | |
| 151 | + | |
| 152 | + // create a new RenderPipeline with the same shader side and the mirrorState | |
| 153 | + auto mirrorPipeline = gpu::PipelinePointer(gpu::Pipeline::create(program, mirrorState)); | |
| 154 | + auto it = insert(value_type(mirrorKey.getRaw(), RenderPipeline(mirrorPipeline, locations))); | |
| 155 | + } | |
| 156 | +} | |
| 157 | + | |
| 158 | + | |
| 159 | +void Model::RenderPipelineLib::initLocations(gpu::ShaderPointer& program, Model::Locations& locations) { | |
| 160 | + locations.alphaThreshold = program->getUniforms().findLocation("alphaThreshold"); | |
| 161 | + locations.texcoordMatrices = program->getUniforms().findLocation("texcoordMatrices"); | |
| 162 | + locations.emissiveParams = program->getUniforms().findLocation("emissiveParams"); | |
| 163 | + locations.glowIntensity = program->getUniforms().findLocation("glowIntensity"); | |
| 164 | + | |
| 165 | + locations.specularTextureUnit = program->getTextures().findLocation("specularMap"); | |
| 166 | + locations.emissiveTextureUnit = program->getTextures().findLocation("emissiveMap"); | |
| 167 | + | |
| 168 | +#if (GPU_FEATURE_PROFILE == GPU_CORE) | |
| 169 | + locations.materialBufferUnit = program->getBuffers().findLocation("materialBuffer"); | |
| 170 | +#else | |
| 171 | + locations.materialBufferUnit = program->getUniforms().findLocation("materialBuffer"); | |
| 172 | +#endif | |
| 173 | + locations.clusterMatrices = program->getUniforms().findLocation("clusterMatrices"); | |
| 174 | + | |
| 175 | + locations.clusterIndices = program->getInputs().findLocation("clusterIndices");; | |
| 176 | + locations.clusterWeights = program->getInputs().findLocation("clusterWeights");; | |
| 177 | + | |
| 178 | +} | |
| 139 | 179 | |
| 140 | 180 | AbstractViewStateInterface* Model::_viewState = NULL; |
| 141 | 181 | |
| 142 | −const GLint MATERIAL_GPU_SLOT = 3; | |
| 143 | 182 | |
| 144 | 183 | void Model::setScale(const glm::vec3& scale) { |
| 145 | 184 | setScaleInternal(scale); |
| @@ -171,33 +210,6 @@ void Model::setOffset(const glm::vec3& offset) { · 25 unmodified lines | ||
| 171 | 210 | _snappedToRegistrationPoint = false; |
| 172 | 211 | } |
| 173 | 212 | |
| 174 | −void Model::initProgram(gpu::ShaderPointer& program, Model::Locations& locations) { | |
| 175 | − locations.alphaThreshold = program->getUniforms().findLocation("alphaThreshold"); | |
| 176 | − locations.texcoordMatrices = program->getUniforms().findLocation("texcoordMatrices"); | |
| 177 | − locations.emissiveParams = program->getUniforms().findLocation("emissiveParams"); | |
| 178 | − locations.glowIntensity = program->getUniforms().findLocation("glowIntensity"); | |
| 179 | − | |
| 180 | − locations.specularTextureUnit = program->getTextures().findLocation("specularMap"); | |
| 181 | − locations.emissiveTextureUnit = program->getTextures().findLocation("emissiveMap"); | |
| 182 | − | |
| 183 | −#if (GPU_FEATURE_PROFILE == GPU_CORE) | |
| 184 | − locations.materialBufferUnit = program->getBuffers().findLocation("materialBuffer"); | |
| 185 | −#else | |
| 186 | − locations.materialBufferUnit = program->getUniforms().findLocation("materialBuffer"); | |
| 187 | −#endif | |
| 188 | − | |
| 189 | −} | |
| 190 | − | |
| 191 | −void Model::initSkinProgram(gpu::ShaderPointer& program, Model::SkinLocations& locations) { | |
| 192 | − | |
| 193 | − initProgram(program, locations); | |
| 194 | − | |
| 195 | − locations.clusterMatrices = program->getUniforms().findLocation("clusterMatrices"); | |
| 196 | − | |
| 197 | − locations.clusterIndices = program->getInputs().findLocation("clusterIndices");; | |
| 198 | − locations.clusterWeights = program->getInputs().findLocation("clusterWeights");; | |
| 199 | −} | |
| 200 | − | |
| 201 | 213 | QVector<JointState> Model::createJointStates(const FBXGeometry& geometry) { |
| 202 | 214 | QVector<JointState> jointStates; |
| 203 | 215 | for (int i = 0; i < geometry.joints.size(); ++i) { |
| @@ -231,7 +243,7 @@ void Model::initJointTransforms() { · 27 unmodified lines | ||
| 231 | 243 | } |
| 232 | 244 | |
| 233 | 245 | void Model::init() { |
| 234 | − if (_program.isNull()) { | |
| 246 | + if (_renderPipelineLib.empty()) { | |
| 235 | 247 | gpu::Shader::BindingSet slotBindings; |
| 236 | 248 | slotBindings.insert(gpu::Shader::Binding(std::string("materialBuffer"), MATERIAL_GPU_SLOT)); |
| 237 | 249 | slotBindings.insert(gpu::Shader::Binding(std::string("diffuseMap"), 0)); |
| @@ -261,75 +273,71 @@ void Model::init() { · 23 unmodified lines | ||
| 261 | 273 | auto modelLightmapSpecularMapPixel = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(model_lightmap_specular_map_frag))); |
| 262 | 274 | auto modelLightmapNormalSpecularMapPixel = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(model_lightmap_normal_specular_map_frag))); |
| 263 | 275 | |
| 276 | + // Fill the renderPipelineLib | |
| 277 | + | |
| 278 | + _renderPipelineLib.addRenderPipeline( | |
| 279 | + RenderKey(0), | |
| 280 | + modelVertex, modelPixel); | |
| 264 | 281 | |
| 265 | − bool makeResult = false; | |
| 266 | − | |
| 267 | − // Programs | |
| 268 | − _program = gpu::ShaderPointer(gpu::Shader::createProgram(modelVertex, modelPixel)); | |
| 269 | − makeResult = gpu::Shader::makeProgram(*_program, slotBindings); | |
| 270 | − initProgram(_program, _locations); | |
| 282 | + _renderPipelineLib.addRenderPipeline( | |
| 283 | + RenderKey(RenderKey::HAS_TANGENTS), | |
| 284 | + modelNormalMapVertex, modelNormalMapPixel); | |
| 271 | 285 | |
| 272 | − _normalMapProgram = gpu::ShaderPointer(gpu::Shader::createProgram(modelNormalMapVertex, modelNormalMapPixel)); | |
| 273 | − makeResult = gpu::Shader::makeProgram(*_normalMapProgram, slotBindings); | |
| 274 | − initProgram(_normalMapProgram, _normalMapLocations); | |
| 286 | + _renderPipelineLib.addRenderPipeline( | |
| 287 | + RenderKey(RenderKey::HAS_SPECULAR), | |
| 288 | + modelVertex, modelSpecularMapPixel); | |
| 275 | 289 | |
| 276 | − _specularMapProgram = gpu::ShaderPointer(gpu::Shader::createProgram(modelVertex, modelSpecularMapPixel)); | |
| 277 | − makeResult = gpu::Shader::makeProgram(*_specularMapProgram, slotBindings); | |
| 278 | − initProgram(_specularMapProgram, _specularMapLocations); | |
| 290 | + _renderPipelineLib.addRenderPipeline( | |
| 291 | + RenderKey(RenderKey::HAS_TANGENTS | RenderKey::HAS_SPECULAR), | |
| 292 | + modelNormalMapVertex, modelNormalSpecularMapPixel); | |
| 279 | 293 | |
| 280 | − _normalSpecularMapProgram = gpu::ShaderPointer(gpu::Shader::createProgram(modelNormalMapVertex, modelNormalSpecularMapPixel)); | |
| 281 | − makeResult = gpu::Shader::makeProgram(*_normalSpecularMapProgram, slotBindings); | |
| 282 | − initProgram(_normalSpecularMapProgram, _normalSpecularMapLocations); | |
| 294 | + _renderPipelineLib.addRenderPipeline( | |
| 295 | + RenderKey(RenderKey::IS_TRANSLUCENT), | |
| 296 | + modelVertex, modelTranslucentPixel); | |
| 297 | + | |
| 298 | + _renderPipelineLib.addRenderPipeline( | |
| 299 | + RenderKey(RenderKey::HAS_LIGHTMAP), | |
| 300 | + modelLightmapVertex, modelLightmapPixel); | |
| 301 | + _renderPipelineLib.addRenderPipeline( | |
| 302 | + RenderKey(RenderKey::HAS_LIGHTMAP | RenderKey::HAS_TANGENTS), | |
| 303 | + modelLightmapNormalMapVertex, modelLightmapNormalMapPixel); | |
| 283 | 304 | |
| 284 | − _translucentProgram = gpu::ShaderPointer(gpu::Shader::createProgram(modelVertex, modelTranslucentPixel)); | |
| 285 | − makeResult = gpu::Shader::makeProgram(*_translucentProgram, slotBindings); | |
| 286 | − initProgram(_translucentProgram, _translucentLocations); | |
| 287 | − | |
| 288 | − _shadowProgram = gpu::ShaderPointer(gpu::Shader::createProgram(modelShadowVertex, modelShadowPixel)); | |
| 289 | − makeResult = gpu::Shader::makeProgram(*_shadowProgram, slotBindings); | |
| 290 | − initProgram(_shadowProgram, _shadowLocations); | |
| 305 | + _renderPipelineLib.addRenderPipeline( | |
| 306 | + RenderKey(RenderKey::HAS_LIGHTMAP | RenderKey::HAS_SPECULAR), | |
| 307 | + modelLightmapVertex, modelLightmapSpecularMapPixel); | |
| 291 | 308 | |
| 292 | − _lightmapProgram = gpu::ShaderPointer(gpu::Shader::createProgram(modelLightmapVertex, modelLightmapPixel)); | |
| 293 | − makeResult = gpu::Shader::makeProgram(*_lightmapProgram, slotBindings); | |
| 294 | − initProgram(_lightmapProgram, _lightmapLocations); | |
| 309 | + _renderPipelineLib.addRenderPipeline( | |
| 310 | + RenderKey(RenderKey::HAS_LIGHTMAP | RenderKey::HAS_TANGENTS | RenderKey::HAS_SPECULAR), | |
| 311 | + modelLightmapNormalMapVertex, modelLightmapNormalSpecularMapPixel); | |
| 295 | 312 | |
| 296 | − _lightmapNormalMapProgram = gpu::ShaderPointer(gpu::Shader::createProgram(modelLightmapNormalMapVertex, modelLightmapNormalMapPixel)); | |
| 297 | − makeResult = gpu::Shader::makeProgram(*_lightmapNormalMapProgram, slotBindings); | |
| 298 | − initProgram(_lightmapNormalMapProgram, _lightmapNormalMapLocations); | |
| 313 | + _renderPipelineLib.addRenderPipeline( | |
| 314 | + RenderKey(RenderKey::IS_SKINNED), | |
| 315 | + skinModelVertex, modelPixel); | |
| 299 | 316 | |
| 300 | − _lightmapSpecularMapProgram = gpu::ShaderPointer(gpu::Shader::createProgram(modelLightmapVertex, modelLightmapSpecularMapPixel)); | |
| 301 | − makeResult = gpu::Shader::makeProgram(*_lightmapSpecularMapProgram, slotBindings); | |
| 302 | − initProgram(_lightmapSpecularMapProgram, _lightmapSpecularMapLocations); | |
| 317 | + _renderPipelineLib.addRenderPipeline( | |
| 318 | + RenderKey(RenderKey::IS_SKINNED | RenderKey::HAS_TANGENTS), | |
| 319 | + skinModelNormalMapVertex, modelNormalMapPixel); | |
| 303 | 320 | |
| 304 | − _lightmapNormalSpecularMapProgram = gpu::ShaderPointer(gpu::Shader::createProgram(modelLightmapNormalMapVertex, modelLightmapNormalSpecularMapPixel)); | |
| 305 | − makeResult = gpu::Shader::makeProgram(*_lightmapNormalSpecularMapProgram, slotBindings); | |
| 306 | − initProgram(_lightmapNormalSpecularMapProgram, _lightmapNormalSpecularMapLocations); | |
| 321 | + _renderPipelineLib.addRenderPipeline( | |
| 322 | + RenderKey(RenderKey::IS_SKINNED | RenderKey::HAS_SPECULAR), | |
| 323 | + skinModelVertex, modelSpecularMapPixel); | |
| 307 | 324 | |
| 308 | − _skinProgram = gpu::ShaderPointer(gpu::Shader::createProgram(skinModelVertex, modelPixel)); | |
| 309 | − makeResult = gpu::Shader::makeProgram(*_skinProgram, slotBindings); | |
| 310 | − initSkinProgram(_skinProgram, _skinLocations); | |
| 325 | + _renderPipelineLib.addRenderPipeline( | |
| 326 | + RenderKey(RenderKey::IS_SKINNED | RenderKey::HAS_TANGENTS | RenderKey::HAS_SPECULAR), | |
| 327 | + skinModelNormalMapVertex, modelNormalSpecularMapPixel); | |
| 311 | 328 | |
| 312 | − _skinNormalMapProgram = gpu::ShaderPointer(gpu::Shader::createProgram(skinModelNormalMapVertex, modelNormalMapPixel)); | |
| 313 | − makeResult = gpu::Shader::makeProgram(*_skinNormalMapProgram, slotBindings); | |
| 314 | − initSkinProgram(_skinNormalMapProgram, _skinNormalMapLocations); | |
| 329 | + _renderPipelineLib.addRenderPipeline( | |
| 330 | + RenderKey(RenderKey::IS_SKINNED | RenderKey::IS_TRANSLUCENT), | |
| 331 | + skinModelVertex, modelTranslucentPixel); | |
| 315 | 332 | |
| 316 | − _skinSpecularMapProgram = gpu::ShaderPointer(gpu::Shader::createProgram(skinModelVertex, modelSpecularMapPixel)); | |
| 317 | − makeResult = gpu::Shader::makeProgram(*_skinSpecularMapProgram, slotBindings); | |
| 318 | − initSkinProgram(_skinSpecularMapProgram, _skinSpecularMapLocations); | |
| 319 | 333 | |
| 320 | − _skinNormalSpecularMapProgram = gpu::ShaderPointer(gpu::Shader::createProgram(skinModelNormalMapVertex, modelNormalSpecularMapPixel)); | |
| 321 | − makeResult = gpu::Shader::makeProgram(*_skinNormalSpecularMapProgram, slotBindings); | |
| 322 | − initSkinProgram(_skinNormalSpecularMapProgram, _skinNormalSpecularMapLocations); | |
| 323 | − | |
| 324 | − _skinShadowProgram = gpu::ShaderPointer(gpu::Shader::createProgram(skinModelShadowVertex, modelShadowPixel)); | |
| 325 | − makeResult = gpu::Shader::makeProgram(*_skinShadowProgram, slotBindings); | |
| 326 | − initSkinProgram(_skinShadowProgram, _skinShadowLocations); | |
| 327 | − | |
| 328 | − _skinTranslucentProgram = gpu::ShaderPointer(gpu::Shader::createProgram(skinModelVertex, modelTranslucentPixel)); | |
| 329 | − makeResult = gpu::Shader::makeProgram(*_skinTranslucentProgram, slotBindings); | |
| 330 | − initSkinProgram(_skinTranslucentProgram, _skinTranslucentLocations); | |
| 334 | + _renderPipelineLib.addRenderPipeline( | |
| 335 | + RenderKey(RenderKey::IS_DEPTH_ONLY | RenderKey::IS_SHADOW), | |
| 336 | + modelShadowVertex, modelShadowPixel); | |
| 331 | 337 | |
| 332 | − (void) makeResult; // quiet compiler | |
| 338 | + _renderPipelineLib.addRenderPipeline( | |
| 339 | + RenderKey(RenderKey::IS_SKINNED | RenderKey::IS_DEPTH_ONLY | RenderKey::IS_SHADOW), | |
| 340 | + skinModelShadowVertex, modelShadowPixel); | |
| 333 | 341 | } |
| 334 | 342 | } |
| 335 | 343 | |
| @@ -665,6 +673,8 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) { · 329 unmodified lines | ||
| 665 | 673 | return false; |
| 666 | 674 | } |
| 667 | 675 | |
| 676 | + // auto glowEffectIntensity = DependencyManager::get<GlowEffect>()->getIntensity(); | |
| 677 | + | |
| 668 | 678 | // Let's introduce a gpu::Batch to capture all the calls to the graphics api |
| 669 | 679 | _renderBatch.clear(); |
| 670 | 680 | gpu::Batch& batch = _renderBatch; |
| @@ -693,42 +703,48 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) { · 22 unmodified lines | ||
| 693 | 703 | |
| 694 | 704 | batch.setViewTransform(_transforms[0]); |
| 695 | 705 | |
| 696 | − GLBATCH(glDisable)(GL_COLOR_MATERIAL); | |
| 706 | + // GLBATCH(glDisable)(GL_COLOR_MATERIAL); | |
| 697 | 707 | |
| 698 | − if (mode == DIFFUSE_RENDER_MODE || mode == NORMAL_RENDER_MODE) { | |
| 708 | + // taking care of by the state? | |
| 709 | + /* if (mode == RenderArgs::DIFFUSE_RENDER_MODE || mode == RenderArgs::NORMAL_RENDER_MODE) { | |
| 699 | 710 | GLBATCH(glDisable)(GL_CULL_FACE); |
| 700 | 711 | } else { |
| 701 | 712 | GLBATCH(glEnable)(GL_CULL_FACE); |
| 702 | − if (mode == SHADOW_RENDER_MODE) { | |
| 713 | + if (mode == RenderArgs::SHADOW_RENDER_MODE) { | |
| 703 | 714 | GLBATCH(glCullFace)(GL_FRONT); |
| 704 | 715 | } |
| 705 | 716 | } |
| 706 | − | |
| 717 | + */ | |
| 718 | + | |
| 707 | 719 | // render opaque meshes with alpha testing |
| 708 | 720 | |
| 709 | − GLBATCH(glDisable)(GL_BLEND); | |
| 710 | − GLBATCH(glEnable)(GL_ALPHA_TEST); | |
| 711 | − | |
| 712 | − if (mode == SHADOW_RENDER_MODE) { | |
| 721 | +// GLBATCH(glDisable)(GL_BLEND); | |
| 722 | +// GLBATCH(glEnable)(GL_ALPHA_TEST); | |
| 723 | + | |
| 724 | + /* if (mode == RenderArgs::SHADOW_RENDER_MODE) { | |
| 713 | 725 | GLBATCH(glAlphaFunc)(GL_EQUAL, 0.0f); |
| 714 | 726 | } |
| 715 | − | |
| 727 | + */ | |
| 716 | 728 | |
| 717 | 729 | /*DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers( |
| 718 | − mode == DEFAULT_RENDER_MODE || mode == DIFFUSE_RENDER_MODE, | |
| 719 | − mode == DEFAULT_RENDER_MODE || mode == NORMAL_RENDER_MODE, | |
| 720 | − mode == DEFAULT_RENDER_MODE); | |
| 730 | + mode == RenderArgs::DEFAULT_RENDER_MODE || mode == RenderArgs::DIFFUSE_RENDER_MODE, | |
| 731 | + mode == RenderArgs::DEFAULT_RENDER_MODE || mode == RenderArgs::NORMAL_RENDER_MODE, | |
| 732 | + mode == RenderArgs::DEFAULT_RENDER_MODE); | |
| 721 | 733 | */ |
| 722 | 734 | { |
| 723 | 735 | GLenum buffers[3]; |
| 724 | 736 | int bufferCount = 0; |
| 725 | − if (mode == DEFAULT_RENDER_MODE || mode == DIFFUSE_RENDER_MODE || mode == DEBUG_RENDER_MODE) { | |
| 737 | + | |
| 738 | + // if (mode == RenderArgs::DEFAULT_RENDER_MODE || mode == RenderArgs::DIFFUSE_RENDER_MODE) { | |
| 739 | + if (mode != RenderArgs::SHADOW_RENDER_MODE) { | |
| 726 | 740 | buffers[bufferCount++] = GL_COLOR_ATTACHMENT0; |
| 727 | 741 | } |
| 728 | − if (mode == DEFAULT_RENDER_MODE || mode == NORMAL_RENDER_MODE || mode == DEBUG_RENDER_MODE) { | |
| 742 | + // if (mode == RenderArgs::DEFAULT_RENDER_MODE || mode == RenderArgs::NORMAL_RENDER_MODE) { | |
| 743 | + if (mode != RenderArgs::SHADOW_RENDER_MODE) { | |
| 729 | 744 | buffers[bufferCount++] = GL_COLOR_ATTACHMENT1; |
| 730 | 745 | } |
| 731 | − if (mode == DEFAULT_RENDER_MODE || mode == DEBUG_RENDER_MODE) { | |
| 746 | + // if (mode == RenderArgs::DEFAULT_RENDER_MODE) { | |
| 747 | + if (mode != RenderArgs::SHADOW_RENDER_MODE) { | |
| 732 | 748 | buffers[bufferCount++] = GL_COLOR_ATTACHMENT2; |
| 733 | 749 | } |
| 734 | 750 | GLBATCH(glDrawBuffers)(bufferCount, buffers); |
| @@ -774,11 +790,11 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) { · 39 unmodified lines | ||
| 774 | 790 | translucentMeshPartsRendered += renderMeshes(batch, mode, true, MOSTLY_OPAQUE_THRESHOLD, false, true, true, false, args, true); |
| 775 | 791 | translucentMeshPartsRendered += renderMeshes(batch, mode, true, MOSTLY_OPAQUE_THRESHOLD, false, true, true, true, args, true); |
| 776 | 792 | |
| 777 | − GLBATCH(glDisable)(GL_ALPHA_TEST); | |
| 778 | − GLBATCH(glEnable)(GL_BLEND); | |
| 793 | + // GLBATCH(glDisable)(GL_ALPHA_TEST); | |
| 794 | + /* GLBATCH(glEnable)(GL_BLEND); | |
| 779 | 795 | GLBATCH(glDepthMask)(false); |
| 780 | 796 | GLBATCH(glDepthFunc)(GL_LEQUAL); |
| 781 | − | |
| 797 | + */ | |
| 782 | 798 | //DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true); |
| 783 | 799 | { |
| 784 | 800 | GLenum buffers[1]; |
| @@ -787,7 +803,8 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) { · 2 unmodified lines | ||
| 787 | 803 | GLBATCH(glDrawBuffers)(bufferCount, buffers); |
| 788 | 804 | } |
| 789 | 805 | |
| 790 | − if (mode == DEFAULT_RENDER_MODE || mode == DIFFUSE_RENDER_MODE || mode == DEBUG_RENDER_MODE) { | |
| 806 | + // if (mode == RenderArgs::DEFAULT_RENDER_MODE || mode == RenderArgs::DIFFUSE_RENDER_MODE) { | |
| 807 | + if (mode != RenderArgs::SHADOW_RENDER_MODE) { | |
| 791 | 808 | const float MOSTLY_TRANSPARENT_THRESHOLD = 0.0f; |
| 792 | 809 | translucentMeshPartsRendered += renderMeshes(batch, mode, true, MOSTLY_TRANSPARENT_THRESHOLD, false, false, false, false, args, true); |
| 793 | 810 | translucentMeshPartsRendered += renderMeshes(batch, mode, true, MOSTLY_TRANSPARENT_THRESHOLD, false, false, false, true, args, true); |
| @@ -803,7 +820,7 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) { · 9 unmodified lines | ||
| 803 | 820 | GLBATCH(glDepthFunc)(GL_LESS); |
| 804 | 821 | GLBATCH(glDisable)(GL_CULL_FACE); |
| 805 | 822 | |
| 806 | − if (mode == SHADOW_RENDER_MODE) { | |
| 823 | + if (mode == RenderArgs::SHADOW_RENDER_MODE) { | |
| 807 | 824 | GLBATCH(glCullFace)(GL_BACK); |
| 808 | 825 | } |
| 809 | 826 | |
| @@ -830,6 +847,9 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) { · 20 unmodified lines | ||
| 830 | 847 | GLBATCH(glBindBuffer)(GL_ELEMENT_ARRAY_BUFFER, 0); |
| 831 | 848 | GLBATCH(glBindTexture)(GL_TEXTURE_2D, 0); |
| 832 | 849 | |
| 850 | + // Back to no program | |
| 851 | + GLBATCH(glUseProgram)(0); | |
| 852 | + | |
| 833 | 853 | // Render! |
| 834 | 854 | { |
| 835 | 855 | PROFILE_RANGE("render Batch"); |
| @@ -1738,6 +1758,9 @@ void Model::setupBatchTransform(gpu::Batch& batch, RenderArgs* args) { · 902 unmodified lines | ||
| 1738 | 1758 | void Model::endScene(RenderMode mode, RenderArgs* args) { |
| 1739 | 1759 | PROFILE_RANGE(__FUNCTION__); |
| 1740 | 1760 | |
| 1761 | + // auto glowEffectIntensity = DependencyManager::get<GlowEffect>()->getIntensity(); | |
| 1762 | + | |
| 1763 | + | |
| 1741 | 1764 | #if defined(ANDROID) |
| 1742 | 1765 | #else |
| 1743 | 1766 | glPushMatrix(); |
| @@ -1769,42 +1792,45 @@ void Model::endScene(RenderMode mode, RenderArgs* args) { · 25 unmodified lines | ||
| 1769 | 1792 | _sceneRenderBatch.clear(); |
| 1770 | 1793 | gpu::Batch& batch = _sceneRenderBatch; |
| 1771 | 1794 | |
| 1772 | − GLBATCH(glDisable)(GL_COLOR_MATERIAL); | |
| 1795 | + // GLBATCH(glDisable)(GL_COLOR_MATERIAL); | |
| 1773 | 1796 | |
| 1774 | − if (mode == DIFFUSE_RENDER_MODE || mode == NORMAL_RENDER_MODE) { | |
| 1797 | + /* if (mode == RenderArgs::DIFFUSE_RENDER_MODE || mode == RenderArgs::NORMAL_RENDER_MODE) { | |
| 1775 | 1798 | GLBATCH(glDisable)(GL_CULL_FACE); |
| 1776 | 1799 | } else { |
| 1777 | 1800 | GLBATCH(glEnable)(GL_CULL_FACE); |
| 1778 | − if (mode == SHADOW_RENDER_MODE) { | |
| 1801 | + if (mode == RenderArgs::SHADOW_RENDER_MODE) { | |
| 1779 | 1802 | GLBATCH(glCullFace)(GL_FRONT); |
| 1780 | 1803 | } |
| 1781 | − } | |
| 1804 | + }*/ | |
| 1782 | 1805 | |
| 1783 | 1806 | // render opaque meshes with alpha testing |
| 1784 | 1807 | |
| 1785 | − GLBATCH(glDisable)(GL_BLEND); | |
| 1786 | − GLBATCH(glEnable)(GL_ALPHA_TEST); | |
| 1808 | + // GLBATCH(glDisable)(GL_BLEND); | |
| 1809 | + // GLBATCH(glEnable)(GL_ALPHA_TEST); | |
| 1787 | 1810 | |
| 1788 | − if (mode == SHADOW_RENDER_MODE) { | |
| 1811 | + /* if (mode == RenderArgs::SHADOW_RENDER_MODE) { | |
| 1789 | 1812 | GLBATCH(glAlphaFunc)(GL_EQUAL, 0.0f); |
| 1790 | 1813 | } |
| 1791 | − | |
| 1814 | +*/ | |
| 1792 | 1815 | |
| 1793 | 1816 | /*DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers( |
| 1794 | − mode == DEFAULT_RENDER_MODE || mode == DIFFUSE_RENDER_MODE, | |
| 1795 | − mode == DEFAULT_RENDER_MODE || mode == NORMAL_RENDER_MODE, | |
| 1796 | − mode == DEFAULT_RENDER_MODE); | |
| 1817 | + mode == RenderArgs::DEFAULT_RENDER_MODE || mode == RenderArgs::DIFFUSE_RENDER_MODE, | |
| 1818 | + mode == RenderArgs::DEFAULT_RENDER_MODE || mode == RenderArgs::NORMAL_RENDER_MODE, | |
| 1819 | + mode == RenderArgs::DEFAULT_RENDER_MODE); | |
| 1797 | 1820 | */ |
| 1798 | 1821 | { |
| 1799 | 1822 | GLenum buffers[3]; |
| 1800 | 1823 | int bufferCount = 0; |
| 1801 | − if (mode == DEFAULT_RENDER_MODE || mode == DIFFUSE_RENDER_MODE || mode == DEBUG_RENDER_MODE) { | |
| 1824 | + // if (mode == RenderArgs::DEFAULT_RENDER_MODE || mode == RenderArgs::DIFFUSE_RENDER_MODE) { | |
| 1825 | + if (mode != RenderArgs::SHADOW_RENDER_MODE) { | |
| 1802 | 1826 | buffers[bufferCount++] = GL_COLOR_ATTACHMENT0; |
| 1803 | 1827 | } |
| 1804 | − if (mode == DEFAULT_RENDER_MODE || mode == NORMAL_RENDER_MODE || mode == DEBUG_RENDER_MODE) { | |
| 1828 | + //if (mode == RenderArgs::DEFAULT_RENDER_MODE || mode == RenderArgs::NORMAL_RENDER_MODE) { | |
| 1829 | + if (mode != RenderArgs::SHADOW_RENDER_MODE) { | |
| 1805 | 1830 | buffers[bufferCount++] = GL_COLOR_ATTACHMENT1; |
| 1806 | 1831 | } |
| 1807 | − if (mode == DEFAULT_RENDER_MODE || mode == DEBUG_RENDER_MODE) { | |
| 1832 | + // if (mode == RenderArgs::DEFAULT_RENDER_MODE) { | |
| 1833 | + if (mode != RenderArgs::SHADOW_RENDER_MODE) { | |
| 1808 | 1834 | buffers[bufferCount++] = GL_COLOR_ATTACHMENT2; |
| 1809 | 1835 | } |
| 1810 | 1836 | GLBATCH(glDrawBuffers)(bufferCount, buffers); |
| @@ -1850,11 +1876,11 @@ void Model::endScene(RenderMode mode, RenderArgs* args) { · 39 unmodified lines | ||
| 1850 | 1876 | translucentParts += renderMeshesForModelsInScene(batch, mode, true, MOSTLY_OPAQUE_THRESHOLD, false, true, true, false, args); |
| 1851 | 1877 | translucentParts += renderMeshesForModelsInScene(batch, mode, true, MOSTLY_OPAQUE_THRESHOLD, false, true, true, true, args); |
| 1852 | 1878 | |
| 1853 | − GLBATCH(glDisable)(GL_ALPHA_TEST); | |
| 1854 | − GLBATCH(glEnable)(GL_BLEND); | |
| 1879 | + // GLBATCH(glDisable)(GL_ALPHA_TEST); | |
| 1880 | + /* GLBATCH(glEnable)(GL_BLEND); | |
| 1855 | 1881 | GLBATCH(glDepthMask)(false); |
| 1856 | 1882 | GLBATCH(glDepthFunc)(GL_LEQUAL); |
| 1857 | − | |
| 1883 | + */ | |
| 1858 | 1884 | //DependencyManager::get<TextureCache>()->setPrimaryDrawBuffers(true); |
| 1859 | 1885 | { |
| 1860 | 1886 | GLenum buffers[1]; |
| @@ -1863,7 +1889,8 @@ void Model::endScene(RenderMode mode, RenderArgs* args) { · 2 unmodified lines | ||
| 1863 | 1889 | GLBATCH(glDrawBuffers)(bufferCount, buffers); |
| 1864 | 1890 | } |
| 1865 | 1891 | |
| 1866 | − if (mode == DEFAULT_RENDER_MODE || mode == DIFFUSE_RENDER_MODE || mode == DEBUG_RENDER_MODE) { | |
| 1892 | + // if (mode == RenderArgs::DEFAULT_RENDER_MODE || mode == RenderArgs::DIFFUSE_RENDER_MODE) { | |
| 1893 | + if (mode != RenderArgs::SHADOW_RENDER_MODE) { | |
| 1867 | 1894 | const float MOSTLY_TRANSPARENT_THRESHOLD = 0.0f; |
| 1868 | 1895 | translucentParts += renderMeshesForModelsInScene(batch, mode, true, MOSTLY_TRANSPARENT_THRESHOLD, false, false, false, false, args); |
| 1869 | 1896 | translucentParts += renderMeshesForModelsInScene(batch, mode, true, MOSTLY_TRANSPARENT_THRESHOLD, false, false, false, true, args); |
| @@ -1879,7 +1906,7 @@ void Model::endScene(RenderMode mode, RenderArgs* args) { · 9 unmodified lines | ||
| 1879 | 1906 | GLBATCH(glDepthFunc)(GL_LESS); |
| 1880 | 1907 | GLBATCH(glDisable)(GL_CULL_FACE); |
| 1881 | 1908 | |
| 1882 | − if (mode == SHADOW_RENDER_MODE) { | |
| 1909 | + if (mode == RenderArgs::SHADOW_RENDER_MODE) { | |
| 1883 | 1910 | GLBATCH(glCullFace)(GL_BACK); |
| 1884 | 1911 | } |
| 1885 | 1912 | |
| @@ -1907,6 +1934,10 @@ void Model::endScene(RenderMode mode, RenderArgs* args) { · 21 unmodified lines | ||
| 1907 | 1934 | GLBATCH(glBindBuffer)(GL_ARRAY_BUFFER, 0); |
| 1908 | 1935 | GLBATCH(glBindBuffer)(GL_ELEMENT_ARRAY_BUFFER, 0); |
| 1909 | 1936 | GLBATCH(glBindTexture)(GL_TEXTURE_2D, 0); |
| 1937 | + | |
| 1938 | + // Back to no program | |
| 1939 | + GLBATCH(glUseProgram)(0); | |
| 1940 | + | |
| 1910 | 1941 | if (args) { |
| 1911 | 1942 | args->_translucentMeshPartsRendered = translucentParts; |
| 1912 | 1943 | args->_opaqueMeshPartsRendered = opaqueMeshPartsRendered; |
| @@ -2298,83 +2329,34 @@ QVector<int>* Model::pickMeshList(bool translucent, float alphaThreshold, bool h · 385 unmodified lines | ||
| 2298 | 2329 | |
| 2299 | 2330 | void Model::pickPrograms(gpu::Batch& batch, RenderMode mode, bool translucent, float alphaThreshold, |
| 2300 | 2331 | bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, RenderArgs* args, |
| 2301 | − Locations*& locations, SkinLocations*& skinLocations) { | |
| 2302 | − gpu::ShaderPointer program = _program; | |
| 2303 | − locations = &_locations; | |
| 2304 | − gpu::ShaderPointer skinProgram = _skinProgram; | |
| 2305 | − skinLocations = &_skinLocations; | |
| 2306 | − if (mode == SHADOW_RENDER_MODE) { | |
| 2307 | − program = _shadowProgram; | |
| 2308 | − locations = &_shadowLocations; | |
| 2309 | − skinProgram = _skinShadowProgram; | |
| 2310 | − skinLocations = &_skinShadowLocations; | |
| 2311 | − } else if (translucent && alphaThreshold == 0.0f) { | |
| 2312 | − program = _translucentProgram; | |
| 2313 | − locations = &_translucentLocations; | |
| 2314 | − skinProgram = _skinTranslucentProgram; | |
| 2315 | − skinLocations = &_skinTranslucentLocations; | |
| 2316 | − | |
| 2317 | − } else if (hasLightmap) { | |
| 2318 | − if (hasTangents) { | |
| 2319 | − if (hasSpecular) { | |
| 2320 | − program = _lightmapNormalSpecularMapProgram; | |
| 2321 | − locations = &_lightmapNormalSpecularMapLocations; | |
| 2322 | − skinProgram.reset(); | |
| 2323 | − skinLocations = NULL; | |
| 2324 | − } else { | |
| 2325 | − program = _lightmapNormalMapProgram; | |
| 2326 | − locations = &_lightmapNormalMapLocations; | |
| 2327 | − skinProgram.reset(); | |
| 2328 | − skinLocations = NULL; | |
| 2329 | − } | |
| 2330 | − } else if (hasSpecular) { | |
| 2331 | − program = _lightmapSpecularMapProgram; | |
| 2332 | − locations = &_lightmapSpecularMapLocations; | |
| 2333 | − skinProgram.reset(); | |
| 2334 | − skinLocations = NULL; | |
| 2335 | − } else { | |
| 2336 | − program = _lightmapProgram; | |
| 2337 | − locations = &_lightmapLocations; | |
| 2338 | − skinProgram.reset(); | |
| 2339 | − skinLocations = NULL; | |
| 2340 | − } | |
| 2341 | − } else { | |
| 2342 | − if (hasTangents) { | |
| 2343 | − if (hasSpecular) { | |
| 2344 | − program = _normalSpecularMapProgram; | |
| 2345 | − locations = &_normalSpecularMapLocations; | |
| 2346 | − skinProgram = _skinNormalSpecularMapProgram; | |
| 2347 | − skinLocations = &_skinNormalSpecularMapLocations; | |
| 2348 | − } else { | |
| 2349 | − program = _normalMapProgram; | |
| 2350 | − locations = &_normalMapLocations; | |
| 2351 | − skinProgram = _skinNormalMapProgram; | |
| 2352 | − skinLocations = &_skinNormalMapLocations; | |
| 2353 | − } | |
| 2354 | − } else if (hasSpecular) { | |
| 2355 | − program = _specularMapProgram; | |
| 2356 | − locations = &_specularMapLocations; | |
| 2357 | − skinProgram = _skinSpecularMapProgram; | |
| 2358 | − skinLocations = &_skinSpecularMapLocations; | |
| 2359 | − } | |
| 2360 | − } | |
| 2361 | − | |
| 2362 | − gpu::ShaderPointer activeProgram = program; | |
| 2363 | − Locations* activeLocations = locations; | |
| 2332 | + Locations*& locations) { | |
| 2364 | 2333 | |
| 2365 | − if (isSkinned) { | |
| 2366 | − activeProgram = skinProgram; | |
| 2367 | − activeLocations = skinLocations; | |
| 2368 | − locations = skinLocations; | |
| 2334 | + RenderKey key(mode, translucent, alphaThreshold, hasLightmap, hasTangents, hasSpecular, isSkinned); | |
| 2335 | + auto pipeline = _renderPipelineLib.find(key.getRaw()); | |
| 2336 | + if (pipeline == _renderPipelineLib.end()) { | |
| 2337 | + qDebug() << "No good, couldn;t find a pipeline from the key ?" << key.getRaw(); | |
| 2338 | + return; | |
| 2369 | 2339 | } |
| 2370 | 2340 | |
| 2371 | − GLuint glprogram = gpu::GLBackend::getShaderID(activeProgram); | |
| 2372 | − GLBATCH(glUseProgram)(glprogram); | |
| 2341 | + gpu::ShaderPointer program = (*pipeline).second._pipeline->getProgram(); | |
| 2342 | + locations = (*pipeline).second._locations.get(); | |
| 2343 | + | |
| 2344 | + //GLuint glprogram = gpu::GLBackend::getShaderID(program); | |
| 2345 | + //GLBATCH(glUseProgram)(glprogram); | |
| 2373 | 2346 | |
| 2347 | + // dare! | |
| 2348 | + batch.setPipeline((*pipeline).second._pipeline); | |
| 2374 | 2349 | |
| 2375 | − if ((activeLocations->alphaThreshold > -1) && (mode != SHADOW_RENDER_MODE)) { | |
| 2376 | − GLBATCH(glUniform1f)(activeLocations->alphaThreshold, alphaThreshold); | |
| 2350 | + if ((locations->alphaThreshold > -1) && (mode != RenderArgs::SHADOW_RENDER_MODE)) { | |
| 2351 | + GLBATCH(glUniform1f)(locations->alphaThreshold, alphaThreshold); | |
| 2377 | 2352 | } |
| 2353 | + | |
| 2354 | + if ((locations->glowIntensity > -1) && (mode != RenderArgs::SHADOW_RENDER_MODE)) { | |
| 2355 | + GLBATCH(glUniform1f)(locations->glowIntensity, DependencyManager::get<GlowEffect>()->getIntensity()); | |
| 2356 | + } | |
| 2357 | + // if (!(translucent && alphaThreshold == 0.0f) && (mode != RenderArgs::SHADOW_RENDER_MODE)) { | |
| 2358 | + // GLBATCH(glAlphaFunc)(GL_EQUAL, DependencyManager::get<GlowEffect>()->getIntensity()); | |
| 2359 | + // } | |
| 2378 | 2360 | } |
| 2379 | 2361 | |
| 2380 | 2362 | int Model::renderMeshesForModelsInScene(gpu::Batch& batch, RenderMode mode, bool translucent, float alphaThreshold, |
| @@ -2385,7 +2367,6 @@ int Model::renderMeshesForModelsInScene(gpu::Batch& batch, RenderMode mode, bool · 4 unmodified lines | ||
| 2385 | 2367 | |
| 2386 | 2368 | bool pickProgramsNeeded = true; |
| 2387 | 2369 | Locations* locations; |
| 2388 | − SkinLocations* skinLocations; | |
| 2389 | 2370 | |
| 2390 | 2371 | foreach(Model* model, _modelsInScene) { |
| 2391 | 2372 | QVector<int>* whichList = model->pickMeshList(translucent, alphaThreshold, hasLightmap, hasTangents, hasSpecular, isSkinned); |
| @@ -2393,24 +2374,25 @@ int Model::renderMeshesForModelsInScene(gpu::Batch& batch, RenderMode mode, bool · 1 unmodified line | ||
| 2393 | 2374 | QVector<int>& list = *whichList; |
| 2394 | 2375 | if (list.size() > 0) { |
| 2395 | 2376 | if (pickProgramsNeeded) { |
| 2396 | − pickPrograms(batch, mode, translucent, alphaThreshold, hasLightmap, hasTangents, hasSpecular, isSkinned, args, locations, skinLocations); | |
| 2377 | + pickPrograms(batch, mode, translucent, alphaThreshold, hasLightmap, hasTangents, hasSpecular, isSkinned, args, locations); | |
| 2397 | 2378 | pickProgramsNeeded = false; |
| 2398 | 2379 | } |
| 2380 | + | |
| 2399 | 2381 | model->setupBatchTransform(batch, args); |
| 2400 | − meshPartsRendered += model->renderMeshesFromList(list, batch, mode, translucent, alphaThreshold, args, locations, skinLocations); | |
| 2382 | + meshPartsRendered += model->renderMeshesFromList(list, batch, mode, translucent, alphaThreshold, args, locations); | |
| 2401 | 2383 | } |
| 2402 | 2384 | } |
| 2403 | 2385 | } |
| 2404 | 2386 | // if we selected a program, then unselect it |
| 2405 | 2387 | if (!pickProgramsNeeded) { |
| 2406 | − GLBATCH(glUseProgram)(0); | |
| 2388 | + // GLBATCH(glUseProgram)(0); | |
| 2407 | 2389 | } |
| 2408 | 2390 | return meshPartsRendered; |
| 2409 | 2391 | } |
| 2410 | 2392 | |
| 2411 | 2393 | int Model::renderMeshes(gpu::Batch& batch, RenderMode mode, bool translucent, float alphaThreshold, |
| 2412 | 2394 | bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, RenderArgs* args, |
| 2413 | − bool forceRenderMeshes) { | |
| 2395 | + bool forceRenderSomeMeshes) { | |
| 2414 | 2396 | |
| 2415 | 2397 | PROFILE_RANGE(__FUNCTION__); |
| 2416 | 2398 | int meshPartsRendered = 0; |
| @@ -2429,24 +2411,23 @@ int Model::renderMeshes(gpu::Batch& batch, RenderMode mode, bool translucent, fl · 12 unmodified lines | ||
| 2429 | 2411 | } |
| 2430 | 2412 | |
| 2431 | 2413 | Locations* locations; |
| 2432 | − SkinLocations* skinLocations; | |
| 2433 | 2414 | pickPrograms(batch, mode, translucent, alphaThreshold, hasLightmap, hasTangents, hasSpecular, isSkinned, |
| 2434 | − args, locations, skinLocations); | |
| 2415 | + args, locations); | |
| 2435 | 2416 | meshPartsRendered = renderMeshesFromList(list, batch, mode, translucent, alphaThreshold, |
| 2436 | − args, locations, skinLocations, forceRenderMeshes); | |
| 2437 | − GLBATCH(glUseProgram)(0); | |
| 2417 | + args, locations, forceRenderSomeMeshes); | |
| 2418 | + // GLBATCH(glUseProgram)(0); | |
| 2419 | + | |
| 2438 | 2420 | |
| 2439 | 2421 | return meshPartsRendered; |
| 2440 | 2422 | } |
| 2441 | 2423 | |
| 2442 | 2424 | |
| 2443 | −int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMode mode, bool translucent, | |
| 2444 | − float alphaThreshold, RenderArgs* args, Locations* locations, SkinLocations* skinLocations, | |
| 2445 | − bool forceRenderMeshes) { | |
| 2425 | +int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMode mode, bool translucent, float alphaThreshold, RenderArgs* args, | |
| 2426 | + Locations* locations, bool forceRenderMeshes) { | |
| 2446 | 2427 | PROFILE_RANGE(__FUNCTION__); |
| 2447 | 2428 | |
| 2448 | 2429 | auto textureCache = DependencyManager::get<TextureCache>(); |
| 2449 | − auto glowEffect = DependencyManager::get<GlowEffect>(); | |
| 2430 | + // auto glowEffect = DependencyManager::get<GlowEffect>(); | |
| 2450 | 2431 | QString lastMaterialID; |
| 2451 | 2432 | int meshPartsRendered = 0; |
| 2452 | 2433 | updateVisibleJointStates(); |
| @@ -2506,7 +2487,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod · 53 unmodified lines | ||
| 2506 | 2487 | |
| 2507 | 2488 | const MeshState& state = _meshStates.at(i); |
| 2508 | 2489 | if (state.clusterMatrices.size() > 1) { |
| 2509 | − GLBATCH(glUniformMatrix4fv)(skinLocations->clusterMatrices, state.clusterMatrices.size(), false, | |
| 2490 | + GLBATCH(glUniformMatrix4fv)(locations->clusterMatrices, state.clusterMatrices.size(), false, | |
| 2510 | 2491 | (const float*)state.clusterMatrices.constData()); |
| 2511 | 2492 | batch.setModelTransform(Transform()); |
| 2512 | 2493 | } else { |
| @@ -2524,7 +2505,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod · 11 unmodified lines | ||
| 2524 | 2505 | } |
| 2525 | 2506 | |
| 2526 | 2507 | if (mesh.colors.isEmpty()) { |
| 2527 | − GLBATCH(glColor4f)(1.0f, 1.0f, 1.0f, 1.0f); | |
| 2508 | + GLBATCH(glColor4f)(0.0f, 1.0f, 0.0f, 1.0f); | |
| 2528 | 2509 | } |
| 2529 | 2510 | |
| 2530 | 2511 | qint64 offset = 0; |
| @@ -2538,7 +2519,7 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod · 7 unmodified lines | ||
| 2538 | 2519 | } |
| 2539 | 2520 | |
| 2540 | 2521 | // apply material properties |
| 2541 | − if (mode == SHADOW_RENDER_MODE) { | |
| 2522 | + if (mode == RenderArgs::SHADOW_RENDER_MODE) { | |
| 2542 | 2523 | /// GLBATCH(glBindTexture)(GL_TEXTURE_2D, 0); |
| 2543 | 2524 | |
| 2544 | 2525 | } else { |
| @@ -2550,13 +2531,13 @@ int Model::renderMeshesFromList(QVector<int>& list, gpu::Batch& batch, RenderMod · 5 unmodified lines | ||
| 2550 | 2531 | qCDebug(renderutils) << "NEW part.materialID:" << part.materialID; |
| 2551 | 2532 | } |
| 2552 | 2533 | |
| 2553 | − if (locations->glowIntensity >= 0) { | |
| 2534 | +/* if (locations->glowIntensity >= 0) { | |
| 2554 | 2535 | GLBATCH(glUniform1f)(locations->glowIntensity, glowEffect->getIntensity()); |
| 2555 | 2536 | } |
| 2556 | 2537 | if (!(translucent && alphaThreshold == 0.0f)) { |
| 2557 | 2538 | GLBATCH(glAlphaFunc)(GL_EQUAL, glowEffect->getIntensity()); |
| 2558 | 2539 | } |
| 2559 | − | |
| 2540 | +*/ | |
| 2560 | 2541 | if (locations->materialBufferUnit >= 0) { |
| 2561 | 2542 | batch.setUniformBuffer(locations->materialBufferUnit, material->getSchemaBuffer()); |
| 2562 | 2543 | } |