Ticket #1920: NoSortingForTrees.patch
File NoSortingForTrees.patch, 5.1 KB (added by , 11 years ago) |
---|
-
binaries/data/mods/public/art/materials/basic_trans_wind.xml
1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <material> 3 <shader effect="model_transparent "/>3 <shader effect="model_transparent_nosort"/> 4 4 <alpha_blending/> 5 5 <define name="USE_TRANSPARENT" value="1"/> 6 6 <renderquery name="sim_time"/> -
source/graphics/Material.cpp
52 52 m_Samplers.push_back(texture); 53 53 if (texture.Name == CStrIntern("baseTex")) 54 54 m_DiffuseTexture = texture.Sampler; 55 else if (texture.Name == CStrIntern("normTex")) 56 m_NormalTexture = texture.Sampler; 57 else if (texture.Name == CStrIntern("specTex")) 58 m_SpecularTexture = texture.Sampler; 59 else if (texture.Name == CStrIntern("aoTex")) 60 m_AOTexture = texture.Sampler; 55 61 } 56 62 57 63 void CMaterial::AddRenderQuery(const char* key) -
source/graphics/Model.cpp
375 375 { 376 376 const Prop& prop=m_Props[j]; 377 377 378 CMatrix3D proptransform = prop.m_Point->m_Transform; ;378 CMatrix3D proptransform = prop.m_Point->m_Transform; 379 379 if (prop.m_Point->m_BoneIndex != 0xff) 380 380 { 381 381 CMatrix3D boneMatrix = m_BoneMatrices[prop.m_Point->m_BoneIndex]; -
source/graphics/Material.h
48 48 bool UsesAlphaBlending() { return m_AlphaBlending; } 49 49 50 50 const CTexturePtr& GetDiffuseTexture() const { return m_DiffuseTexture; } 51 const CTexturePtr& GetSpecularTexture() const { return m_SpecularTexture; } 52 const CTexturePtr& GetNormalTexture() const { return m_NormalTexture; } 53 const CTexturePtr& GetAOTexture() const { return m_AOTexture; } 51 54 52 55 void SetShaderEffect(const CStr& effect); 53 56 CStrIntern GetShaderEffect() const { return m_ShaderEffect; } … … 72 75 // This pointer is kept to make it easier for the fixed pipeline to 73 76 // access the only texture it's interested in. 74 77 CTexturePtr m_DiffuseTexture; 78 // these other pointers are for easier comparison when batching 79 CTexturePtr m_SpecularTexture; 80 CTexturePtr m_NormalTexture; 81 CTexturePtr m_AOTexture; 75 82 76 83 SamplersVector m_Samplers; 77 84 -
source/renderer/ModelRenderer.cpp
294 294 if (b->GetMaterial().GetDiffuseTexture() < a->GetMaterial().GetDiffuseTexture()) 295 295 return false; 296 296 297 if (a->GetMaterial().GetSpecularTexture() < b->GetMaterial().GetSpecularTexture()) 298 return true; 299 if (b->GetMaterial().GetSpecularTexture() < a->GetMaterial().GetSpecularTexture()) 300 return false; 301 302 if (a->GetMaterial().GetNormalTexture() < b->GetMaterial().GetNormalTexture()) 303 return true; 304 if (b->GetMaterial().GetNormalTexture() < a->GetMaterial().GetNormalTexture()) 305 return false; 306 307 if (a->GetMaterial().GetAOTexture() < b->GetMaterial().GetAOTexture()) 308 return true; 309 if (b->GetMaterial().GetAOTexture() < a->GetMaterial().GetAOTexture()) 310 return false; 311 297 312 return a->GetMaterial().GetStaticUniforms() < b->GetMaterial().GetStaticUniforms(); 298 313 } 299 314 }; … … 401 416 * For each material bucket we then look up the appropriate shader technique. 402 417 * If the technique requires sort-by-distance, the model is added to the 403 418 * 'sortByDistItems' list with its computed distance. 404 * Otherwise, the bucket's list of models is sorted by modeldef+texture +uniforms,419 * Otherwise, the bucket's list of models is sorted by modeldef+textures+uniforms, 405 420 * then the technique and model list is added to 'techBuckets'. 406 421 * 407 422 * 'techBuckets' is then sorted by technique, to improve batching when multiple … … 504 519 } 505 520 else 506 521 { 507 // Sort model list by modeldef+texture, forbatching508 // TODO: This only sorts by base texture. While this is an OK approximation509 // for most cases (as related samplers are usually used together), it would be better510 // to take all the samplers into account when sorting here.522 // Sort model list for more efficient batching 523 // this sorts by model def and the 4 basic textures 524 // (diffuse, normal, specular and AO) 525 // TODO: this should probably be made more generic. 511 526 std::sort(it->second.begin(), it->second.end(), SMRBatchModel()); 512 527 513 528 // Add a tech bucket pointing at this model list … … 625 640 { 626 641 CModel** models = techBuckets[idx].models; 627 642 size_t numModels = techBuckets[idx].numModels; 643 628 644 for (size_t i = 0; i < numModels; ++i) 629 645 { 630 646 CModel* model = models[i];