Ticket #1920: NoSortTrees.patch
File NoSortTrees.patch, 9.6 KB (added by , 10 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"/> -
binaries/data/mods/public/shaders/effects/model_transparent_nosort.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <effect> 3 4 <technique> 5 <require context="MODE_SHADOWCAST || MODE_SILHOUETTEOCCLUDER"/> 6 <require shaders="arb"/> 7 <pass shader="arb/model_solid_tex"> 8 <define name="REQUIRE_ALPHA_GEQUAL" value="0.4"/> 9 </pass> 10 </technique> 11 12 <technique> 13 <require context="MODE_SHADOWCAST || MODE_SILHOUETTEOCCLUDER"/> 14 <require shaders="glsl"/> 15 <pass shader="glsl/model_solid_tex"> 16 <define name="REQUIRE_ALPHA_GEQUAL" value="0.4"/> 17 </pass> 18 </technique> 19 20 <technique> 21 <require context="MODE_SHADOWCAST || MODE_SILHOUETTEOCCLUDER"/> 22 <require shaders="fixed"/> 23 <define name="USE_PLAYERCOLOR" value="0"/> 24 <define name="USE_OBJECTCOLOR" value="0"/> 25 <pass shader="fixed:model_solid_tex"> 26 <alpha func="gequal" ref="0.4"/> 27 </pass> 28 </technique> 29 30 31 32 <!-- 33 CRenderer::RenderSilhouettes skips alpha-blended models for 34 MODE_SILHOUETTEDISPLAY, so do a dummy non-blended behaviour here to 35 make it obviously buggy if CRenderer is changed to render these models. 36 --> 37 <technique> 38 <require context="MODE_SILHOUETTEDISPLAY || MODE_WIREFRAME"/> 39 <require shaders="arb"/> 40 <pass shader="arb/model_solid_player"/> 41 </technique> 42 43 <technique> 44 <require context="MODE_SILHOUETTEDISPLAY || MODE_WIREFRAME"/> 45 <require shaders="glsl"/> 46 <pass shader="glsl/model_solid_player"/> 47 </technique> 48 49 <technique> 50 <require context="MODE_SILHOUETTEDISPLAY || MODE_WIREFRAME"/> 51 <require shaders="fixed"/> 52 <define name="USE_PLAYERCOLOR" value="1"/> 53 <define name="USE_OBJECTCOLOR" value="0"/> 54 <pass shader="fixed:model_solid"/> 55 </technique> 56 57 58 59 <technique> 60 <require context="USE_ALPHATEST"/> 61 <require shaders="arb"/> 62 <pass shader="arb/model_common"> 63 <define name="USE_TRANSPARENT" value="1"/> 64 <define name="REQUIRE_ALPHA_GEQUAL" value="0.4"/> 65 </pass> 66 </technique> 67 68 <technique> 69 <require context="USE_ALPHATEST"/> 70 <require shaders="glsl"/> 71 <pass shader="glsl/model_common"> 72 <define name="USE_TRANSPARENT" value="1"/> 73 <define name="REQUIRE_ALPHA_GEQUAL" value="0.4"/> 74 </pass> 75 </technique> 76 77 <technique> 78 <require context="USE_ALPHATEST"/> 79 <require shaders="fixed"/> 80 <pass shader="fixed:model"> 81 <alpha func="gequal" ref="0.4"/> 82 </pass> 83 </technique> 84 85 86 87 <technique> 88 <require context="ALPHABLEND_PASS_OPAQUE"/> 89 <require shaders="arb"/> 90 <pass shader="arb/model_common"> 91 <define name="USE_TRANSPARENT" value="1"/> 92 <define name="REQUIRE_ALPHA_GEQUAL" value="0.6375"/> 93 </pass> 94 </technique> 95 96 <technique> 97 <require context="ALPHABLEND_PASS_OPAQUE"/> 98 <require shaders="glsl"/> 99 <pass shader="glsl/model_common"> 100 <define name="USE_TRANSPARENT" value="1"/> 101 <define name="REQUIRE_ALPHA_GEQUAL" value="0.6375"/> 102 </pass> 103 </technique> 104 105 <technique> 106 <require context="ALPHABLEND_PASS_OPAQUE"/> 107 <require shaders="fixed"/> 108 <pass shader="fixed:model"> 109 <alpha func="gequal" ref="0.6375"/> 110 </pass> 111 </technique> 112 113 114 115 <technique> 116 <require context="ALPHABLEND_PASS_BLEND"/> 117 <require shaders="arb"/> 118 <pass shader="arb/model_common"> 119 <define name="USE_TRANSPARENT" value="1"/> 120 <define name="REQUIRE_ALPHA_GEQUAL" value="0.05"/> 121 <blend src="src_alpha" dst="one_minus_src_alpha"/> 122 <depth func="less" mask="false"/> 123 </pass> 124 </technique> 125 126 <technique> 127 <require context="ALPHABLEND_PASS_BLEND"/> 128 <require shaders="glsl"/> 129 <pass shader="glsl/model_common"> 130 <define name="USE_TRANSPARENT" value="1"/> 131 <define name="REQUIRE_ALPHA_GEQUAL" value="0.05"/> 132 <blend src="src_alpha" dst="one_minus_src_alpha"/> 133 <depth func="less" mask="false"/> 134 </pass> 135 </technique> 136 137 <technique> 138 <require context="ALPHABLEND_PASS_BLEND"/> 139 <require shaders="fixed"/> 140 <pass shader="fixed:model"> 141 <define name="USE_TRANSPARENT" value="1"/> 142 <alpha func="gequal" ref="0.05"/> 143 <blend src="src_alpha" dst="one_minus_src_alpha"/> 144 <depth func="less" mask="false"/> 145 </pass> 146 </technique> 147 148 </effect> -
source/graphics/Material.cpp
53 53 m_Samplers.push_back(texture); 54 54 if (texture.Name == str_baseTex) 55 55 m_DiffuseTexture = texture.Sampler; 56 else if (texture.Name == CStrIntern("normTex")) 57 m_NormalTexture = texture.Sampler; 58 else if (texture.Name == CStrIntern("specTex")) 59 m_SpecularTexture = texture.Sampler; 60 else if (texture.Name == CStrIntern("aoTex")) 61 m_AOTexture = texture.Sampler; 56 62 } 57 63 58 64 void CMaterial::AddRenderQuery(const char* key) -
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; } … … 82 85 // This pointer is kept to make it easier for the fixed pipeline to 83 86 // access the only texture it's interested in. 84 87 CTexturePtr m_DiffuseTexture; 88 // these other pointers are for easier comparison when batching 89 CTexturePtr m_SpecularTexture; 90 CTexturePtr m_NormalTexture; 91 CTexturePtr m_AOTexture; 85 92 86 93 SamplersVector m_Samplers; 87 94 -
source/renderer/ModelRenderer.cpp
296 296 if (b->GetMaterial().GetDiffuseTexture() < a->GetMaterial().GetDiffuseTexture()) 297 297 return false; 298 298 299 if (a->GetMaterial().GetSpecularTexture() < b->GetMaterial().GetSpecularTexture()) 300 return true; 301 if (b->GetMaterial().GetSpecularTexture() < a->GetMaterial().GetSpecularTexture()) 302 return false; 303 304 if (a->GetMaterial().GetNormalTexture() < b->GetMaterial().GetNormalTexture()) 305 return true; 306 if (b->GetMaterial().GetNormalTexture() < a->GetMaterial().GetNormalTexture()) 307 return false; 308 309 if (a->GetMaterial().GetAOTexture() < b->GetMaterial().GetAOTexture()) 310 return true; 311 if (b->GetMaterial().GetAOTexture() < a->GetMaterial().GetAOTexture()) 312 return false; 313 299 314 return a->GetMaterial().GetStaticUniforms() < b->GetMaterial().GetStaticUniforms(); 300 315 } 301 316 }; … … 403 418 * For each material bucket we then look up the appropriate shader technique. 404 419 * If the technique requires sort-by-distance, the model is added to the 405 420 * 'sortByDistItems' list with its computed distance. 406 * Otherwise, the bucket's list of models is sorted by modeldef+texture +uniforms,421 * Otherwise, the bucket's list of models is sorted by modeldef+textures+uniforms, 407 422 * then the technique and model list is added to 'techBuckets'. 408 423 * 409 424 * 'techBuckets' is then sorted by technique, to improve batching when multiple … … 523 538 } 524 539 else 525 540 { 526 // Sort model list by modeldef+texture, forbatching527 // TODO: This only sorts by base texture. While this is an OK approximation528 // for most cases (as related samplers are usually used together), it would be better529 // to take all the samplers into account when sorting here.541 // Sort model list for more efficient batching 542 // this sorts by model def and the 4 basic textures 543 // (diffuse, normal, specular and AO) 544 // TODO: this should probably be made more generic. 530 545 std::sort(it->second.begin(), it->second.end(), SMRBatchModel()); 531 546 532 547 // Add a tech bucket pointing at this model list … … 644 659 { 645 660 CModel** models = techBuckets[idx].models; 646 661 size_t numModels = techBuckets[idx].numModels; 662 647 663 for (size_t i = 0; i < numModels; ++i) 648 664 { 649 665 CModel* model = models[i];