You are on page 1of 19

SEUS SHADERS 10.

1 EDITS:
(with the help from the SEUS FB Community too)

IN ORDER TO GET PARALLAX WATER TO WORK DO THE


FOLLOWING:

GO INTO GBUFFERS_WATER.FSH :

EDIT LINE #3:


#define WAVE_HEIGHT 0.1f
to
#define WAVE_HEIGHT 0.4f

EDIT LINE #139:


//position = GetWaterParallaxCoord(position, viewVector);
to
position = GetWaterParallaxCoord(position, viewVector);
(this is for smoother textured water)

EDIT LINE #293 & #294:


wavesNormal.r *= 30.0f * WAVE_HEIGHT / sampleDistance;
wavesNormal.g *= 30.0f * WAVE_HEIGHT / sampleDistance;
(change the numbers to anything you want)

EDIT LINE #280:


//position = GetWaterParallaxCoord(position, viewVector);
to
position = GetWaterParallaxCoord(position, viewVector);
(enables the changing of waves height for #define WAVE_HEIGHT)

TO GET DOF BACK DO THE FOLLOWING:


GO INTO FINAL.FSH :

EDIT LINE #212:


vec2 dofblur = vec2(factor * bias)*0.6;
to
vec2 dofblur = vec2(factor * bias)*2.1;

EDIT LINE #758:


//DepthOfField(color);
to
DepthOfField(color);

TO TEMPERARLY FIX THE LIGHT BUG WITH LIGHT SOURCES


NEAR WATER:

GO INTO COMPOSITE1_FSH :

EDIT LINE #1088:


surface.fresnelPower = 6.0f;
to
surface.fresnelPower = 2.0f;

TO CHANGE HDR SETTINGS:


GO INTO COMPOSITE.FSH :

EDIT LINE #2259:


finalComposite *= 0.001f;
to
finalComposite *= 0.002f;
(you can change it upto 0.005 for same setting as N1 shader)

TO GET BACK VOLUMETRIC 3D


CLOUDS:
(shadowresmulti must be set to 2.000 in shaders menu in game to stop pixelation)

GO INTO COMPOSITE1.FSH :

EDIT LINE #18:


//#define SMOOTH_SKY
to
#define SMOOTH_SKY

EDIT LINE #22 & #23:


const bool gcolorMipmapEnabled = false;
const bool compositeMipmapEnabled = false;
to
const bool gcolorMipmapEnabled = true;
const bool compositeMipmapEnabled = true;

EDIT LINE #1323:


CloudPlane(surface);
to
//CloudPlane(surface);

EDIT LINE #1049:


ReflectedCloudPlane(color.rgb, surface);
to
//ReflectedCloudPlane(color.rgb, surface);

OPEN COMPOSITE.FSH :
COPY & REPLACE THE FOLLOWING CODE IN LINE #1416 UNTILL LINE #1631 :
vec4 CloudColor(in vec4 worldPosition, in float sunglow, in vec3 worldLightVector)

float cloudHeight = 230.0f;


float cloudDepth = 85.0f;
float cloudUpperHeight = cloudHeight + (cloudDepth / 2.0f);
float cloudLowerHeight = cloudHeight - (cloudDepth / 2.0f);

if (worldPosition.y < cloudLowerHeight || worldPosition.y > cloudUpperHeight)


return vec4(0.0f);
else
{

vec3 p = worldPosition.xyz / 150.0f;

float t = frameTimeCounter * 1.0f;


//t *= 0.001;
p.x -= t * 0.01f;

// p += (Get3DNoise(p * 1.0f + vec3(0.0f, t * 0.01f, 0.0f)) * 2.0f - 1.0f) *


0.3f;

vec3 p1 = p * vec3(1.0f, 0.5f, 1.0f) + vec3(0.0f, t * 0.01f, 0.0f);


float noise = Get3DNoise(p * vec3(1.0f, 0.5f, 1.0f) + vec3(0.0f, t * 0.01f,
0.0f)); p *= 3.0f;
p.x -= t * 0.057f;
vec3 p2 = p;
noise += (1.0f - abs(Get3DNoise(p) * 1.0f - 0.5f)) * 0.2f;

p *= 3.0f;

p.xz -= t * 0.035f;

vec3 p3 = p;

noise += (1.0f - abs(Get3DNoise(p) * 3.0f - 1.0f)) * 0.045f;


p *= 3.0f;
p.xz -= t * 0.035f;
noise += (1.0f - abs(Get3DNoise(p) * 3.0f - 1.0f)) * 0.015f;
noise /= 1.475f;

const float lightOffset = 0.45f;

float heightGradient = clamp(( - (cloudLowerHeight - worldPosition.y) /


(cloudDepth * 1.0f)), 0.0f, 1.0f);
float heightGradient2 = clamp(( - (cloudLowerHeight - (worldPosition.y +
worldLightVector.y * lightOffset * 30.0f)) / (cloudDepth * 1.0f)), 0.0f, 1.0f);

float cloudAltitudeWeight = 1.0f - clamp(distance(worldPosition.y,


cloudHeight) / (cloudDepth / 2.0f), 0.0f, 1.0f);
cloudAltitudeWeight = pow(cloudAltitudeWeight, mix(0.2f, 0.6f,
rainStrength));
cloudAltitudeWeight *= 1.0f - heightGradient;

float cloudAltitudeWeight2 = 1.0f - clamp(distance(worldPosition.y +


worldLightVector.y * lightOffset * 30.0f, cloudHeight) / (cloudDepth / 2.0f), 0.0f, 1.0f);
cloudAltitudeWeight2 = pow(cloudAltitudeWeight2, mix(0.2f, 0.6f,
rainStrength));
cloudAltitudeWeight2 *= 1.0f - heightGradient2;

noise *= cloudAltitudeWeight;

//cloud edge
float coverage = 0.695f;
coverage = mix(coverage, 1.05f, rainStrength);
float density = 0.77f;
noise = clamp(noise - (1.0f - coverage), 0.0f, 1.0f - density) / (1.0f density);
//noise = GetCoverage(coverage, density, noise);

//float sunProximity = pow(sunglow, 1.0f);


//float propigation = mix(15.0f, 9.0f, sunProximity);

// float directLightFalloff = pow(heightGradient, propigation);


//

directLightFalloff += pow(heightGradient, propigation / 2.0f);

//

directLightFalloff /= 2.0f;

//float sundiff = -Get3DNoise(p1 + worldLightVector.xyz * lightOffset) *


cloudAltitudeWeight2;
//sundiff += -(1.0f - abs(Get3DNoise(p2 + worldLightVector.xyz *
lightOffset) * 1.0f - 0.5f)) * 0.4f * cloudAltitudeWeight2;
//sundiff += -(1.0f - abs(Get3DNoise(p3 + worldLightVector.xyz *
lightOffset) * 3.0f - 1.0f)) * 0.035f * cloudAltitudeWeight2;

