override protected Texture2D CreateProduct(Texture2D reuse = null) { Texture2D texture = reuse; if (texture == null) { texture = new Texture2D(Width, Height, TextureFormat.ARGB32, false); } if (Input == null) { Debug.LogWarning("No Input set up"); return(texture); } this.hideFlags = HideFlags.HideInHierarchy; Mesh mesh = ((NPVoxIMeshFactory)Input).GetProduct(); if (mesh) { NPVoxTextureGenerator.CreateTexture(mesh, texture, Type, Width, Height); } return(texture); }
private NPVoxTextureAtlas.Slot CreateTexture(NPVoxTextureAtlas.Slot slot, bool bInclude, int width, int height, Quaternion cameraAngle, Vector3 camPosition, Vector2 ratio, Quaternion normalOffset) { int border = 1; NPVoxMeshOutput meshOutput = (Input as NPVoxMeshOutput); Mesh sourceMesh = meshOutput.GetProduct(); Texture2D albedoTexture = TextureAtlas.GetAlbedoTexture(); Texture2D normalTexture = TextureAtlas.GetNormalTexture(); // if(BakeGaianigmaAngle) // { // height *= 2; // } if (bInclude) { if (slot == null || slot.width != width + border * 2 || slot.height != height + border * 2 || !TextureAtlas.IsAllocated(slot) || slotsAllocatedAtTA != this.TextureAtlas) { if (slot.width != 0 && slot.height != 0 && slotsAllocatedAtTA != null) { slotsAllocatedAtTA.DeallocateSlot(slot); } slot = TextureAtlas.AllocateSlot(width + border * 2, height + border * 2); } NPVoxTextureGenerator.CreateSubTexture(sourceMesh, cameraAngle, camPosition, albedoTexture, NPVoxTextureType.ALBEDO, width, height, slot.x + border, slot.y + border, ratio, normalOffset); NPVoxTextureGenerator.CreateSubTexture(sourceMesh, cameraAngle, camPosition, normalTexture, NPVoxTextureType.NORMALMAP, width, height, slot.x + border, slot.y + border, ratio, normalOffset); if (border > 0) { NPVoxTextureGenerator.AddBorder(albedoTexture, width, height, slot.x + border, slot.y + border); NPVoxTextureGenerator.AddBorder(normalTexture, width, height, slot.x + border, slot.y + border); } } else if (slot != null) { if (slotsAllocatedAtTA != null) { slotsAllocatedAtTA.DeallocateSlot(slot); } slot = null; } return(slot); }