PaintColors - 图1

    1. //reference: http://glslsandbox.com/e#43216.0
    2. shader PaintColors
    3. [[ string help = "Painterly Texture Map Distortion",
    4. string label = "Paint Colors" ]]
    5. (
    6. float tm=0[[float min=0, float max=100]],
    7. float offX=0.175[[float min=0, float max=0.5]],
    8. float offY=0.275[[float min=0, float max=0.5]],
    9. float offZ=0.25[[float min=0, float max=0.5]],
    10. output color c = 0)
    11. {
    12. int complexity = 47; // More points of color.
    13. float fluid_speed = 108.0; // Drives speed, higher number will make it slower.
    14. float clrInt = 0.8;
    15. vector p=vector(u,v,0);
    16. p=P;
    17. for(int i=1;i<complexity;i++)
    18. {
    19. vector newp = p + tm*0.001;
    20. float s=i;
    21. newp[0]+=0.6/s*sin(s*p[2]+tm/fluid_speed+0.3*s) + offX; // + mouse[1]/mouse_factor+mouse_offset;
    22. newp[1]+=0.6/s*sin(s*p[0]+tm/fluid_speed+0.3*(i+10)) - offY; // - mouse[0]/mouse_factor+mouse_offset;
    23. newp[2]+=0.6/s*sin(s*p[1]+tm/fluid_speed+0.3*s) + offZ;
    24. p=newp;
    25. }
    26. c=vector(clrInt*sin(3.0*p[0])+clrInt, clrInt*sin(3.0*p[1])+clrInt, clrInt*sin(p[0]+p[2])+clrInt);
    27. }