AmplifyImpostors源码如何深入理解其策略?

摘要:首先看一下点击Bake按钮后的执行流程: 1.AmplifyImpostorInspector部分 首先点击按钮设置了bakeTexture = true if( GUILayout.Button( TextureIcon, &am
首先看一下点击Bake按钮后的执行流程: 1.AmplifyImpostorInspector部分 首先点击按钮设置了bakeTexture = true if( GUILayout.Button( TextureIcon, "buttonright", GUILayout.Height( 24 ) ) ) { // now recalculates texture and mesh every time because mesh might have changed //if( m_instance.m_alphaTex == null ) //{ m_outdatedTexture = true; m_recalculatePreviewTexture = true; //} bakeTextures = true; } 如果展开了BillboardMesh选项或是bakeTextures为true,则都会执行下面部分: if( ( ( m_billboardMesh || m_recalculatePreviewTexture ) && m_instance.m_alphaTex == null ) || ( bakeTextures && m_recalculatePreviewTexture ) ) { try { m_instance.RenderCombinedAlpha( m_currentData ); } catch( Exception e ) { Debug.LogWarning( "[AmplifyImpostors] Something went wrong with the mesh preview process, please contact support@amplify.pt with this log message.\n" + e.Message + e.StackTrace ); } if( m_instance.m_cutMode == CutMode.Automatic ) m_recalculateMesh = true; m_recalculatePreviewTexture = false; } 如果缓存的m_alphaTex为空,则会先调用RenderCombinedAlpha渲染出合并alpha纹理,并缓存进m_alphaTex。 然后再调用GenerateAutomaticMesh生成Mesh点。
阅读全文