Skip to content

Commit

Permalink
cleanup; fix smooth normals
Browse files Browse the repository at this point in the history
  • Loading branch information
null511 committed Jan 24, 2023
1 parent 9d40814 commit 3a5e2b1
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 57 deletions.
4 changes: 4 additions & 0 deletions shaders/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ option.DOF_ENABLED=Enabled

option.DOF_SCALE=Scale

option.DOF_STEP_SIZE=Step Size

option.DOF_MAX_SIZE=Max Size


option.SHADER_PLATFORM=Platform
option.SHADER_PLATFORM.comment=Turn this on if you are using Optifine; turn off for Iris.
Expand Down
6 changes: 3 additions & 3 deletions shaders/lib/common.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ const bool colortex11Clear = false;
//#define DOF_ENABLED
#define DOF_SCALE 2.0 // [1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0]
// Smaller = nicer blur, larger = faster
#define DOF_STEP_SIZE 0.7 // [0.5 1.0 1.5 2.0]
#define DOF_MAX_SIZE 16.0 // [5.0 10.0 15.0 20.0 25.0 30.0]
#define DOF_STEP_SIZE 0.5 // [0.5 1.0 1.5 2.0]
#define DOF_MAX_SIZE 10.0 // [5.0 10.0 15.0 20.0 25.0 30.0]


