二 งานทดลองExperiment

Night Shader

ท้องฟ้ากลางคืนที่สร้างจาก noise ใน GLSL ล้วน แสงชาดตามเมาส์ ไม่มีไลบรารีA night sky made purely from GLSL noise, with an ember light that follows your pointer. No library.

loading shader…
WebGL · GLSL fragment shader · fBm noise
一 วิธีเล่นHow to play

ขยับเมาส์หรือนิ้วไปบนท้องฟ้า แสงสีชาดจะตามไป เปิดเต็มจอเพื่อดูรายละเอียดของหมอกMove the pointer or a finger across the sky and the ember light follows. Go fullscreen to see the detail in the haze.

二 ทำงานยังไงHow it works
  • 一

    noise ซ้อน 5 ชั้นFive octaves of noise

    หมอกมาจาก fBm (noise ซ้อนกัน 5 ชั้น) และเอาผลของ noise ชุดหนึ่งไปบิดพิกัดของอีกชุด ทำให้ไหลเหมือนควันThe haze is fBm — five layers of noise — and one noise field warps the coordinates of another, which makes it flow like smoke.

  • 二

    สามเหลี่ยมเดียวคลุมทั้งจอOne triangle covers the screen

    ไม่มีโมเดล มีแค่สามเหลี่ยมใหญ่หนึ่งรูป ทุกอย่างคำนวณต่อพิกเซลใน fragment shaderThere is no model, just one oversized triangle. Everything is computed per pixel in the fragment shader.

  • 三

    แสงตามเมาส์ + ดาวกะพริบPointer light and twinkling stars

    ความสว่างของแสงคำนวณจากระยะห่างถึงตำแหน่งเมาส์ ส่วนดาวมาจากการสุ่มต่อช่องพิกเซลแล้วให้กะพริบด้วยคลื่น sineThe glow is computed from the distance to the pointer; the stars come from a per-cell random value that twinkles on a sine wave.

  • 四

    เบาเครื่องEasy on the device

    วาดที่ความละเอียดต่ำกว่าจอจริง (ลดลงอีกบนมือถือ) หยุดเมื่ออยู่นอกจอ คืนทรัพยากร WebGL เมื่อออกจากหน้า และแสดงภาพนิ่งถ้าผู้ชมตั้งค่าลดการเคลื่อนไหวIt renders below native resolution (lower again on phones), pauses off-screen, releases its WebGL resources on exit, and shows a still frame for visitors who ask for reduced motion.