float sundiff = Get3DNoise(p1 + worldLightVector.xyz * lightOffset);


sundiff += (1.0f - abs(Get3DNoise(p2 + worldLightVector.xyz *
lightOffset) * 1.0f - 0.5f)) * 0.4f;
sundiff *= 1.1f;
sundiff *= cloudAltitudeWeight2;
//sundiff += (1.0f - abs(Get3DNoise(p3 + worldLightVector.xyz *
lightOffset) * 3.0f - 1.0f)) * 0.075f * cloudAltitudeWeight2;
sundiff = -GetCoverage(coverage * 1.0f, 0.0f, sundiff);
float firstOrder

= pow(clamp(sundiff * 1.0f + 1.15f, 0.0f, 1.0f),

56.0f);
//firstOrder
float secondOrder

*= pow(clamp(1.3f - noise, 0.0f, 1.0f), 12.0f);


= pow(clamp(sundiff * 1.0f + 1.1f, 0.0f, 1.0f), 11.0f);

//directLightFalloff *= mix(
1.0f), clamp(pow(1.0f - noise, 10.3f), 0.0f, 0.5f),

clamp(pow(noise, 1.2f) * 1.0f, 0.0f,


pow(sunglow, 1.2f));

float directLightFalloff = mix(firstOrder, secondOrder, 0.5f);


//float directLightFalloff = firstOrder;
float anisoBackFactor = mix(clamp(pow(noise, 1.6f) * 2.5f, 0.0f, 1.0f), 1.0f,
pow(sunglow, 1.0f));

directLightFalloff *= anisoBackFactor;
directLightFalloff *= mix(11.5f, 1.0f, pow(sunglow, 0.5f));

vec3 colorDirect = colorSunlight * 0.55f;


