Integrated various graphical tweaks.
parent
cceb5d4cb1
commit
4ad8748726
|
@ -0,0 +1,2 @@
|
|||
call gradlew.bat cleanIdea idea
|
||||
pause
|
|
@ -37,14 +37,14 @@ public class LightComponent implements Component {
|
|||
public Vector3f lightColorAmbient = new Vector3f(1.0f, 1.0f, 1.0f);
|
||||
|
||||
@Replicate
|
||||
public float lightDiffuseIntensity = 2.0f;
|
||||
public float lightDiffuseIntensity = 1.0f;
|
||||
@Replicate
|
||||
public float lightSpecularIntensity = 0.1f;
|
||||
@Replicate
|
||||
public float lightAmbientIntensity = 1.0f;
|
||||
|
||||
@Replicate
|
||||
public float lightSpecularPower = 4.0f;
|
||||
public float lightSpecularPower = 1.0f;
|
||||
@Replicate
|
||||
public float lightAttenuationRange = 16.0f;
|
||||
@Replicate
|
||||
|
|
|
@ -147,7 +147,7 @@ public class DefaultRenderingProcess {
|
|||
@EditorRange(min = 0.0f, max = 10.0f)
|
||||
private float hdrMaxExposure = 8.0f;
|
||||
@EditorRange(min = 0.0f, max = 10.0f)
|
||||
private float hdrMaxExposureNight = 1.0f;
|
||||
private float hdrMaxExposureNight = 8.0f;
|
||||
@EditorRange(min = 0.0f, max = 10.0f)
|
||||
private float hdrMinExposure = 1.0f;
|
||||
@EditorRange(min = 0.0f, max = 4.0f)
|
||||
|
|
|
@ -66,7 +66,7 @@ public class ShaderParametersChunk extends ShaderParametersBase {
|
|||
float waterOffsetY = 0.0f;
|
||||
|
||||
@EditorRange(min = 0.0f, max = 1024.0f)
|
||||
float waterSpecExp = 512.0f;
|
||||
float waterSpecExp = 200.0f;
|
||||
|
||||
@EditorRange(min = 0.0f, max = 0.5f)
|
||||
float parallaxBias = 0.05f;
|
||||
|
|
|
@ -210,8 +210,8 @@ public final class WorldRenderer {
|
|||
mainDirectionalLight.lightType = LightComponent.LightType.DIRECTIONAL;
|
||||
mainDirectionalLight.lightColorAmbient = new Vector3f(1.0f, 1.0f, 1.0f);
|
||||
mainDirectionalLight.lightColorDiffuse = new Vector3f(1.0f, 1.0f, 1.0f);
|
||||
mainDirectionalLight.lightAmbientIntensity = 2.0f;
|
||||
mainDirectionalLight.lightDiffuseIntensity = 1.0f;
|
||||
mainDirectionalLight.lightAmbientIntensity = 1.0f;
|
||||
mainDirectionalLight.lightDiffuseIntensity = 2.0f;
|
||||
mainDirectionalLight.lightSpecularIntensity = 0.0f;
|
||||
|
||||
localPlayerSystem.setPlayerCamera(localPlayerCamera);
|
||||
|
@ -734,6 +734,8 @@ public final class WorldRenderer {
|
|||
|
||||
// Sunlight
|
||||
Vector3f sunlightWorldPosition = new Vector3f(skysphere.getSunDirection(true));
|
||||
sunlightWorldPosition.scale(50000f);
|
||||
sunlightWorldPosition.add(activeCamera.getPosition());
|
||||
renderLightComponent(mainDirectionalLight, sunlightWorldPosition, program, camera, false);
|
||||
|
||||
DefaultRenderingProcess.getInstance().endRenderDirectionalLights();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#define WATER_COLOR_SWIMMING 0.8, 1.0, 1.0, 0.975
|
||||
#define WATER_TINT 0.1, 0.41, 0.627, 1.0
|
||||
#define WATER_SPEC 2.0
|
||||
#define WATER_SPEC 1.0
|
||||
|
||||
#ifdef FEATURE_REFRACTIVE_PASS
|
||||
varying vec3 waterNormalViewSpace;
|
||||
|
@ -236,7 +236,8 @@ void main() {
|
|||
// Apply reflection and refraction AFTER the lighting has been applied (otherwise bright areas below water become dark)
|
||||
// The water tint has still to be adjusted adjusted though...
|
||||
if (isWater && isOceanWater) {
|
||||
color.xyz += calcSpecLight(normalWater, sunVecViewAdjusted, normalizedVPos, waterSpecExp) * WATER_SPEC;
|
||||
float specularHighlight = WATER_SPEC * calcDayAndNightLightingFactor(daylightValue, daylight) * calcSpecLightNormalized(normalWater, sunVecViewAdjusted, normalizedVPos, waterSpecExp);
|
||||
color.xyz += vec3(specularHighlight, specularHighlight, specularHighlight);
|
||||
|
||||
vec4 reflectionColor = vec4(texture2D(textureWaterReflection, projectedPos + normalWaterOffset.xy * waterRefraction).xyz, 1.0);
|
||||
vec4 refractionColor = vec4(texture2D(texSceneOpaque, projectedPos + normalWaterOffset.xy * waterRefraction).xyz, 1.0);
|
||||
|
|
|
@ -153,8 +153,8 @@ void main()
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_REFRACTIVE_PASS
|
||||
# ifdef ANIMATED_WATER
|
||||
#if defined (FEATURE_REFRACTIVE_PASS)
|
||||
# if defined (ANIMATED_WATER)
|
||||
if (checkFlag(BLOCK_HINT_WATER, blockHint)) {
|
||||
// Only animate blocks on sea level
|
||||
if (vertexWorldPos.y < 32.5 && vertexWorldPos.y > 31.5) {
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
|
||||
varying vec4 vertexProjPos;
|
||||
varying vec3 eyeVec;
|
||||
|
||||
uniform vec3 lightViewPos;
|
||||
|
||||
|
@ -42,7 +41,7 @@ uniform mat4 invProjMatrix;
|
|||
uniform sampler2D texSceneClouds;
|
||||
# endif
|
||||
|
||||
#define SHADOW_MAP_BIAS 0.003
|
||||
#define SHADOW_MAP_BIAS 0.01
|
||||
|
||||
uniform sampler2D texSceneShadowMap;
|
||||
uniform mat4 lightViewProjMatrix;
|
||||
|
@ -99,16 +98,26 @@ void main() {
|
|||
// TODO: Costly - would be nice to use Crytek's view frustum ray method at this point
|
||||
vec3 viewSpacePos = reconstructViewPos(depth, projectedPos, invProjMatrix);
|
||||
|
||||
vec3 lightDir = lightViewPos.xyz - viewSpacePos;
|
||||
vec3 lightDir;
|
||||
#if defined (FEATURE_LIGHT_POINT)
|
||||
lightDir = lightViewPos.xyz - viewSpacePos;
|
||||
#else if defined (FEATURE_LIGHT_DIRECTIONAL)
|
||||
lightDir = lightViewPos.xyz;
|
||||
#endif
|
||||
|
||||
vec3 eyeVec = -normalize(viewSpacePos.xyz).xyz;
|
||||
|
||||
float lightDist = length(lightDir);
|
||||
vec3 lightDirNorm = lightDir / lightDist;
|
||||
|
||||
float ambTerm = lightAmbientIntensity;
|
||||
float lambTerm = calcLambLight(normal, lightDirNorm);
|
||||
float specTerm = calcSpecLight(normal, lightDirNorm, eyeVec, lightSpecularPower);
|
||||
float specTerm = calcSpecLightNormalized(normal, lightDirNorm, eyeVec, lightSpecularPower);
|
||||
|
||||
#if defined (DYNAMIC_SHADOWS) && defined (FEATURE_LIGHT_DIRECTIONAL)
|
||||
lambTerm *= shadowTerm;
|
||||
specTerm *= shadowTerm;
|
||||
|
||||
ambTerm *= clamp(shadowTerm, 0.25, 1.0);
|
||||
#endif
|
||||
|
||||
|
@ -120,7 +129,7 @@ void main() {
|
|||
#elif defined (FEATURE_LIGHT_DIRECTIONAL)
|
||||
vec3 color = calcSunlightColorDeferred(normalBuffer.a, lambTerm, ambTerm, lightDiffuseIntensity, lightColorAmbient, lightColorDiffuse);
|
||||
#else
|
||||
vec3 color = vec3(0.0);
|
||||
vec3 color = vec3(1.0, 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
#if defined (FEATURE_LIGHT_POINT)
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
|
||||
varying vec4 vertexProjPos;
|
||||
varying vec3 eyeVec;
|
||||
|
||||
uniform mat4 modelMatrix;
|
||||
uniform mat4 viewMatrix;
|
||||
|
@ -30,8 +29,6 @@ void main()
|
|||
vertexProjPos = gl_Vertex;
|
||||
#endif
|
||||
|
||||
eyeVec = -normalize(viewMatrix * gl_Vertex).xyz;
|
||||
|
||||
gl_Position = vertexProjPos;
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_FrontColor = gl_Color;
|
||||
|
|
|
@ -22,15 +22,17 @@
|
|||
#define DAYLIGHT_AMBIENT_COLOR 1.0, 0.9, 0.9
|
||||
#define MOONLIGHT_AMBIENT_COLOR 0.5, 0.5, 1.0
|
||||
|
||||
#define NIGHT_BRIGHTNESS 0.1
|
||||
#define NIGHT_BRIGHTNESS 0.125
|
||||
|
||||
#define WATER_AMB 1.0
|
||||
#define WATER_DIFF 0.75
|
||||
#define WATER_DIFF 2.0
|
||||
|
||||
#define BLOCK_AMB 1.0
|
||||
#define BLOCK_DIFF 2.0
|
||||
|
||||
#define BLOCK_DIFF 0.75
|
||||
#define BLOCK_AMB 2.0
|
||||
|
||||
#define EPSILON 0.000001
|
||||
#define PI 3.14159265359
|
||||
|
||||
#define A 0.15
|
||||
#define B 0.50
|
||||
|
|
|
@ -45,6 +45,13 @@ float calcSpecLight(vec3 normal, vec3 lightVec, vec3 eyeVec, float exp) {
|
|||
return pow(clamp(dot(halfWay, normal), 0.0, 1.0), exp);
|
||||
}
|
||||
|
||||
float calcSpecLightNormalized(vec3 normal, vec3 lightVec, vec3 eyeVec, float exp) {
|
||||
const float PI_TIMES_8 = 8.0 * PI;
|
||||
|
||||
vec3 halfWay = normalize(eyeVec+lightVec);
|
||||
return clamp(((exp + 8.0) / PI_TIMES_8) * pow(dot(halfWay, normal), exp), 0.0, 1.0);
|
||||
}
|
||||
|
||||
vec4 linearToSrgb(vec4 color) {
|
||||
return vec4(sqrt(color.rgb), color.a);
|
||||
}
|
||||
|
@ -167,15 +174,19 @@ vec3 calcBlocklightColor(float blocklightValue
|
|||
return vec3(blockBrightness) * vec3(1.0, 0.95, 0.94);
|
||||
}
|
||||
|
||||
vec3 calcSunlightColorDeferred(float daylightValue, float diffuseLighting, float ambientIntensity, float diffuseIntensity, vec3 ambientColor, vec3 diffuseColor) {
|
||||
float calcDayAndNightLightingFactor(float daylightValue, float daylight) {
|
||||
float daylightScaledValue = daylight * daylightValue;
|
||||
return expLightValue(daylightScaledValue) + (NIGHT_BRIGHTNESS * (1.0 - daylight) * expLightValue(daylightValue));
|
||||
}
|
||||
|
||||
vec3 calcSunlightColorDeferred(float daylightValue, float diffuseLighting, float ambientIntensity, float diffuseIntensity, vec3 ambientColor, vec3 diffuseColor) {
|
||||
vec3 daylightColorValue = vec3(ambientIntensity) + diffuseLighting * diffuseIntensity * diffuseColor;
|
||||
|
||||
vec3 ambientTint = mix(vec3(MOONLIGHT_AMBIENT_COLOR), vec3(DAYLIGHT_AMBIENT_COLOR), daylight) * ambientColor;
|
||||
daylightColorValue.xyz *= ambientTint;
|
||||
|
||||
// Scale the lighting according to the daylight and daylight block values and add moonlight during the nights
|
||||
daylightColorValue.xyz *= expLightValue(daylightScaledValue) + (NIGHT_BRIGHTNESS * (1.0 - daylight) * expLightValue(daylightValue));
|
||||
daylightColorValue.xyz *= calcDayAndNightLightingFactor(daylightValue, daylight);
|
||||
|
||||
return daylightColorValue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue