Community
Maya Shading, Lighting and Rendering
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya materials topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How the texel density is calculated in maya ?

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Anonymous
2640 Views, 1 Reply

How the texel density is calculated in maya ?

Hi,

 

I just append to have a problem with the Texel Density tool from the UV Toolkit.

We have to get a very precise Texel Density among the whole project, and the way this tool reacts is causing us problems at the moment.

 

The same texel density on different UV shells results on really significant changes and i don't know why.

 

I tried to find the way this attribute is calculated in order to python my way out of this problem, and I am still on it, but I cannot find a proper way to calculate it at the moment.

 

Anybody have a similar problem ? Or better, a hint of a solution ?

 

Thank you by advance !

1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

I just found the mel script which does this :

// ===========================================================================
// Copyright 2017 Autodesk, Inc. All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software in either electronic or hard copy form.
// ===========================================================================
// ===========================================================================
//
// Creation Date: October 27, 2016
//
// Procedure Name:
// texCalculateTexelDensity
//
// Description:
// UV workflow function used for calculating the texel density value of
// input faces
//
// Input Arguments
// faces - String[] - Names of face components.
// mapSize - Int - The texture size to scale against.
// progressBar - Int - Update the progressBar
//
// Return Values:
// Float - The calculated texel density value.
//
// Notes:
// This script is part of the implementation of Nightshade UV Editor into
// Autodesk Maya. This script is sourced by other scripts. Do not run it
// directly.
//
// ===========================================================================

 

global proc float texCalculateTexelDensity(string $faces[], int $mapSize, int $progressBar)
{
    float $area3DSum = 0.0;
    float $area2DSum = 0.0;
    $faces = `filterExpand -ex false -sm 34 $faces`;

   

    // Begin progressBar
    global string $gMainProgressBar;
    if ($progressBar)
        progressBar -e -bp -max (size($faces)) $gMainProgressBar;

 

    float $area3D[] = `polyEvaluate -worldFaceArea $faces`;
    float $area2D[] = `polyEvaluate -uvFaceArea $faces`;
    for ($i = 0; $i < size($area3D); $i++){
        // Break if cancelled by user
        if ($progressBar && `progressBar -q -isCancelled $gMainProgressBar`)
        {
            warning((uiRes("m_texCalculateTexelDensity.kUvEditorGetTexelDensityInteruptMsg")));
            break;
        }

 

        $area3DSum += $area3D[$i];
        $area2DSum += $area2D[$i];

        // Update the progress window
        if ($progressBar)
            progressBar -e -s 1 $gMainProgressBar;
    }

 

    // End progressBar
    if ($progressBar)
        progressBar -e -endProgress $gMainProgressBar;

    return (`sqrt $area2DSum` / `sqrt $area3DSum`) * $mapSize;
}

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report