4

I am trying to draw a hemisphere decomposed with multiple patches. Here is the figure enter image description here The issue is that on the periphery, it gets very dark. I would like the surface to be less smooth, so it can be lighted uniformly. Here is the code:

    import three;
    size(10cm);
    settings.render = 1;
    settings.antialias = 16;
    defaultrender.merge=true;
    defaultrender.tessellate=true;

    currentlight = light(0,0,100);
    currentprojection =
    orthographic(0,0,100);

    real[] uknot={0,0,0,0,0,1,1,1,1,1};
    real[] vknot={0,0,0,0,0,1,1,1,1,1};

    triple[][] P1={{
    (-29.282032302755088, -29.282032302755088, 29.282032302755088)/5.071796769724491,
    (-21.712083963243018, -30.677838684923557, 30.677838684923557)/4.795919436663918,
    (-14.391575887554247, -31.571002659693967, 31.571002659693967)/4.6172866417098355,
    (-7.195787943777123, -32.017584647079175, 32.017584647079175)/4.527970244232795,
    (0.0, -32.017584647079175, 32.017584647079175)/4.527970244232795
    },{
    (-30.677838684923557, -21.712083963243018, 30.677838684923557)/4.795919436663918,
    (-22.869643776777806, -22.869643776777806, 33.02239411869588)/4.494476595178904,
    (-15.200184105546917, -23.632006915798854, 34.56287410349287)/4.295770397960685,
    (-7.600092052773459, -24.013188485309378, 35.33311409589136)/4.196417299351575,
    (0.0, -24.013188485309378, 35.33311409589136)/4.196417299351575
    },{
    (-31.571002659693967, -14.391575887554247, 31.571002659693967)/4.6172866417098355,
    (-23.632006915798854, -15.200184105546917, 34.562874103492874)/4.295770397960685,
    (-15.739256250875362, -15.739256250875362, 36.54993607567506)/4.082178134496292,
    (-7.869628125437681, -16.008792323539584, 37.54346706176616)/3.975382002764096,
    (0.0, -16.008792323539584, 37.54346706176616)/3.975382002764096
    },{
    (-32.017584647079175, -7.195787943777123, 32.017584647079175)/4.527970244232795,
    (-24.013188485309378, -7.600092052773459, 35.33311409589137)/4.196417299351575,
    (-16.008792323539584, -7.869628125437681, 37.543467061766165)/3.9753820027640954,
    (-8.004396161769792, -8.004396161769792, 38.64864354470356)/3.864864354470356,
    (0.0, -8.004396161769792, 38.64864354470356)/3.864864354470356
    },{
    (-32.017584647079175, 0.0, 32.017584647079175)/4.527970244232795,
    (-24.013188485309378, 0.0, 35.33311409589137)/4.196417299351575,
    (-16.008792323539584, 0.0, 37.543467061766165)/3.9753820027640954,
    (-8.004396161769792, 0.0, 38.64864354470356)/3.864864354470356,
    (0.0, 0.0, 38.64864354470356)/3.864864354470356
    }
    };

    // Optional weights:
    real[][] weights1={
    {5.071796769724491,4.795919436663918,4.6172866417098355,4.527970244232795, 4.527970244232795 },
    {4.795919436663918, 4.494476595178904, 4.295770397960685, 4.196417299351575, 4.196417299351575},
    {4.6172866417098355, 4.295770397960685, 4.082178134496292, 3.975382002764096, 3.975382002764096}, 
    {4.527970244232795, 4.196417299351575, 3.9753820027640954, 3.9753820027640954, 3.9753820027640954},
    {4.527970244232795, 4.196417299351575, 3.9753820027640954, 3.9753820027640954, 3.9753820027640954}
    };

    draw(rotate(0, (0,0,1)) * P1,uknot,vknot,weights1,mediumblue);
    draw(rotate(90, (0,0,1)) * P1,uknot,vknot,weights1,mediumyellow);
    draw(rotate(180, (0,0,1)) * P1,uknot,vknot,weights1,mediumgreen);
    draw(rotate(270, (0,0,1)) * P1,uknot,vknot,weights1,mediumred);

    draw(rotate(90, (0,1,0)) * P1,uknot,vknot,weights1,mediumblue);
    draw(rotate(-90, (0,1,0)) * rotate(90, (0,0,1)) * P1,uknot,vknot,weights1,mediumyellow);

    draw(rotate(-90, (0,1,0)) * rotate(180, (0,0,1))  * P1,uknot,vknot,weights1,mediumgreen);
    draw(rotate(90, (0,1,0)) * rotate(270, (0,0,1)) * P1,uknot,vknot,weights1, mediumred);

    draw(rotate(-90, (1,0,0)) * P1,uknot,vknot,weights1,yellow);
    draw(rotate(-90, (1,0,0)) * rotate(90, (0,0,1))  * P1,uknot,vknot,weights1,mediumblue);

    draw(rotate(90, (1,0,0)) * rotate(270, (0,0,1)) * P1,uknot,vknot,weights1,mediumred);
    draw(rotate(90, (1,0,0)) * rotate(180, (0,0,1))  * P1,uknot,vknot,weights1, mediumgreen);
  • 1
    No. If you don't specify the location of the light source, asymptote will set one for you. – Di Miao Aug 31 '18 at 21:37
  • You are right. I'm wondering if this discussion could help, just may make your pen more "emissive". – user121799 Aug 31 '18 at 22:09
4