// Debug Options
Expand All @@ -239,7 +239,7 @@ const bool colortex11Clear = false;
#define CLOUD_HORIZON_POWER 8.0
#define CLOUD_POW_CLEAR 1.6
#define CLOUD_POW_RAIN 0.3
//#define SHADOW_CLOUD
#define SHADOW_CLOUD
#define SMOKE_ENABLED
#define VL_SMOKE_DENSITY 0.2
#define IRIS_FEATURE_BIOMECAT
Expand Down
3 changes: 1 addition & 2 deletions shaders/lib/lighting/basic_forward.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ vec4 BasicLighting(const in LightData lightData, const in vec4 albedo, const in
//vec3 upDir = normalize(upPosition);

float cloudF = GetCloudFactor(worldPos, localLightDir, 0);
float cloudShadow = 1.0 - mix(cloudF, 1.0, horizonFogF);
shadow *= cloudShadow;
shadow *= 1.0 - cloudF;
#endif
#endif
#else
Expand Down
2 changes: 1 addition & 1 deletion shaders/lib/lighting/pbr_gbuffers.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
float parallaxShadow = 1.0;
vec2 lm = lmcoord;

#if defined PARALLAX_ENABLED && defined PARALLAX_SMOOTH_NORMALS && MATERIAL_FORMAT != MATERIAL_FORMAT_DEFAULT
#if defined PARALLAX_ENABLED && defined PARALLAX_SMOOTH_NORMALS && MATERIAL_FORMAT != MATERIAL_FORMAT_DEFAULT && !defined RENDER_TEXTURED && !defined RENDER_ENTITIES
if (!isMissingNormal && !isMissingTangent) {
////normalMap.rgb = TexelFetchLinearRGB(normals, atlasCoord * atlasSize);
//normalMap.rgb = TextureGradLinearRGB(normals, atlasCoord, atlasSize, dFdXY);
Expand Down
5 changes: 1 addition & 4 deletions shaders/lib/lighting/volumetric.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ const float AirSpeed = 20.0;
vec3 psiMS = getValFromMultiScattLUT(colortex13, atmosPos, localSunDir) * SKY_FANCY_LUM;
#endif

psiMS *= (eyeBrightnessSmooth.y / 240.0);
psiMS *= 0.6 * (eyeBrightnessSmooth.y / 240.0);

vec3 rayleighInScattering = rayleighScattering * (rayleighPhaseValue * lightTransmittance + psiMS);
vec3 mieInScattering = mieScattering * (miePhaseValue * lightTransmittance + psiMS);
Expand Down Expand Up @@ -228,9 +228,6 @@ const float AirSpeed = 20.0;
vec3 viewLightDir = normalize(shadowLightPosition);
vec3 localLightDir = mat3(gbufferModelViewInverse) * viewLightDir;

//vec3 upDir = normalize(upPosition);
//float horizonFogF = 1.0 - abs(dot(viewLightDir, upDir));

if (localLightDir.y <= 0.0) return vec3(0.0);
#endif

Expand Down
10 changes: 7 additions & 3 deletions shaders/lib/shadows/basic_render.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,13 @@
#elif SHADOW_FILTER == 0
// Unfiltered
float GetShadowing(const in LightData lightData) {
float surfaceDepth = lightData.shadowPos.z - lightData.shadowBias;
float texDepth = lightData.opaqueShadowDepth + EPSILON;
return step(surfaceDepth, texDepth);
#ifdef IRIS_FEATURE_SEPARATE_HARDWARE_SAMPLERS
return textureLod(shadowtex1HW, lightData.shadowPos + vec3(offset, -lightData.shadowBias), 0);
#else
float surfaceDepth = lightData.shadowPos.z - lightData.shadowBias;
float texDepth = lightData.opaqueShadowDepth + EPSILON;
return step(surfaceDepth, texDepth);
#endif
}
#endif

Expand Down
9 changes: 2 additions & 7 deletions shaders/program/composite5.fsh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define RENDER_FRAG
#define RENDER_COMPOSITE
//#define RENDER_COMPOSITE_DOF
#define RENDER_COMPOSITE
#define RENDER_FRAG

#include "/lib/constants.glsl"
#include "/lib/common.glsl"
Expand All @@ -11,16 +11,11 @@ uniform sampler2D depthtex0;
uniform sampler2D BUFFER_HDR_OPAQUE;

uniform float centerDepthSmooth;
//uniform int isEyeInWater;
uniform float viewWidth;
uniform float viewHeight;
uniform float near;
uniform float far;

// #if CAMERA_EXPOSURE_MODE == EXPOSURE_MODE_MIPMAP
// uniform sampler2D BUFFER_LUM_OPAQUE;
// #endif

#include "/lib/depth.glsl"

/* RENDERTARGETS: 4 */
Expand Down
4 changes: 2 additions & 2 deletions shaders/program/composite8.fsh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define RENDER_FRAG
#define RENDER_COMPOSITE
#define RENDER_COMPOSITE_BLOOM_BLUR
//#define RENDER_COMPOSITE_BLOOM_BLUR_V
#define RENDER_COMPOSITE
#define RENDER_FRAG

#include "/lib/constants.glsl"
#include "/lib/common.glsl"
Expand Down
4 changes: 2 additions & 2 deletions shaders/program/composite8.vsh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define RENDER_VERTEX
#define RENDER_COMPOSITE
#define RENDER_COMPOSITE_BLOOM_BLUR
//#define RENDER_COMPOSITE_BLOOM_BLUR_V
#define RENDER_COMPOSITE
#define RENDER_VERTEX

#include "/lib/constants.glsl"
#include "/lib/common.glsl"
Expand Down
12 changes: 1 addition & 11 deletions shaders/program/deferred5.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -409,17 +409,7 @@ void main() {

if (lightData.opaqueScreenDepth >= 1.0) {
if (blindness > EPSILON) {
color = vec3(0.0);//GetAreaFogColor();
// color = GetVanillaSkyLuminance(viewDir);
// float horizonFogF = 1.0 - abs(localViewDir.y);

// vec2 scatteringF = GetVanillaSkyScattering(viewDir, lightData.skyLightLevels);
// vec3 vlColor = RGBToLinear(fogColor) * (scatteringF.x * sunColorFinalEye + scatteringF.y * moonColorFinalEye);
// color += vlColor * (1.0 - horizonFogF);

// vec3 starF = GetStarLight(normalize(localViewDir));
// starF *= 1.0 - horizonFogF;
// color += starF * StarLumen;
color = vec3(0.0);
}
else {
#ifdef SKY_ENABLED
Expand Down
1 change: 1 addition & 0 deletions shaders/program/shadow.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ void main() {
#if MATERIAL_FORMAT == MATERIAL_FORMAT_DEFAULT
//sss = gMaterialSSS;
ApplyHardCodedMaterials(material, gBlockId);
//if (entityId == MATERIAL_PHYSICS_SNOW) material.scattering = 0.9;
#else
float specularMapB = textureGrad(specular, gTexcoord, dFdXY[0], dFdXY[1]).b;
material.scattering = GetLabPbr_SSS(specularMapB);
Expand Down
22 changes: 3 additions & 19 deletions shaders/program/shadow.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -105,27 +105,11 @@ uniform float far;

void main() {
vBlockId = -1;

if (renderStage == MC_RENDER_STAGE_ENTITIES) {
//blockId = -1;
//vEntityId = entityId;

// if (entityId == MATERIAL_LIGHTNING_BOLT) {
// gl_Position = vec4(10.0);
// return;
// }
}
else {
if (renderStage != MC_RENDER_STAGE_ENTITIES)
vBlockId = int(mc_Entity.x + 0.5);
//vEntityId = -1;

// #ifdef SHADOW_EXCLUDE_FOLIAGE
// if (vBlockId >= 10000 && vBlockId <= 10004) {
// gl_Position = vec4(10.0);
// return;
// }
// #endif
}
if (entityId == MATERIAL_PHYSICS_SNOW)
vBlockId = MATERIAL_PHYSICS_SNOW;

vLocalPos = gl_Vertex.xyz;
vTexcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
Expand Down
7 changes: 4 additions & 3 deletions shaders/shaders.properties
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,19 @@ screen.EFFECT_OPTIONS=[EFFECT_AO_OPTIONS] [EFFECT_RSM_OPTIONS] [EFFECT_BLOOM_OPT
screen.EFFECT_BLOOM_OPTIONS=BLOOM_ENABLED BLOOM_STRENGTH BLOOM_SMOOTH BLOOM_POWER <empty> BLOOM_THRESHOLD
screen.EFFECT_RSM_OPTIONS=RSM_ENABLED RSM_SCALE RSM_FILTER_SIZE RSM_INTENSITY RSM_SAMPLE_COUNT RSM_UPSCALE
screen.EFFECT_AO_OPTIONS=AO_TYPE SSAO_INTENSITY SSAO_RADIUS SSAO_SAMPLES
screen.EFFECT_DOF_OPTIONS=DOF_ENABLED DOF_SCALE
screen.EFFECT_DOF_OPTIONS=DOF_ENABLED DOF_SCALE DOF_STEP_SIZE DOF_MAX_SIZE
screen.DEBUG_OPTIONS=DEBUG_VIEW DEBUG_EXPOSURE_METERS <empty> <empty>

sliders=DEBUG_VIEW sunPathRotation shadowMapResolution shadowDistance CLOUD_LEVEL DOF_SCALE \
sliders=DEBUG_VIEW sunPathRotation shadowMapResolution shadowDistance CLOUD_LEVEL \
CAMERA_EXPOSURE CAMERA_BRIGHTNESS CAMERA_SATURATION \
BLOCKLIGHT_TEMP DIRECTIONAL_LIGHTMAP_STRENGTH WEATHER_OPACITY \
SHADOW_BIAS_SCALE SHADOW_DISTORT_FACTOR SHADOW_BRIGHTNESS SHADOW_PCF_SIZE SHADOW_PCF_SAMPLES \
SSS_STRENGTH SSS_PCF_SIZE SSS_PCF_SAMPLES SSS_MAXDIST \
PARALLAX_DEPTH PARALLAX_SAMPLES PARALLAX_SHADOW_SAMPLES \
RSM_FILTER_SIZE RSM_INTENSITY RSM_SAMPLE_COUNT BLOOM_STRENGTH BLOOM_POWER BLOOM_THRESHOLD \
VL_STRENGTH VL_SAMPLES_SKY VL_SAMPLES_WATER VL_FOG_MIN \
SSAO_INTENSITY SSAO_RADIUS SSAO_SAMPLES REFRACTION_STRENGTH WATER_WAVE_DEPTH
SSAO_INTENSITY SSAO_RADIUS SSAO_SAMPLES REFRACTION_STRENGTH WATER_WAVE_DEPTH \
DOF_SCALE DOF_STEP_SIZE DOF_MAX_SIZE

iris.features.optional=SEPARATE_HARDWARE_SAMPLERS
iris.features.optional=COMPUTE_SHADERS
Expand Down

0 comments on commit 3a5e2b1

Please sign in to comment.