Initial commit: Minecraft 光追着色器包(从零实现的 path tracing)
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
// MinecraftPT — Entities Fragment Shader
|
||||
// Handles entities (players, mobs), hands are in Hand_FS
|
||||
|
||||
#include "/Lib/Settings.glsl"
|
||||
#include "/Lib/Utilities.glsl"
|
||||
|
||||
in vec2 texcoord;
|
||||
in vec3 worldPos;
|
||||
in vec3 worldNormal;
|
||||
in vec3 vertexNormal;
|
||||
in vec4 color;
|
||||
in vec2 lightmap;
|
||||
flat in int blockId;
|
||||
flat in float blockLightLevel;
|
||||
|
||||
layout(location = 0) out vec4 colortex0Out;
|
||||
layout(location = 1) out vec4 colortex1Out;
|
||||
layout(location = 2) out vec4 colortex2Out;
|
||||
layout(location = 3) out vec4 colortex3Out;
|
||||
layout(location = 4) out vec4 colortex4Out;
|
||||
layout(location = 5) out vec4 colortex5Out;
|
||||
|
||||
uniform bool isPlayer;
|
||||
|
||||
void main(){
|
||||
vec4 albedo = texture(tex, texcoord) * color;
|
||||
|
||||
if (albedo.a < 0.004) discard;
|
||||
|
||||
// Entity material ID — default entity
|
||||
float matID = 6.0; // MATID_ENTITIES
|
||||
|
||||
// Player special handling (OptiFine provides isPlayer uniform in entities pass)
|
||||
if (isPlayer){
|
||||
matID = 7.0; // MATID_ENTITIES_PLAYER
|
||||
}
|
||||
|
||||
vec4 specTex = vec4(0.0);
|
||||
#ifdef TEXTURE_PBR_FORMAT
|
||||
if (TEXTURE_PBR_FORMAT >= 1){
|
||||
specTex = texture(atlasSpecular2D, texcoord);
|
||||
}
|
||||
#endif
|
||||
|
||||
vec2 lm = lightmap;
|
||||
lm.y = SkyLightmapCurve(lightmap.y);
|
||||
|
||||
float emissive = 0.0;
|
||||
#ifdef VANILLA_EMISSIVE
|
||||
emissive = step(13.5, blockLightLevel) * blockLightLevel / 15.0;
|
||||
#endif
|
||||
|
||||
colortex0Out = vec4(albedo.rgb, emissive);
|
||||
colortex1Out = vec4(EncodeNormal(worldNormal), EncodeNormal(vertexNormal));
|
||||
colortex2Out = vec4(specTex.r, specTex.g, specTex.b, matID / 255.0);
|
||||
colortex3Out = vec4(lm, 1.0, 1.0);
|
||||
|
||||
colortex4Out = vec4(0.0);
|
||||
colortex5Out = vec4(0.0);
|
||||
}
|
||||
Reference in New Issue
Block a user