colorDirect = mix(colorDirect, colorDirect * vec3(0.2f, 0.5f, 1.0f),
timeMidnight);
//colorDirect *= 1.0f + pow(sunglow, 10.0f) * 0.0f * pow(directLightFalloff,
1.0f);
colorDirect *= 1.0f + pow(sunglow, 2.0f) * 100.0f * pow(directLightFalloff,
1.1f) * (1.0f - rainStrength);
//colorDirect *= mix(1.0f, (clamp(pow(1.1f - noise, 50.09f) * 1.0f, 0.0f,
1.0f)) * 5.0f + 1.0f, pow(sunglow, 1.5f));

vec3 colorAmbient = mix(colorSkylight, colorSunlight * 2.0f,


vec3(heightGradient * 0.0f)) * 0.03f;
//colorAmbient *= vec3(0.5f, 0.7f, 1.0f);
colorAmbient *= mix(1.0f, 0.3f, timeMidnight);
colorAmbient = mix(colorAmbient, colorAmbient * 3.0f +
colorSunlight * 0.05f, vec3(clamp(pow(1.0f - noise, 12.0f) * 1.0f, 0.0f, 1.0f)));
colorAmbient *= heightGradient * heightGradient + 0.1f;

vec3 colorBounced = colorBouncedSunlight * 0.1f;


colorBounced *= pow((1.0f - heightGradient), 8.0f);

directLightFalloff *= 1.0f - rainStrength * 0.7f;

// //cloud shadows

// vec4 shadowPosition = shadowModelView * (worldPosition vec4(cameraPosition, 0.0f));


// shadowPosition = shadowProjection * shadowPosition;
// shadowPosition /= shadowPosition.w;

// float dist = sqrt(shadowPosition.x * shadowPosition.x +


shadowPosition.y * shadowPosition.y);
// float distortFactor = (1.0f - SHADOW_MAP_BIAS) + dist *
SHADOW_MAP_BIAS;
// shadowPosition.xy *= 1.0f / distortFactor;
// shadowPosition = shadowPosition * 0.5f + 0.5f;

// float sunlightVisibility = shadow2D(shadow, vec3(shadowPosition.st,


shadowPosition.z)).x;
// directLightFalloff *= sunlightVisibility;

vec3 color = mix(colorAmbient, colorDirect, vec3(min(1.0f,


directLightFalloff)));
//color += colorBounced;
//color = colorAmbient;
//color = colorDirect * directLightFalloff;
//color *= clamp(pow(noise, 0.1f), 0.0f, 1.0f);

color *= 1.0f;

//color *= mix(1.0f, 0.4f, timeMidnight);

vec4 result = vec4(color.rgb, noise);

return result;
}
}

void

CalculateClouds (inout vec3 color, inout SurfaceStruct surface)

{
//if (texcoord.s < 0.5f && texcoord.t < 0.5f)
//{
surface.cloudAlpha = 0.0f;

vec2 coord = texcoord.st * 2.0f;

vec4 worldPosition = gbufferModelViewInverse *


surface.screenSpacePosition;
worldPosition.xyz += cameraPosition.xyz;

float cloudHeight = 150.0f;


float cloudDepth = 60.0f;
float cloudDensity = 1.0f;

float startingRayDepth = far - 5.0f;

float rayDepth = startingRayDepth;


//rayDepth += CalculateDitherPattern1() * 0.09f;
//rayDepth += texture2D(noisetex, texcoord.st * (viewWidth /
noiseTextureResolution, viewHeight / noiseTextureResolution)).x * 0.1f;

//rayDepth += CalculateDitherPattern2() * 0.1f;


float rayIncrement = far / 10.0f;

rayDepth += CalculateDitherPattern1() * rayIncrement;

int i = 0;

vec3 cloudColor = colorSunlight;


vec4 cloudSum = vec4(0.0f);
cloudSum.rgb = colorSkylight * 0.2f;
cloudSum.rgb = color.rgb;

float sunglow = CalculateSunglow(surface);

float cloudDistanceMult = 400.0f / far;

float surfaceDistance = length(worldPosition.xyz - cameraPosition.xyz);

while (rayDepth > 0.0f)


{
//determine worldspace ray position
vec4 rayPosition = GetCloudSpacePosition(texcoord.st, rayDepth,
cloudDistanceMult);

float rayDistance = length((rayPosition.xyz - cameraPosition.xyz) /


cloudDistanceMult);

vec4 proximity = CloudColor(rayPosition, sunglow,


surface.worldLightVector);
proximity.a *= cloudDensity;

//proximity.a *= clamp(surfaceDistance - rayDistance,


0.0f, 1.0f);
if (surfaceDistance < rayDistance * cloudDistanceMult
&& !surface.mask.sky)
proximity.a = 0.0f;

