@@ -20,20 +20,13 @@ public class AssetManager : MonoBehaviour
2020 public int TotalParentObjectSize ;
2121 [ HideInInspector ] public float LightEnergyScale = 1.0f ;
2222 //emissive, alpha, metallic, roughness
23- #if ForceLossless
24- public RenderTexture AlbedoAtlas ;
25- public RenderTexture NormalAtlas ;
26- public RenderTexture SingleComponentAtlas ;
27- public RenderTexture EmissiveAtlas ;
28- #else
29- public Texture2D AlbedoAtlas ;
30- public Texture2D NormalAtlas ;
31- public Texture2D SingleComponentAtlas ;
32- public Texture2D EmissiveAtlas ;
33- #endif
34- public RenderTexture HeightmapAtlas ;
35- public RenderTexture AlphaMapAtlas ;
36- public RenderTexture AlphaAtlas ;
23+ [ HideInInspector ] public Texture2D AlbedoAtlas ;
24+ [ HideInInspector ] public Texture2D NormalAtlas ;
25+ [ HideInInspector ] public Texture2D SingleComponentAtlas ;
26+ [ HideInInspector ] public Texture2D EmissiveAtlas ;
27+ [ HideInInspector ] public RenderTexture HeightmapAtlas ;
28+ [ HideInInspector ] public RenderTexture AlphaMapAtlas ;
29+ [ HideInInspector ] public RenderTexture AlphaAtlas ;
3730 private RenderTexture TempTex ;
3831 private RenderTexture s_Prop_EncodeBCn_Temp ;
3932 private ComputeShader CopyShader ;
@@ -58,7 +51,7 @@ public class AssetManager : MonoBehaviour
5851 [ HideInInspector ] public ComputeBuffer AggTriBuffer ;
5952 [ HideInInspector ] public ComputeBuffer LightTriBuffer ;
6053 [ HideInInspector ] public ComputeBuffer LightNodeBuffer ;
61- public List < MyMeshDataCompacted > MyMeshesCompacted ;
54+ [ HideInInspector ] public List < MyMeshDataCompacted > MyMeshesCompacted ;
6255 [ HideInInspector ] public List < LightData > UnityLights ;
6356 [ HideInInspector ] public InstancedManager InstanceData ;
6457 [ HideInInspector ] public List < InstancedObject > Instances ;
@@ -135,10 +128,10 @@ public void SetLightData(ComputeShader ThisShader, int Kernel) {
135128
136129 [ HideInInspector ] public int MatCount ;
137130
138- public List < LightMeshData > LightMeshes ;
131+ [ HideInInspector ] public List < LightMeshData > LightMeshes ;
139132
140133 [ HideInInspector ] public AABB [ ] MeshAABBs ;
141- public LightBounds [ ] LightAABBs ;
134+ [ HideInInspector ] public LightBounds [ ] LightAABBs ;
142135
143136 [ HideInInspector ] public bool ParentCountHasChanged ;
144137
@@ -220,20 +213,12 @@ private void PackAndCompact(Dictionary<int, TexObj> DictTex, ref RenderTexture A
220213 if ( TexCount != 0 ) {
221214 PackingRectangle BoundRects ;
222215 RectanglePacker . Pack ( Rects , out BoundRects ) ;
223- #if ForceLossless
224- DesiredRes = ( int ) Mathf . Min ( Mathf . Max ( BoundRects . Width , BoundRects . Height ) , DesiredRes ) ;
225- #else
226- DesiredRes = ( int ) Mathf . Min ( ( Mathf . Floor ( ( float ) Mathf . Max ( BoundRects . Width , BoundRects . Height ) / 4.0f ) ) * 4 , DesiredRes ) ;
227- #endif
216+ DesiredRes = ( int ) Mathf . Min ( ( Mathf . Floor ( ( float ) Mathf . Max ( BoundRects . Width , BoundRects . Height ) / 4.0f ) ) * 4 , DesiredRes ) ;
228217 Scale = new Vector2 ( Mathf . Ceil ( Mathf . Min ( ( float ) DesiredRes / BoundRects . Width , 1 ) * 16384.0f / 4.0f ) * 4.0f / 16384.0f , Mathf . Ceil ( Mathf . Min ( ( float ) DesiredRes / BoundRects . Height , 1 ) * 16384.0f / 4.0f ) * 4.0f / 16384.0f ) ;
229218 } else {
230219 DesiredRes = 4 ;
231220 }
232- #if ForceLossless
233- if ( Atlas == null || Atlas . width != DesiredRes ) {
234- #else
235221 if ( Atlas == null || Atlas . width != DesiredRes ) {
236- #endif
237222 if ( Atlas != null ) Atlas . ReleaseSafe ( ) ;
238223 int tempWidth = ( DesiredRes + 3 ) / 4 ;
239224 int tempHeight = ( DesiredRes + 3 ) / 4 ;
@@ -283,26 +268,18 @@ private void PackAndCompact(Dictionary<int, TexObj> DictTex, ref RenderTexture A
283268 }
284269 break ;
285270 case 6 : //AlbedoMap
286- #if ForceLossless
287- CreateRenderTexture ( ref Atlas , DesiredRes , DesiredRes , CommonFunctions . RTHalf4 , false ) ;
288- #else
289- Atlas = new RenderTexture ( desc ) ;
290- AlbedoAtlasSize = DesiredRes ;
291- if ( AlbedoAtlas != null && AlbedoAtlas . width != DesiredRes ) {
292- DestroyImmediate ( AlbedoAtlas ) ;
293- AlbedoAtlas = new Texture2D ( DesiredRes , DesiredRes , TextureFormat . BC6H , false ) ;
294- }
295- #endif
271+ Atlas = new RenderTexture ( desc ) ;
272+ AlbedoAtlasSize = DesiredRes ;
273+ if ( AlbedoAtlas != null && AlbedoAtlas . width != DesiredRes ) {
274+ DestroyImmediate ( AlbedoAtlas ) ;
275+ AlbedoAtlas = new Texture2D ( DesiredRes , DesiredRes , TextureFormat . BC6H , false ) ;
276+ }
296277 break ;
297278 }
298279 }
299280 if ( TexCount == 0 ) return ;
300281
301- #if ForceLossless
302- CopyShader . SetBool ( "ForceLossless" , TexIndex != 5 ) ;
303- #else
304- CopyShader . SetBool ( "ForceLossless" , false ) ;
305- #endif
282+ CopyShader . SetBool ( "ForceLossless" , false ) ;
306283 CopyShader . SetBool ( "IsHeightmap" , TexIndex == 0 ) ;
307284 for ( int i = 0 ; i < TexCount ; i ++ ) {
308285 PackingRectangle TempRect = Rects [ i ] ;
@@ -372,16 +349,10 @@ private void PackAndCompact(Dictionary<int, TexObj> DictTex, ref RenderTexture A
372349 break ;
373350 case 5 :
374351 case 6 :
375- #if ForceLossless
376- CopyShader . SetTexture ( 2 , "InputTex" , SelectedTex . Tex ) ;
377- CopyShader . SetTexture ( 2 , "ResultFull" , Atlas ) ;
378- CopyShader . Dispatch ( 2 , ( int ) Mathf . CeilToInt ( TempRect . Width * Scale . x / 32.0f ) , ( int ) Mathf . CeilToInt ( TempRect . Height * Scale . y / 32.0f ) , 1 ) ;
379- #else
380352 CopyShader . SetTexture ( 4 , "_Source" , SelectedTex . Tex ) ;
381353
382354 CopyShader . SetTexture ( 4 , "_Target" , Atlas ) ;
383355 CopyShader . Dispatch ( 4 , ( int ) Mathf . CeilToInt ( TempRect . Width * Scale . x / 4.0f ) , ( int ) Mathf . CeilToInt ( TempRect . Height * Scale . y / 4.0f ) , 1 ) ;
384- #endif
385356 break ;
386357 }
387358
@@ -565,34 +536,27 @@ private void CreateAtlas(int TotalMatCount) {//Creates texture atlas
565536 if ( ! RenderQue . Any ( ) )
566537 return ;
567538
568- #if ForceLossless
569- if ( AlbedoAtlas != null ) AlbedoAtlas ? . Release ( ) ;
570- PackAndCompact ( AlbTextures , ref AlbedoAtlas , AlbRect . ToArray ( ) , MainDesiredRes , 6 , 3 ) ;
571- if ( NormalAtlas != null ) NormalAtlas ? . Release ( ) ;
572- PackAndCompact ( NormTextures , ref NormalAtlas , NormRect . ToArray ( ) , MainDesiredRes , 2 ) ;
573- #else
574- PackAndCompact ( AlbTextures , ref TempTex , AlbRect . ToArray ( ) , MainDesiredRes , 6 , 3 ) ;
575- Graphics . CopyTexture ( TempTex , 0 , AlbedoAtlas , 0 ) ;
576- TempTex . Release ( ) ;
577- TempTex = null ;
539+ PackAndCompact ( AlbTextures , ref TempTex , AlbRect . ToArray ( ) , MainDesiredRes , 6 , 3 ) ;
540+ Graphics . CopyTexture ( TempTex , 0 , AlbedoAtlas , 0 ) ;
541+ TempTex . Release ( ) ;
542+ TempTex = null ;
578543
579- PackAndCompact ( NormTextures , ref TempTex , NormRect . ToArray ( ) , MainDesiredRes , 2 ) ;
544+ PackAndCompact ( NormTextures , ref TempTex , NormRect . ToArray ( ) , MainDesiredRes , 2 ) ;
580545
581- Graphics . CopyTexture ( TempTex , 0 , NormalAtlas , 0 ) ;
582- TempTex . Release ( ) ;
583- TempTex = null ;
546+ Graphics . CopyTexture ( TempTex , 0 , NormalAtlas , 0 ) ;
547+ TempTex . Release ( ) ;
548+ TempTex = null ;
584549
585- PackAndCompact ( SingleComponentTexture , ref TempTex , SingleComponentRect . ToArray ( ) , MainDesiredRes , 4 ) ;
550+ PackAndCompact ( SingleComponentTexture , ref TempTex , SingleComponentRect . ToArray ( ) , MainDesiredRes , 4 ) ;
586551
587- Graphics . CopyTexture ( TempTex , 0 , SingleComponentAtlas , 0 ) ;
588- TempTex . Release ( ) ;
589- TempTex = null ;
552+ Graphics . CopyTexture ( TempTex , 0 , SingleComponentAtlas , 0 ) ;
553+ TempTex . Release ( ) ;
554+ TempTex = null ;
590555
591- PackAndCompact ( EmisTextures , ref TempTex , EmisRect . ToArray ( ) , MainDesiredRes , 5 ) ;
592- Graphics . CopyTexture ( TempTex , 0 , EmissiveAtlas , 0 ) ;
593- TempTex . Release ( ) ;
594- TempTex = null ;
595- #endif
556+ PackAndCompact ( EmisTextures , ref TempTex , EmisRect . ToArray ( ) , MainDesiredRes , 5 ) ;
557+ Graphics . CopyTexture ( TempTex , 0 , EmissiveAtlas , 0 ) ;
558+ TempTex . Release ( ) ;
559+ TempTex = null ;
596560
597561
598562 PackAndCompact ( AlphTextures , ref AlphaAtlas , AlphRect . ToArray ( ) , MainDesiredRes , 7 ) ;
@@ -741,13 +705,11 @@ private void init() {
741705 #if HardwareRT
742706 AccelStruct = new UnityEngine . Rendering . RayTracingAccelerationStructure ( ) ;
743707 #endif
744- #if ForceLossless
745- #else
746- if ( AlbedoAtlas == null ) AlbedoAtlas = new Texture2D ( 4 , 4 , TextureFormat . BC6H , false ) ;
747- if ( EmissiveAtlas == null ) EmissiveAtlas = new Texture2D ( 4 , 4 , TextureFormat . BC6H , false ) ;
748- if ( NormalAtlas == null ) NormalAtlas = new Texture2D ( 4 , 4 , TextureFormat . BC5 , 1 , false ) ;
749- if ( SingleComponentAtlas == null ) SingleComponentAtlas = new Texture2D ( 4 , 4 , TextureFormat . BC4 , 1 , false ) ;
750- #endif
708+ if ( AlbedoAtlas == null ) AlbedoAtlas = new Texture2D ( 4 , 4 , TextureFormat . BC6H , false ) ;
709+ if ( EmissiveAtlas == null ) EmissiveAtlas = new Texture2D ( 4 , 4 , TextureFormat . BC6H , false ) ;
710+ if ( NormalAtlas == null ) NormalAtlas = new Texture2D ( 4 , 4 , TextureFormat . BC5 , 1 , false ) ;
711+ if ( SingleComponentAtlas == null ) SingleComponentAtlas = new Texture2D ( 4 , 4 , TextureFormat . BC4 , 1 , false ) ;
712+
751713 UpdateMaterialDefinition ( ) ;
752714 UnityEngine . Video . VideoPlayer [ ] VideoObjects = GameObject . FindObjectsOfType < UnityEngine . Video . VideoPlayer > ( ) ;
753715 if ( VideoTexture != null ) VideoTexture . Release ( ) ;
@@ -1350,7 +1312,7 @@ public struct LightBVHTransform {
13501312 public Matrix4x4 Transform ;
13511313 public int SolidOffset ;
13521314 }
1353- public LightBVHTransform [ ] LightBVHTransforms ;
1315+ [ HideInInspector ] public LightBVHTransform [ ] LightBVHTransforms ;
13541316
13551317 unsafe public void ConstructNewTLAS ( ) {
13561318 #if HardwareRT
0 commit comments