Initial commit: Minecraft 光追着色器包(从零实现的 path tracing)
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#include "/Lib/Settings.glsl"
|
||||
#include "/Lib/Utilities.glsl"
|
||||
// MinecraftPT — End Sky
|
||||
// End dimension sky: stars, planet, accretion disc around black hole.
|
||||
|
||||
#ifndef END_SKY_GLSL
|
||||
#define END_SKY_GLSL
|
||||
|
||||
vec3 GetEndSky(vec3 dir, vec3 sunDir){
|
||||
dir = normalize(dir);
|
||||
|
||||
// Dark base
|
||||
vec3 color = vec3(0.01, 0.01, 0.02);
|
||||
|
||||
// Stars (hash-based)
|
||||
float stars = 0.0;
|
||||
vec3 starDir = dir;
|
||||
for (int i = 0; i < 32; i++){
|
||||
vec3 seed = vec3(i * 0.1, 0.5, 0.7);
|
||||
vec3 starPos = normalize(hash3(seed.xy) - 0.5);
|
||||
float star = exp(-(1.0 - dot(dir, starPos)) * 1000.0);
|
||||
stars += star * hash1(seed.xy);
|
||||
}
|
||||
color += stars * 0.5;
|
||||
|
||||
// Planet (distant body)
|
||||
vec3 planetDir = normalize(vec3(0.5, 0.3, 0.0));
|
||||
float planet = exp(-(1.0 - dot(dir, planetDir)) * 200.0);
|
||||
color += vec3(0.3, 0.4, 0.6) * planet * 0.8;
|
||||
|
||||
// Accretion disc (around planet)
|
||||
float disc = exp(-abs(dot(normalize(dir.xz), normalize(planetDir.xz))) * 50.0);
|
||||
disc *= step(abs(dir.y), 0.1);
|
||||
color += vec3(1.0, 0.6, 0.2) * disc * 0.5;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user