//cloudSum.rgb = mix( cloudSum.rgb, proximity.rgb, vec3(min(1.0f,


proximity.a * cloudDensity)) );
//cloudSum.a += proximity.a * cloudDensity;
color.rgb = mix(color.rgb, proximity.rgb, vec3(min(1.0f, proximity.a
* cloudDensity)));

surface.cloudAlpha += proximity.a;

//Increment ray
rayDepth -= rayIncrement;
i++;

// if (rayDepth * cloudDistanceMult < ((cloudHeight - (cloudDepth


* 0.5)) - cameraPosition.y))
// {
//
// }
}

break;

//color.rgb = mix(color.rgb, cloudSum.rgb, vec3(min(1.0f, cloudSum.a *


20.0f)));
//color.rgb = cloudSum.rgb;

IMPROVE LIGHTING WHEN SUN IS BEHIND


CLOUDS:

OPEN COMPISITE.FSH:

EDIT LINE #1940

cloudShadow = 1.0f - cloudShadow;


to
cloudShadow = 1.5f - cloudShadow;

CHANGING FOG WHEN IT RAINS:


OPEN FINAL.FSH

EDIT LINE #621:

float fogDensity = 0.013* (rainStrength);


to
float fogDensity = 0.066f * (rainStrength);

CHANGING HDR FOR INDOORS SATURATION


BRIGHTNESS:
OPEN COMPOSITE.FSH:

EDIT LINE #2204:


//Do night eye effect on outdoor lighting and sky
// DoNightEye(final.sunlight);
// DoNightEye(final.skylight);
// DoNightEye(final.bouncedSunlight);
// DoNightEye(final.scatteredSunlight);
// DoNightEye(surface.sky.albedo);
// DoNightEye(final.underwater);

// DoLowlightEye(final.nolight);

to

//Do night eye effect on outdoor lighting and sky

DoNightEye(final.sunlight);
DoNightEye(final.skylight);
DoNightEye(final.bouncedSunlight);
DoNightEye(final.scatteredSunlight);
DoNightEye(surface.sky.albedo);
DoNightEye(final.underwater);

DoLowlightEye(final.nolight);

THEN OPEN FINAL.FSH:

EDIT LINE #526:

const float

bloomSlant = 0.25f;

to
const float

bloomSlant = 0.00f;

TO MAKE TORCHES
BRIGHTER:
GO INTO COMPOSITE.FSH

EDIT LINE #2199

final.torchlight *= 1.0f - float(surface.mask.lava);


to
final.torchlight *= 4.0f - float(surface.mask.lava);

TO MAKE GLOWSTONE
BRIGHTER:
GO INTO COMPOSITE:FSH

EDIT LINE #2226

+ final.glow.glowstone

* 1.1f

to
+ final.glow.glowstone

* 8.1f

TO GET RID OF THE WETNESS PARALLAX BUMP


FOR TEXTURES:
GO INTO GBUFFERS_TERRAIN.FSH :

EDIT LINE #345:


float wetAngle = dot(worldNormal, vec3(0.0f, 1.0f, 0.0f)) * 0.5f + 0.5f;
to
float wetAngle = dot(worldNormal, vec3(0.0f, 0.0f, 0.0f)) * 0.0f + 0.0f;

EDIT LINE #354:


spec.g += max(0.0f, clamp((wet * 1.0f + 0.2f), 0.0f, 1.0f) - (1.0f - w) * 1.0f);
to
spec.g += max(0.0f, clamp((wet * 0.0f + 0.0f), 0.0f, 0.0f) - (0.0f - w) * 0.0f);

EDIT LINE #355:


float wetfactor = clamp(lightmap.b * 1.05f - 0.9f, 0.0f, 0.1f) / 0.1f;
to
float wetfactor = clamp(lightmap.b * 0.00f - 0.0f, 0.0f, 0.0f) / 0.0f;

TO FIX SHADER INVALID PROGRAM


COMPOSITE
GO INTO COMPOSITE.VSH

SEARCH FOR: float timePow = 2.0f;


to
float timePow = 3.0f;

RAIN FIX FOR RAINING ON WALLS INSIDE


BUILDINGS:
GO INTO GBUFFERS_WEATHER.VSH

GO TO LINE #9:
DELETE: gl_Position.z = 0.0f;

You might also like