Skip to content

Commit

Permalink
Merge pull request #314 from umasteeringgroup/feature-DownSample_Impr…
Browse files Browse the repository at this point in the history
…ovement

Feature down sample improvement
  • Loading branch information
Jaimi authored Jun 22, 2020
2 parents 79e432d + b689c45 commit 728f2af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ protected override IEnumerator workerMethod()
continue;
}

destinationTexture = new RenderTexture(Mathf.FloorToInt(atlas.cropResolution.x * umaData.atlasResolutionScale), Mathf.FloorToInt(atlas.cropResolution.y * umaData.atlasResolutionScale), 0, slotData.asset.material.channels[textureType].textureFormat, RenderTextureReadWrite.Linear);
//this should be restricted to >= 1 but 0 was allowed before and projects may have the umaMaterial value serialized to 0.
float downSample = (slotData.asset.material.channels[textureType].DownSample == 0) ? 1f : (1f / slotData.asset.material.channels[textureType].DownSample);

destinationTexture = new RenderTexture(Mathf.FloorToInt(atlas.cropResolution.x * umaData.atlasResolutionScale * downSample), Mathf.FloorToInt(atlas.cropResolution.y * umaData.atlasResolutionScale * downSample), 0, slotData.asset.material.channels[textureType].textureFormat, RenderTextureReadWrite.Linear);
destinationTexture.filterMode = FilterMode.Point;
destinationTexture.useMipMap = umaGenerator.convertMipMaps && !umaGenerator.convertRenderTexture;
//Draw all the Rects here
Expand All @@ -128,17 +131,6 @@ protected override IEnumerator workerMethod()
//PostProcess
textureMerge.PostProcess(destinationTexture, slotData.asset.material.channels[textureType].channelType);

int DownSample = slotData.asset.material.channels[textureType].DownSample;
if (DownSample != 0)
{
int newW = width >> DownSample;
int newH = height >> DownSample;

RenderTexture rt = ResizeRenderTexture(destinationTexture, newW, newH, FilterMode.Bilinear);
destinationTexture.Release();
destinationTexture = rt;
}

if (umaGenerator.convertRenderTexture || slotData.asset.material.channels[textureType].ConvertRenderTexture)
{
#region Convert Render Textures
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public struct MaterialChannel
public string materialPropertyName;
public string sourceTextureName;
public CompressionSettings Compression;
[Range(0,4)]
[Range(1,128)]
public int DownSample;
public bool ConvertRenderTexture;
public bool NonShaderTexture;
Expand Down

0 comments on commit 728f2af

Please sign in to comment.