Initial commit: Minecraft 光追着色器包(从零实现的 path tracing)
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#include "/Lib/Settings.glsl"
|
||||
#include "/Lib/Utilities.glsl"
|
||||
#include "/Lib/BasicFunctions/LightingConstants.glsl"
|
||||
// MinecraftPT — Planar Clouds
|
||||
// Simple 2D cloud layer rendered as a plane at altitude.
|
||||
|
||||
#ifndef PLANAR_CLOUDS_GLSL
|
||||
#define PLANAR_CLOUDS_GLSL
|
||||
|
||||
// Sample cloud density at a world XZ position (2D noise + coverage)
|
||||
float GetPlanarCloudDensity(vec2 xz, float time, out vec3 cloudColor){
|
||||
// Coverage by weather
|
||||
float coverage = mix(PC_CLEAR_COVERAGE, PC_RAIN_COVERAGE, wetness);
|
||||
float density = mix(PC_CLEAR_DENSITY, PC_RAIN_DENSITY, wetness);
|
||||
float sunlighting = mix(PC_CLEAR_SUNLIGHTING, PC_RAIN_SUNLIGHTING, wetness);
|
||||
float skylighting = mix(PC_CLEAR_SKYLIGHTING, PC_RAIN_SKYLIGHTING, wetness);
|
||||
|
||||
// FBM noise
|
||||
vec2 p = xz * PC_NOISE_SCALE + vec2(time * 0.01, 0.0);
|
||||
float n = 0.0;
|
||||
float amp = 0.5;
|
||||
for (int i = 0; i < 3; i++){
|
||||
n += textureLod(CloudNoise3D, vec3(p, 0.5), 0.0).r * amp;
|
||||
p *= 2.0;
|
||||
amp *= 0.5;
|
||||
}
|
||||
|
||||
float clouds = saturate((n - (1.0 - coverage)) * (1.0 / max(coverage, 0.01)));
|
||||
|
||||
// Cloud color: lit by sun and sky
|
||||
float sunFactor = sunlighting;
|
||||
cloudColor = mix(GetCloudAtmoIrradiance(), GetCloudSunIrradiance(), sunFactor) * clouds
|
||||
+ vec3(1.0) * skylighting * clouds;
|
||||
|
||||
return clouds * density;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user