Home Technical Talk

UV pass wrapping alghorithm

Hi,
http://blenderartists.org/forum/archive/index.php/t-314216.html

I`ve read that thread and I wanted to do my own php script for wrapping texture with using UV coordinate pass map.

So, I did php script which takes color of current pixel from pixel calculated as red value multiplied by pixel X position and green value multiplied by pixel Y position.
http://community.thefoundry.co.uk/discussion/content.aspx?id=25679&t=10

Something is not right. All my images have got circulated grid. I think that my math algorithm is not complete. Is there something more than multiply color value by current pixel position?

Replies

  • Farfarer
    Options
    Offline / Send Message
    You'd need to give us some code to see what the issue is. We don't know how you're getting the screen space coordinates or how you're applying them.

    I'm not sure PHP is really designed for that kind if work, either.
  • bartosh44
    Options
    Offline / Send Message
    <?php
    ini_set('max_execution_time', 300); //300 seconds = 5 minutes
    ini_set('memory_limit', '-1');
    $img = imagecreatefrompng("uvpass.png");
    $widthimg = imagesx($img);
    $heightimg =imagesy($img);
    $img2 = imagecreatefrompng("texture2.png");
    $widthimg2 = imagesx($img2);
    $heightimg2 =imagesy($img2);

    $img3 = imagecreatetruecolor($widthimg, $heightimg);
    imageantialias($img3, true);


    for($i=0;$i<$heightimg;$i++){
    for($j=0;$j<$widthimg;$j++){



    $rgb = imagecolorat($img, $j,$i);
    $r = (($rgb >> 16) & 0xFF)/255;
    $g = (($rgb >> 8) & 0xFF)/255;

    $wyliczenier = ($i*$r)%$widthimg2;
    $wyliczenieg = ($j*$g)%$heightimg2;

    $rgb2 = imagecolorat($img2,$wyliczenier,$wyliczenieg);
    imagesetpixel($img3, $j,$i, $rgb2);
    }
    }

    header('Content-Type: image/png');

    imagepng($img3);
    imagedestroy($img3);

    ?>

    Here it is. I tried also ImageMagic 16 bit PHP library for floating point calculation. Result was same bad.
Sign In or Register to comment.