According to this answer, one way to go is to give the material more "emissevness". I did that for red and blue but left green and yellow as they were in order to illustrate the difference. The definitions of blues and reds are taken from here.

\documentclass[border=3.14mm]{standalone}
\usepackage{asypictureB}
\begin{document}
\begin{asypicture}{name=PatchSphere}
    import three;
    size(10cm);
    settings.render = 1;
    settings.antialias = 16;
    defaultrender.merge=true;
    defaultrender.tessellate=true;

    currentlight = light(0,0,400);
    currentprojection =
    orthographic(0,0,100);

    real[] uknot={0,0,0,0,0,1,1,1,1,1};
    real[] vknot={0,0,0,0,0,1,1,1,1,1};

    triple[][] P1={{
    (-29.282032302755088, -29.282032302755088, 29.282032302755088)/5.071796769724491,
    (-21.712083963243018, -30.677838684923557, 30.677838684923557)/4.795919436663918,
    (-14.391575887554247, -31.571002659693967, 31.571002659693967)/4.6172866417098355,
    (-7.195787943777123, -32.017584647079175, 32.017584647079175)/4.527970244232795,
    (0.0, -32.017584647079175, 32.017584647079175)/4.527970244232795
    },{
    (-30.677838684923557, -21.712083963243018, 30.677838684923557)/4.795919436663918,
    (-22.869643776777806, -22.869643776777806, 33.02239411869588)/4.494476595178904,
    (-15.200184105546917, -23.632006915798854, 34.56287410349287)/4.295770397960685,
    (-7.600092052773459, -24.013188485309378, 35.33311409589136)/4.196417299351575,
    (0.0, -24.013188485309378, 35.33311409589136)/4.196417299351575
    },{
    (-31.571002659693967, -14.391575887554247, 31.571002659693967)/4.6172866417098355,
    (-23.632006915798854, -15.200184105546917, 34.562874103492874)/4.295770397960685,
    (-15.739256250875362, -15.739256250875362, 36.54993607567506)/4.082178134496292,
    (-7.869628125437681, -16.008792323539584, 37.54346706176616)/3.975382002764096,
    (0.0, -16.008792323539584, 37.54346706176616)/3.975382002764096
    },{
    (-32.017584647079175, -7.195787943777123, 32.017584647079175)/4.527970244232795,
    (-24.013188485309378, -7.600092052773459, 35.33311409589137)/4.196417299351575,
    (-16.008792323539584, -7.869628125437681, 37.543467061766165)/3.9753820027640954,
    (-8.004396161769792, -8.004396161769792, 38.64864354470356)/3.864864354470356,
    (0.0, -8.004396161769792, 38.64864354470356)/3.864864354470356
    },{
    (-32.017584647079175, 0.0, 32.017584647079175)/4.527970244232795,
    (-24.013188485309378, 0.0, 35.33311409589137)/4.196417299351575,
    (-16.008792323539584, 0.0, 37.543467061766165)/3.9753820027640954,
    (-8.004396161769792, 0.0, 38.64864354470356)/3.864864354470356,
    (0.0, 0.0, 38.64864354470356)/3.864864354470356
    }
    };

    // Optional weights:
    real[][] weights1={
    {5.071796769724491,4.795919436663918,4.6172866417098355,4.527970244232795, 4.527970244232795 },
    {4.795919436663918, 4.494476595178904, 4.295770397960685, 4.196417299351575, 4.196417299351575},
    {4.6172866417098355, 4.295770397960685, 4.082178134496292, 3.975382002764096, 3.975382002764096}, 
    {4.527970244232795, 4.196417299351575, 3.9753820027640954, 3.9753820027640954, 3.9753820027640954},
    {4.527970244232795, 4.196417299351575, 3.9753820027640954, 3.9753820027640954, 3.9753820027640954}
    };
    material reds =  material(diffusepen=0.7red,ambientpen=red,emissivepen=0.3*red,specularpen=0.95white,shininess=0.95);
    material blues = material(diffusepen=0.7blue,ambientpen=blue,emissivepen=0.3*blue,specularpen=0.95white,shininess=0.95);

    draw(rotate(0, (0,0,1)) * P1,uknot,vknot,weights1,blues);
    draw(rotate(90, (0,0,1)) * P1,uknot,vknot,weights1,mediumyellow);
    draw(rotate(180, (0,0,1)) * P1,uknot,vknot,weights1,mediumgreen);
    draw(rotate(270, (0,0,1)) * P1,uknot,vknot,weights1,reds);

    draw(rotate(90, (0,1,0)) * P1,uknot,vknot,weights1,blues);
    draw(rotate(-90, (0,1,0)) * rotate(90, (0,0,1)) * P1,uknot,vknot,weights1,mediumyellow);

    draw(rotate(-90, (0,1,0)) * rotate(180, (0,0,1))  * P1,uknot,vknot,weights1,mediumgreen);
    draw(rotate(90, (0,1,0)) * rotate(270, (0,0,1)) * P1,uknot,vknot,weights1, reds);

    draw(rotate(-90, (1,0,0)) * P1,uknot,vknot,weights1,yellow);
    draw(rotate(-90, (1,0,0)) * rotate(90, (0,0,1))  *  P1,uknot,vknot,weights1,blues);

    draw(rotate(90, (1,0,0)) * rotate(270, (0,0,1)) * P1,uknot,vknot,weights1,reds);
    draw(rotate(90, (1,0,0)) * rotate(180, (0,0,1))  * P1,uknot,vknot,weights1, mediumgreen);
\end{asypicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.