Asymptote 中的灯光渲染

Asymptote 中的灯光渲染

我正在尝试绘制一个由多个块分解而成的半球。下图是 在此处输入图片描述 问题是边缘部分太暗了。我希望表面不那么光滑,这样就能均匀地发光。代码如下:

    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

根据这个答案,一种方法是让材料更具“发射性”。我对红色和蓝色做了同样的处理,但保留了绿色和黄色,以说明差异。blues和的定义reds取自这里

\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}

在此处输入图片描述

相关内容