LOTS of fixes, changes, improvements. changes made is bloated because of a skill issue.

FIXED AND IMPROVED translucent rendering. FIXED random stuff from rendering over the hand. FIXED hand shading. FIXED blue horses. FIXED translucent lighting on the hand. FIXED translucent lighting on entities. IMPROVED colored shadows. IMPROVED SSAO application to the scene. IMPROVED subsurface scattering and give it more settings. IMPROVED bloom. ADD AgX tonemap and make it default.
This commit is contained in:
Xonk
2024-05-04 21:08:24 -04:00
parent 343a68c816
commit 25a2284a60
70 changed files with 4096 additions and 1510 deletions

View File

@ -1,5 +1,5 @@
const float k = 1.8;
const float d0 = 0.04;
const float d0 = 0.04 + max(64.0 - shadowDistance, 0.0)/64.0 * 0.26;
const float d1 = 0.61;
float a = exp(d0);
float b = (exp(d1)-a)*150./128.0;

View File

@ -8,8 +8,19 @@ void GriAndEminShadowFix(
float SkyLightmap
){
float minvalue = 0.007;
#ifdef DISTANT_HORIZONS_SHADOWMAP
minvalue = 0.035;
#endif
// float DistanceOffset = clamp(0.17 + length(WorldPos) / (shadowMapResolution*0.20), 0.0,1.0) ;
float DistanceOffset = clamp(0.17 + length(WorldPos) / (shadowMapResolution*0.20), 0.0,1.0) ;
// float DistanceOffset = clamp(0.17 + length(WorldPos) / (shadowMapResolution*0.20), 0.0,1.0) ;
float shadowResScale = (2048.0/shadowMapResolution) / 4.0;
float DistanceOffset = (length(WorldPos)+4.0) * (minvalue + shadowResScale*0.015);
vec3 Bias = FlatNormal * DistanceOffset; // adjust the bias thingy's strength as it gets farther away.
vec3 finalBias = Bias;

205
shaders/lib/blocks.glsl Normal file
View File

@ -0,0 +1,205 @@
#define BLOCK_WATER 8
#define BLOCK_BAMBOO 11
#define BLOCK_GRASS_SHORT 12
#define BLOCK_GRASS_TALL_LOWER 13
#define BLOCK_GRASS_TALL_UPPER 14
#define BLOCK_SAPLING 15
#define BLOCK_VINE 16
#define BLOCK_GROUND_WAVING 60
#define BLOCK_GROUND_WAVING_VERTICAL 61
#define BLOCK_AIR_WAVING 62
#define BLOCK_SSS_STRONG 80
#define BLOCK_SSS_WEAK 81
#define BLOCK_SSS_WEAK_2 82
#define BLOCK_SSS_WEAK_3 83
#define BLOCK_SSS_WEIRD 84
#define BLOCK_GRASS 85
#define BLOCK_AMETHYST_BUD_LARGE 101
#define BLOCK_AMETHYST_BUD_MEDIUM 102
#define BLOCK_AMETHYST_CLUSTER 103
#define BLOCK_BEACON 104
#define BLOCK_BREWING_STAND 105
#define BLOCK_CANDLES_PLAIN_LIT_1 106
#define BLOCK_CANDLES_PLAIN_LIT_2 107
#define BLOCK_CANDLES_PLAIN_LIT_3 108
#define BLOCK_CANDLES_PLAIN_LIT_4 109
#define BLOCK_CANDLES_BLACK_LIT_1 110
#define BLOCK_CANDLES_BLACK_LIT_2 111
#define BLOCK_CANDLES_BLACK_LIT_3 112
#define BLOCK_CANDLES_BLACK_LIT_4 113
#define BLOCK_CANDLES_BLUE_LIT_1 114
#define BLOCK_CANDLES_BLUE_LIT_2 115
#define BLOCK_CANDLES_BLUE_LIT_3 116
#define BLOCK_CANDLES_BLUE_LIT_4 117
#define BLOCK_CANDLES_BROWN_LIT_1 118
#define BLOCK_CANDLES_BROWN_LIT_2 119
#define BLOCK_CANDLES_BROWN_LIT_3 120
#define BLOCK_CANDLES_BROWN_LIT_4 121
#define BLOCK_CANDLES_CYAN_LIT_1 122
#define BLOCK_CANDLES_CYAN_LIT_2 123
#define BLOCK_CANDLES_CYAN_LIT_3 124
#define BLOCK_CANDLES_CYAN_LIT_4 125
#define BLOCK_CANDLES_GRAY_LIT_1 126
#define BLOCK_CANDLES_GRAY_LIT_2 127
#define BLOCK_CANDLES_GRAY_LIT_3 128
#define BLOCK_CANDLES_GRAY_LIT_4 129
#define BLOCK_CANDLES_GREEN_LIT_1 130
#define BLOCK_CANDLES_GREEN_LIT_2 131
#define BLOCK_CANDLES_GREEN_LIT_3 132
#define BLOCK_CANDLES_GREEN_LIT_4 133
#define BLOCK_CANDLES_LIGHT_BLUE_LIT_1 134
#define BLOCK_CANDLES_LIGHT_BLUE_LIT_2 135
#define BLOCK_CANDLES_LIGHT_BLUE_LIT_3 136
#define BLOCK_CANDLES_LIGHT_BLUE_LIT_4 137
#define BLOCK_CANDLES_LIGHT_GRAY_LIT_1 138
#define BLOCK_CANDLES_LIGHT_GRAY_LIT_2 139
#define BLOCK_CANDLES_LIGHT_GRAY_LIT_3 140
#define BLOCK_CANDLES_LIGHT_GRAY_LIT_4 141
#define BLOCK_CANDLES_LIME_LIT_1 142
#define BLOCK_CANDLES_LIME_LIT_2 143
#define BLOCK_CANDLES_LIME_LIT_3 144
#define BLOCK_CANDLES_LIME_LIT_4 145
#define BLOCK_CANDLES_MAGENTA_LIT_1 146
#define BLOCK_CANDLES_MAGENTA_LIT_2 147
#define BLOCK_CANDLES_MAGENTA_LIT_3 148
#define BLOCK_CANDLES_MAGENTA_LIT_4 149
#define BLOCK_CANDLES_ORANGE_LIT_1 150
#define BLOCK_CANDLES_ORANGE_LIT_2 151
#define BLOCK_CANDLES_ORANGE_LIT_3 152
#define BLOCK_CANDLES_ORANGE_LIT_4 153
#define BLOCK_CANDLES_PINK_LIT_1 154
#define BLOCK_CANDLES_PINK_LIT_2 155
#define BLOCK_CANDLES_PINK_LIT_3 156
#define BLOCK_CANDLES_PINK_LIT_4 157
#define BLOCK_CANDLES_PURPLE_LIT_1 158
#define BLOCK_CANDLES_PURPLE_LIT_2 159
#define BLOCK_CANDLES_PURPLE_LIT_3 160
#define BLOCK_CANDLES_PURPLE_LIT_4 161
#define BLOCK_CANDLES_RED_LIT_1 162
#define BLOCK_CANDLES_RED_LIT_2 163
#define BLOCK_CANDLES_RED_LIT_3 164
#define BLOCK_CANDLES_RED_LIT_4 165
#define BLOCK_CANDLES_WHITE_LIT_1 166
#define BLOCK_CANDLES_WHITE_LIT_2 167
#define BLOCK_CANDLES_WHITE_LIT_3 168
#define BLOCK_CANDLES_WHITE_LIT_4 169
#define BLOCK_CANDLES_YELLOW_LIT_1 170
#define BLOCK_CANDLES_YELLOW_LIT_2 171
#define BLOCK_CANDLES_YELLOW_LIT_3 172
#define BLOCK_CANDLES_YELLOW_LIT_4 173
#define BLOCK_CANDLES_LIT_1 174
#define BLOCK_CANDLES_LIT_2 175
#define BLOCK_CANDLES_LIT_3 176
#define BLOCK_CANDLES_LIT_4 177
#define BLOCK_CAVE_VINE_BERRIES 178
#define BLOCK_COMPARATOR_LIT 179
#define BLOCK_COPPER_BULB_LIT 180
#define BLOCK_COPPER_BULB_EXPOSED_LIT 181
#define BLOCK_COPPER_BULB_OXIDIZED_LIT 182
#define BLOCK_COPPER_BULB_WEATHERED_LIT 183
#define BLOCK_CONDUIT 184
#define BLOCK_CRYING_OBSIDIAN 185
#define BLOCK_END_GATEWAY 186
#define BLOCK_END_ROD 187
#define BLOCK_FIRE 188
#define BLOCK_FROGLIGHT_OCHRE 189
#define BLOCK_FROGLIGHT_PEARLESCENT 190
#define BLOCK_FROGLIGHT_VERDANT 191
#define BLOCK_GLOW_LICHEN 192
#define BLOCK_GLOWSTONE 193
#define BLOCK_JACK_O_LANTERN 194
#define BLOCK_LANTERN 195
#define BLOCK_LAVA 196
#define BLOCK_LIGHT_1 197
#define BLOCK_LIGHT_2 198
#define BLOCK_LIGHT_3 199
#define BLOCK_LIGHT_4 200
#define BLOCK_LIGHT_5 201
#define BLOCK_LIGHT_6 202
#define BLOCK_LIGHT_7 203
#define BLOCK_LIGHT_8 204
#define BLOCK_LIGHT_9 205
#define BLOCK_LIGHT_10 206
#define BLOCK_LIGHT_11 207
#define BLOCK_LIGHT_12 208
#define BLOCK_LIGHT_13 209
#define BLOCK_LIGHT_14 210
#define BLOCK_LIGHT_15 211
#define BLOCK_MAGMA 212
#define BLOCK_REDSTONE_LAMP_LIT 213
#define BLOCK_REDSTONE_TORCH_LIT 214
#define BLOCK_REDSTONE_WIRE_1 215
#define BLOCK_REDSTONE_WIRE_2 216
#define BLOCK_REDSTONE_WIRE_3 217
#define BLOCK_REDSTONE_WIRE_4 218
#define BLOCK_REDSTONE_WIRE_5 219
#define BLOCK_REDSTONE_WIRE_6 220
#define BLOCK_REDSTONE_WIRE_7 221
#define BLOCK_REDSTONE_WIRE_8 222
#define BLOCK_REDSTONE_WIRE_9 223
#define BLOCK_REDSTONE_WIRE_10 224
#define BLOCK_REDSTONE_WIRE_11 225
#define BLOCK_REDSTONE_WIRE_12 226
#define BLOCK_REDSTONE_WIRE_13 227
#define BLOCK_REDSTONE_WIRE_14 228
#define BLOCK_REDSTONE_WIRE_15 229
#define BLOCK_REPEATER_LIT 230
#define BLOCK_RESPAWN_ANCHOR_4 231
#define BLOCK_SCULK_SENSOR_ACTIVE 232
#define BLOCK_SEA_PICKLE_WET_1 233
#define BLOCK_SEA_PICKLE_WET_2 234
#define BLOCK_SEA_PICKLE_WET_3 235
#define BLOCK_SEA_PICKLE_WET_4 236
#define BLOCK_SEA_LANTERN 237
#define BLOCK_SHROOMLIGHT 238
#define BLOCK_SMOKER_LIT 239
#define BLOCK_SOUL_FIRE 240
#define BLOCK_SOUL_LANTERN 241
#define BLOCK_SOUL_TORCH 242
#define BLOCK_TORCH 243
#define BLOCK_GLASS 301
#define BLOCK_HONEY 302
#define BLOCK_ICE 303
#define BLOCK_NETHER_PORTAL 304
#define BLOCK_SLIME 305
#define BLOCK_GLASS_BLACK 306
#define BLOCK_GLASS_BLUE 307
#define BLOCK_GLASS_BROWN 308
#define BLOCK_GLASS_CYAN 309
#define BLOCK_GLASS_GRAY 310
#define BLOCK_GLASS_GREEN 311
#define BLOCK_GLASS_LIGHT_BLUE 312
#define BLOCK_GLASS_LIGHT_GRAY 313
#define BLOCK_GLASS_LIME 314
#define BLOCK_GLASS_MAGENTA 315
#define BLOCK_GLASS_ORANGE 316
#define BLOCK_GLASS_PINK 317
#define BLOCK_GLASS_PURPLE 318
#define BLOCK_GLASS_RED 319
#define BLOCK_GLASS_WHITE 320
#define BLOCK_GLASS_YELLOW 321
#define BLOCK_BUTTON 401
#define BLOCK_CANDLE 402
#define BLOCK_CARPET 403
#define BLOCK_CHAIN 404
#define BLOCK_DOOR_N 405
#define BLOCK_DOOR_E 406
#define BLOCK_DOOR_S 407
#define BLOCK_DOOR_W 408
#define BLOCK_FENCE 409
#define BLOCK_FENCE_GATE 410
#define BLOCK_FLOWER_POT 411
#define BLOCK_IRON_BARS 412
#define BLOCK_LADDER 413
#define BLOCK_LEVER 414
#define BLOCK_PRESSURE_PLATE 415
#define BLOCK_SLAB_TOP 416
#define BLOCK_SLAB_BOTTOM 417
#define BLOCK_TRAPDOOR_BOTTOM 418
#define BLOCK_TRAPDOOR_TOP 419
#define BLOCK_TRAPDOOR_N 420
#define BLOCK_TRAPDOOR_E 421
#define BLOCK_TRAPDOOR_S 422
#define BLOCK_TRAPDOOR_W 423
#define BLOCK_END_PORTAL 500
#define BLOCK_SIGN 501

View File

@ -32,7 +32,7 @@
SpringCol *= glcolor;
// do leaf colors different because thats cool and i like it
if(mc_Entity.x == 10003){
if(mc_Entity.x == BLOCK_AIR_WAVING){
SummerCol = vec3(Summer_Leaf_R, Summer_Leaf_G, Summer_Leaf_B);
AutumnCol = vec3(Fall_Leaf_R, Fall_Leaf_G, Fall_Leaf_B);
WinterCol = vec3(Winter_Leaf_R, Winter_Leaf_G, Winter_Leaf_B);

View File

@ -180,4 +180,96 @@ vec3 Full_Reinhard_Edit(vec3 C){
float lighten = 0.333;
return (C * (1.0 + C / (whitepoint*whitepoint))) / (lighten + C);
}
/// from https://github.com/donmccurdy/three.js/blob/dev/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js
// AgX Tone Mapping implementation based on Filament, which in turn is based
// on Blender's implementation using rec 2020 primaries
// https://github.com/google/filament/pull/7236
// Inputs and outputs are encoded as Linear-sRGB.
// https://iolite-engine.com/blog_posts/minimal_agx_implementation
// Mean error^2: 3.6705141e-06
vec3 agxDefaultContrastApprox( vec3 x ) {
vec3 x2 = x * x;
vec3 x4 = x2 * x2;
return + 15.5 * x4 * x2
- 40.14 * x4 * x
+ 31.96 * x4
- 6.868 * x2 * x
+ 0.4298 * x2
+ 0.1191 * x
- 0.00232;
}
vec3 agxLook(vec3 val) {
const vec3 lw = vec3(0.2126, 0.7152, 0.0722);
float luma = dot(val, lw);
// Default
vec3 offset = vec3(0.0);
vec3 slope = vec3(1.0);
vec3 power = vec3(1.0);
float sat = 1.25;
// ASC CDL
val = pow(val * slope + offset, power);
return luma + sat * (val - luma);
}
vec3 ToneMap_AgX( vec3 color ) {
// AgX constants
const mat3 AgXInsetMatrix = mat3(
vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
);
// explicit AgXOutsetMatrix generated from Filaments AgXOutsetMatrixInv
const mat3 AgXOutsetMatrix = mat3(
vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
);
// LOG2_MIN = -10.0
// LOG2_MAX = +6.5
// MIDDLE_GRAY = 0.18
const float AgxMinEv = - 12.47393; // log2( pow( 2, LOG2_MIN ) * MIDDLE_GRAY )
const float AgxMaxEv = 4.026069; // log2( pow( 2, LOG2_MAX ) * MIDDLE_GRAY )
// color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
color = AgXInsetMatrix * color;
// Log2 encoding
color = max( color, 1e-10 ); // avoid 0 or negative numbers for log2
color = log2( color );
color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
color = clamp( color, 0.0, 1.0 );
// Apply sigmoid
color = agxDefaultContrastApprox( color );
// Apply AgX look
color = agxLook(color);
color = AgXOutsetMatrix * color;
// Linearize
color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
// color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
// Gamut mapping. Simple clamp for now.
color = clamp( color, 0.0, 1.0 );
return color;
}

View File

@ -1,24 +1,43 @@
vec3 DoAmbientLightColor(
vec3 lpvPos,
vec3 SkyColor,
vec3 MinimumColor,
vec3 TorchColor,
vec2 Lightmap
vec2 Lightmap,
float Exposure
){
// Lightmap = vec2(0.0,1.0);
float LightLevelZero = clamp(pow(eyeBrightnessSmooth.y/240. + Lightmap.y,2.0) ,0.0,1.0);
// do sky lighting.
float skyLM = (pow(Lightmap.y,15.0)*2.0 + pow(Lightmap.y,2.5))*0.5;
vec3 MinimumLight = MinimumColor * (MIN_LIGHT_AMOUNT*0.01 + nightVision);
vec3 IndirectLight = max(SkyColor * ambient_brightness * skyLM, MinimumLight);
vec3 IndirectLight = max(SkyColor * ambient_brightness * skyLM * 0.7, MinimumLight);
// do torch lighting
float TorchLM = pow(1.0-sqrt(1.0-clamp(Lightmap.x,0.0,1.0)),2.0) * 2.0;
float TorchBrightness_autoAdjust = mix(1.0, 30.0, clamp(exp(-10.0*Exposure),0.0,1.0)) ;
vec3 TorchLight = TorchColor * TorchLM * TORCH_AMOUNT ;
#if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store
vec4 lpvSample = SampleLpvLinear(lpvPos);
vec3 LpvTorchLight = GetLpvBlockLight(lpvSample);
// do torch lighting.
// float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(Lightmap.x)),5.0)+0.1));
// TorchLM = pow(TorchLM/4,10) + pow(Lightmap.x,1.5)*0.5;
// TODO: needs work, just binary transition for now
// float LpvFadeF = clamp(lpvPos, vec3(0.0), LpvSize3 - 1.0) == lpvPos ? 1.0 : 0.0;
float TorchLM = pow(Lightmap.x,10.0)*5.0 + pow(Lightmap.x,1.5);
vec3 TorchLight = TorchColor * TORCH_AMOUNT * TorchLM * (1.0 + LightLevelZero*dot(SkyColor * ambient_brightness,vec3(0.3333)));
// i gotchu
float fadeLength = 10.0; // in blocks
vec3 cubicRadius = clamp( min(((LpvSize3-1.0) - lpvPos)/fadeLength, lpvPos/fadeLength) ,0.0,1.0);
float LpvFadeF = cubicRadius.x*cubicRadius.y*cubicRadius.z;
return IndirectLight + TorchLight;
LpvFadeF = 1.0 - pow(1.0-pow(LpvFadeF,1.5),3.0); // make it nice and soft :)
TorchLight = mix(TorchLight,LpvTorchLight/5.0, LpvFadeF) ;
#endif
return IndirectLight + TorchLight * TorchBrightness_autoAdjust;
}
vec4 RT_AmbientLight(

10
shaders/lib/entities.glsl Normal file
View File

@ -0,0 +1,10 @@
#define ENTITY_PLAYER 1201
#define ENTITY_LIGHTNING 1202
//#define ENTITY_DRAGON_WITHER 1203
#define ENTITY_ITEM_FRAME 1301
#define ENTITY_SPECTRAL_ARROW 1302
#define ENTITY_TNT 1303
#define ENTITY_SSS_MEDIUM 1401
#define ENTITY_SSS_WEAK 1402

View File

@ -28,7 +28,7 @@ uniform float hurt;
// uniform bool isSpectator;
void applyGameplayEffects_FRAGMENT(inout vec3 color, in vec2 texcoord){
void applyGameplayEffects_FRAGMENT(inout vec3 color, in vec2 texcoord, float noise){
#if defined LOW_HEALTH_EFFECT || defined DAMAGE_TAKEN_EFFECT
// detect when health is zero
@ -46,7 +46,7 @@ void applyGameplayEffects_FRAGMENT(inout vec3 color, in vec2 texcoord){
float heartBeat = (pow(sin(frameTimeCounter * beatingRate)*0.5+0.5,2.0)*0.2 + 0.1);
// scale UV to be more and more lower frequency towards the edges of the screen, to create a tunnel vision effect,
vec2 zoomUV = 0.5 + (texcoord - 0.5) * (1.0 - vignette * (isDead ? 0.7 : heartBeat * MOTION_AMOUNT));
vec2 zoomUV = 0.5 + (texcoord - 0.5) * (1.0 - vignette * (isDead ? noise*0.7 : noise * heartBeat * MOTION_AMOUNT));
vec3 distortedScreen = vec3(1.0, 0.0, 0.0) * dot(texture2D(colortex7, zoomUV).rgb, vec3(0.21, 0.72, 0.07));
#ifdef LOW_HEALTH_EFFECT

17
shaders/lib/hsv.glsl Normal file
View File

@ -0,0 +1,17 @@
vec3 RgbToHsv(const in vec3 c) {
const vec4 K = vec4(0.0, -1.0, 2.0, -3.0) / 3.0;
const float e = 1.0e-10;
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
vec3 HsvToRgb(const in vec3 c) {
const vec4 K = vec4(3.0, 2.0, 1.0, 9.0) / 3.0;
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, saturate(p - K.xxx), c.y);
}

View File

@ -361,7 +361,8 @@ void ApplySSRT(
previousPosition.xy = projMAD(gbufferPreviousProjection, previousPosition).xy / -previousPosition.z * 0.5 + 0.5;
if (previousPosition.x > 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.x < 1.0){
radiance += (texture2D(colortex5,previousPosition.xy).rgb + skycontribution) * GI_Strength;
radiance += texture2D(colortex5, previousPosition.xy).rgb * GI_Strength + skycontribution;
} else{
radiance += skycontribution;
}
@ -388,4 +389,6 @@ void ApplySSRT(
#else
lighting = max(radiance/nrays - occlusion/nrays, 0.0);
#endif
if(hand) lighting = skylightcolor/1.5;
}

1
shaders/lib/items.glsl Normal file
View File

@ -0,0 +1 @@
#define ITEM_LIGHT_SOURCES 1000

View File

@ -0,0 +1,28 @@
struct LpvBlockData { // 12 x2000 =?
uint MaskWeight; // 4
uint ColorRange; // 4
uint Tint; // 4
};
#ifdef RENDER_SETUP
layout(binding = 0) writeonly buffer lpvBlockData
#else
layout(binding = 0) readonly buffer lpvBlockData
#endif
{
LpvBlockData LpvBlockMap[];
};
uint BuildBlockLpvData(uint mixMask, float mixWeight) {
uint data = uint(saturate(mixWeight) * 255.0);
data = data | (mixMask << 8);
return data;
}
void ParseBlockLpvData(const in uint data, out uint mixMask, out float mixWeight) {
mixWeight = (data & 0xFF) / 255.0;
mixMask = (data >> 8) & 0xFF;
}

View File

@ -0,0 +1,7 @@
#ifdef RENDER_SHADOWCOMP
layout(rgba8) uniform restrict image3D imgLpv1;
layout(rgba8) uniform restrict image3D imgLpv2;
#else
layout(rgba8) uniform readonly image3D imgLpv1;
layout(rgba8) uniform readonly image3D imgLpv2;
#endif

View File

@ -0,0 +1,10 @@
// How far light propagates (block, sky)
const vec2 LpvBlockSkyRange = vec2(15.0, 24.0);
const uint LpvSize = uint(exp2(LPV_SIZE));
const uvec3 LpvSize3 = uvec3(LpvSize);
vec3 GetLpvPosition(const in vec3 playerPos) {
vec3 cameraOffset = fract(cameraPosition);
return playerPos + cameraOffset + LpvSize3/2u;
}

View File

@ -0,0 +1,53 @@
// LPV falloff curve
const float LpvBlockPower = 4.0;
// LPV block brightness scale
const float LpvBlockBrightness = 2.0;
vec4 SampleLpvNearest(const in ivec3 lpvPos) {
vec4 lpvSample = (frameCounter % 2) == 0
? texelFetch(texLpv1, lpvPos, 0)
: texelFetch(texLpv2, lpvPos, 0);
lpvSample.b = pow(lpvSample.b, LpvBlockPower) * LpvBlockSkyRange.x;
lpvSample.rgb = HsvToRgb(lpvSample.rgb);
return lpvSample;
}
vec4 SampleLpvLinear(const in vec3 lpvPos) {
vec3 pos = lpvPos - 0.5;
ivec3 lpvCoord = ivec3(floor(pos));
vec3 lpvF = fract(pos);
vec4 sample_x1y1z1 = SampleLpvNearest(lpvCoord + ivec3(0, 0, 0));
vec4 sample_x2y1z1 = SampleLpvNearest(lpvCoord + ivec3(1, 0, 0));
vec4 sample_x1y2z1 = SampleLpvNearest(lpvCoord + ivec3(0, 1, 0));
vec4 sample_x2y2z1 = SampleLpvNearest(lpvCoord + ivec3(1, 1, 0));
vec4 sample_x1y1z2 = SampleLpvNearest(lpvCoord + ivec3(0, 0, 1));
vec4 sample_x2y1z2 = SampleLpvNearest(lpvCoord + ivec3(1, 0, 1));
vec4 sample_x1y2z2 = SampleLpvNearest(lpvCoord + ivec3(0, 1, 1));
vec4 sample_x2y2z2 = SampleLpvNearest(lpvCoord + ivec3(1, 1, 1));
vec4 sample_y1z1 = mix(sample_x1y1z1, sample_x2y1z1, lpvF.x);
vec4 sample_y2z1 = mix(sample_x1y2z1, sample_x2y2z1, lpvF.x);
vec4 sample_y1z2 = mix(sample_x1y1z2, sample_x2y1z2, lpvF.x);
vec4 sample_y2z2 = mix(sample_x1y2z2, sample_x2y2z2, lpvF.x);
vec4 sample_z1 = mix(sample_y1z1, sample_y2z1, lpvF.y);
vec4 sample_z2 = mix(sample_y1z2, sample_y2z2, lpvF.y);
return mix(sample_z1, sample_z2, lpvF.z);
}
vec3 GetLpvBlockLight(const in vec4 lpvSample) {
return LpvBlockBrightness * lpvSample.rgb;
}
float GetLpvSkyLight(const in vec4 lpvSample) {
float skyLight = saturate(lpvSample.a);
return skyLight*skyLight;
}

View File

@ -198,11 +198,11 @@ vec4 GetVolumetricFog(
if (abs(pos.x) < 1.0-0.5/2048. && abs(pos.y) < 1.0-0.5/2048){
pos = pos*vec3(0.5,0.5,0.5/6.0)+0.5;
#ifdef TRANSLUCENT_COLORED_SHADOWS
sh = vec3(shadow2D(shadowtex0, pos).x);
if(shadow2D(shadowtex1, pos).x > pos.z && sh.x < 1.0){
vec4 translucentShadow = texture2D(shadowcolor0, pos.xy);
if(translucentShadow.a < 0.9) sh = normalize(translucentShadow.rgb+0.0001);
}

View File

@ -32,6 +32,7 @@
#define WATER_BACKGROUND_SPECULAR
#define WATER_SUN_SPECULAR
#define SCREENSPACE_REFLECTIONS
// #define WATER_HQ_SMOOTHNESS
#define SNELLS_WINDOW
@ -121,11 +122,13 @@ const float ambientOcclusionLevel = 1.0; // this controls vanilla minecrafts amb
const float sunPathRotation = -35; //[-90 -89 -88 -87 -86 -85 -84 -83 -82 -81 -80 -79 -78 -77 -76 -75 -74 -73 -72 -71 -70 -69 -68 -67 -66 -65 -64 -63 -62 -61 -60 -59 -58 -57 -56 -55 -54 -53 -52 -51 -50 -49 -48 -47 -46 -45 -44 -43 -42 -41 -40 -39 -38 -37 -36 -35 -34 -33 -32 -31 -30 -29 -28 -27 -26 -25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 ]
const int shadowMapResolution = 2048; // [512 768 1024 1536 2048 3172 4096 8192 16384]
const float shadowDistance = 128.0; // [64.0 80.0 96.0 112.0 128.0 144.0 160.0 176.0 192.0 208.0 224.0 240.0 256.0 272.0 288.0 304.0 320.0 336.0 352.0 384.0 400.0 416.0 432.0 448.0 464.0 480.0 496.0 512.0 800.0 1000.0 2000.0 3000.0]
const int shadowMapResolution = 2048; // [512 768 1024 1536 2048 3172 4096 8192]
const float shadowDistance = 128.0; // [32.0 48.0 64.0 80.0 96.0 112.0 128.0 144.0 160.0 176.0 192.0 208.0 224.0 240.0 256.0 272.0 288.0 304.0 320.0 336.0 352.0 368.0 384.0 512.0 768.0 1024.0 1536.0 2048.0 4096.0 8192.0]
const float shadowDistanceRenderMul = 1.0; // [-1.0 1.0]
const float entityShadowDistanceMul = 1.0; // [0.05 0.10 1.50 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.0]
#define OPTIMIZED_SHADOW_DISTANCE -1.0 // [-1.0 1.0]
const float shadowDistanceRenderMul = OPTIMIZED_SHADOW_DISTANCE;
const float entityShadowDistanceMul = 0.25; // [0.01 0.02 0.03 0.04 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.75 1.00]
#define RENDER_ENTITY_SHADOWS
@ -142,9 +145,9 @@ const float entityShadowDistanceMul = 1.0; // [0.05 0.10 1.50 0.20 0.25 0.30 0.3
#define SHADOW_DISABLE_ALPHA_MIPMAPS
#define Stochastic_Transparent_Shadows
#define Glass_Tint
#define TRANSLUCENT_COLORED_SHADOWS
#ifdef TRANSLUCENT_COLORED_SHADOWS
#define Glass_Tint
#undef Stochastic_Transparent_Shadows
#endif
@ -178,7 +181,7 @@ const float entityShadowDistanceMul = 1.0; // [0.05 0.10 1.50 0.20 0.25 0.30 0.3
#define RainFog_amount 3 // [0 1 2 3 4 5 6 7 8 9 10 15 20 25]
#define BLOOMY_FOG 1.5 // [0.0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 3.0 4.0 6.0 10.0 15.0 20.0]
#define BLOOM_STRENGTH 4.0 // [0.0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 50.0 75.0 100.0]
#define BLOOM_STRENGTH 1.0 // [0.0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 50.0 75.0 100.0]
#define CAVE_FOG
#ifdef CAVE_FOG
@ -253,8 +256,8 @@ const float entityShadowDistanceMul = 1.0; // [0.05 0.10 1.50 0.20 0.25 0.30 0.3
#define LIGHTSOURCE_REFLECTION
#endif
#define EMISSIVE_TYPE 0 // [0 1 2 3]
#define Emissive_Brightness 10.0 // [1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 100.]
#define EMISSIVE_TYPE 1 // [0 1 2 3]
#define Emissive_Brightness 1.0 // [1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 100.]
#define Emissive_Curve 2.0 // [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ]
@ -271,12 +274,14 @@ const float entityShadowDistanceMul = 1.0; // [0.05 0.10 1.50 0.20 0.25 0.30 0.3
#undef HEIGTHMAP_DEPTH_OFFSET
#endif
#define SSS_TYPE 2 // [0 1 2 3]
#define SSS_TYPE 1 // [0 1 2 3]
#define LabSSS_Curve 1.0 // [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ]
// #define MOB_SSS
// #define MISC_BLOCK_SSS
#define Ambient_SSS
#define ambientsss_brightness 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0]
#define sss_absorbance_multiplier 1.0 // [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0]
#define sss_density_multiplier 1.0 // [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0]
// #define Porosity
@ -524,7 +529,7 @@ uniform int moonPhase;
// ----- COLOR/POST PROCESSING RELATED SETTINGS ----- //
////////////////////////////////////////////////////////
#define TONEMAP ToneMap_Hejl2015 // [ToneMap_Hejl2015 Tonemap_Xonk Tonemap_Uchimura HableTonemap Full_Reinhard_Edit Tonemap_Full_Reinhard reinhard Tonemap_Lottes ACESFilm]
#define TONEMAP ToneMap_AgX // [ToneMap_AgX ToneMap_Hejl2015 Tonemap_Xonk Tonemap_Uchimura HableTonemap Full_Reinhard_Edit Tonemap_Full_Reinhard reinhard Tonemap_Lottes ACESFilm]
//#define USE_ACES_COLORSPACE_APPROXIMATION
#define CONTRAST_ADAPTATIVE_SHARPENING
@ -642,7 +647,9 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
#define RESOURCEPACK_SKY 0 // [0 1 2]
#define TRANSLUCENT_ENTITIES
#ifdef IS_IRIS
#define TRANSLUCENT_ENTITIES
#endif
#define WATER_CAUSTICS_BRIGHTNESS 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0]
#define DENOISE_SSS_AND_SSAO
@ -660,7 +667,6 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
const float shadowNearPlane = -1.0;
const float shadowFarPlane = -1.0;
#endif
// #define DH_SHADOWPROJECTIONTWEAK
@ -669,6 +675,24 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
#define DH_KNOWN_ISSUES 0 // [0 1 2 3 4 5]
///////////////////////////////////////////
// ----- FLOODFILL [LPV] SETTINGS ----- //
///////////////////////////////////////////
//#define LPV_ENABLED
#define LPV_SIZE 7 // [6 7 8]
#define LPV_NORMAL_OFFSET
#define LPV_ENTITY_LIGHTS
#define LPV_REDSTONE_LIGHTS
//#define LPV_COLORED_CANDLES
#ifdef LPV_ENABLED
#ifdef IRIS_FEATURE_CUSTOM_IMAGES
#define IS_LPV_ENABLED
#endif
#endif
////////////////////////////////
// ----- DEBUG SETTINGS ----- //
////////////////////////////////
@ -683,17 +707,24 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
#define debug_VIEW_POSITION 6
#define debug_DH_WATER_BLENDING 7
#define debug_FILTERED_STUFF 8
#define DEBUG_VIEW debug_OFF // [debug_OFF debug_SHADOWMAP debug_NORMALS debug_SPECULAR debug_INDIRECT debug_DIRECT debug_VIEW_POSITION debug_DH_WATER_BLENDING debug_FILTERED_STUFF]
#define debug_TEMPORAL_REPROJECTION 9
#define DEBUG_VIEW debug_OFF // [debug_OFF debug_SHADOWMAP debug_NORMALS debug_SPECULAR debug_INDIRECT debug_DIRECT debug_VIEW_POSITION debug_DH_WATER_BLENDING debug_FILTERED_STUFF debug_TEMPORAL_REPROJECTION]
/////////////////////////////////
// ----- RANDOM SETTINGS ----- //
/////////////////////////////////
// #define OLD_BLOOM
// #define BLOOMY_PARTICLES
// #define ORIGINAL_CHOCAPIC_SKY
// #define CLOUDS_INFRONT_OF_WORLD
// fix settings
#ifdef TRANSLUCENT_ENTITIES
#endif
#ifdef RENDER_ENTITY_SHADOWS
#endif
#if RESOURCEPACK_SKY == 0
#endif
#ifdef VANILLA_SUN_AND_MOON
@ -703,4 +734,4 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
#if BLISS_SHADERS == 0
#endif
#if DH_KNOWN_ISSUES == 0
#endif
#endif

View File

@ -191,7 +191,7 @@ void DoSpecularReflections(
Roughness = 1.0 - Roughness; Roughness *= Roughness;
F0 = F0 == 0.0 ? 0.02 : F0;
// Roughness = 0.0;
// Roughness = 0.1;
// F0 = 0.9;
mat3 Basis = CoordBase(Normal);
@ -220,8 +220,9 @@ void DoSpecularReflections(
bool hasReflections = Roughness_Threshold == 1.0 ? true : F0 * (1.0 - Roughness * Roughness_Threshold) > 0.01;
// mulitply all reflections by the albedo if it is a metal.
vec3 Metals = F0 > 229.5/255.0 ? lerp(normalize(Albedo+1e-7) * (dot(Albedo,vec3(0.21, 0.72, 0.07)) * 0.7 + 0.3), vec3(1.0), Fresnel * pow(1.0-Roughness,25.0)) : vec3(1.0);
// vec3 Metals = F0 > 229.5/255.0 ? max(Albedo, Fresnel) : vec3(1.0);
// vec3 Metals = F0 > 229.5/255.0 ? lerp(normalize(Albedo+1e-7) * (dot(Albedo,vec3(0.21, 0.72, 0.07)) * 0.7 + 0.3), vec3(1.0), Fresnel * pow(1.0-Roughness,25.0)) : vec3(1.0);
vec3 Metals = F0 > 229.5/255.0 ? normalize(Albedo+1e-7) * (dot(Albedo,vec3(0.21, 0.72, 0.07)) * 0.7 + 0.3) : vec3(1.0);
// vec3 Metals = F0 > 229.5/255.0 ? Albedo : vec3(1.0);
// --------------- BACKGROUND REFLECTIONS
// apply background reflections to the final color. make sure it does not exist based on the lightmap
@ -271,11 +272,13 @@ void DoSpecularReflections(
}
#endif
// Final_Reflection = mix(mix(Output,Background_Reflection,Lightmap), SS_Reflections.rgb, SS_Reflections.a) * RayContribution;
// --------------- LIGHTSOURCE REFLECTIONS
// slap the main lightsource reflections to the final color.
#ifdef LIGHTSOURCE_REFLECTION
Lightsource_Reflection = Diffuse * GGX(Normal, -WorldPos, LightPos, Roughness, F0) * Metals;
Final_Reflection += Lightsource_Reflection * Sun_specular_Strength;
Final_Reflection += Lightsource_Reflection * Sun_specular_Strength ;
#endif
Output = Final_Reflection;

View File

@ -9,41 +9,48 @@ float hash12(vec2 p)
p3 += dot(p3, p3.yzx + 19.19);
return fract((p3.x + p3.y) * p3.z);
}
// Convert Noise2d() into a "star field" by stomping everthing below fThreshhold to zero.
float NoisyStarField( in vec2 vSamplePos, float fThreshhold )
// 1 out, 3 in...
float hash13(vec3 p3)
{
float StarVal = hash12( vSamplePos );
StarVal = clamp(StarVal/(1.0 - fThreshhold) - fThreshhold/(1.0 - fThreshhold),0.0,1.0);
p3 = fract(p3 * .1031);
p3 += dot(p3, p3.zyx + 31.32);
return fract((p3.x + p3.y) * p3.z);
}
// Convert Noise2d() into a "star field" by stomping everthing below fThreshhold to zero.
float NoisyStarField( in vec3 vSamplePos, float fThreshhold )
{
float StarVal = hash13( vSamplePos );
StarVal = clamp(StarVal/(1.0 - fThreshhold) - fThreshhold/(1.0 - fThreshhold),0.0,1.0);
return StarVal;
}
// Stabilize NoisyStarField() by only sampling at integer values.
float StableStarField( in vec2 vSamplePos, float fThreshhold )
float StableStarField( in vec3 vSamplePos, float fThreshhold )
{
// Linear interpolation between four samples.
// Note: This approach has some visual artifacts.
// There must be a better way to "anti alias" the star field.
float fractX = fract( vSamplePos.x );
float fractY = fract( vSamplePos.y );
vec2 floorSample = floor( vSamplePos );
float v1 = NoisyStarField( floorSample, fThreshhold );
float v2 = NoisyStarField( floorSample + vec2( 0.0, 1.0 ), fThreshhold );
float v3 = NoisyStarField( floorSample + vec2( 1.0, 0.0 ), fThreshhold );
float v4 = NoisyStarField( floorSample + vec2( 1.0, 1.0 ), fThreshhold );
vec3 floorSample = floor( vSamplePos.xyz );
float v1 = NoisyStarField( floorSample, fThreshhold);
float v2 = NoisyStarField( floorSample + vec3( 0.0, 1.0, 0.0), fThreshhold );
float v3 = NoisyStarField( floorSample + vec3( 1.0, 0.0, 0.0), fThreshhold );
float v4 = NoisyStarField( floorSample + vec3( 1.0, 1.0, 0.0), fThreshhold );
float StarVal = v1 * ( 1.0 - fractX ) * ( 1.0 - fractY )
+ v2 * ( 1.0 - fractX ) * fractY
+ v3 * fractX * ( 1.0 - fractY )
+ v4 * fractX * fractY;
return StarVal;
}
float stars(vec3 viewPos){
float elevation = clamp(viewPos.y,0.,1.);
vec2 uv = viewPos.xz/(1.5+elevation);
return exp((1.0-StableStarField(uv*1000.,0.999)) * -10) * 3;
// return StableStarField(uv*1000.,0.999)*0.5*0.3;
float stars = max(1.0 - StableStarField(viewPos*300.0 , 0.99),0.0);
return exp( stars * -20.0);
}

View File

@ -0,0 +1,12 @@
#ifdef RENDER_SHADOW
layout(r16ui) uniform uimage3D imgVoxelMask;
#else
layout(r16ui) uniform readonly uimage3D imgVoxelMask;
#endif
const uint VoxelSize = uint(exp2(LPV_SIZE));
const uvec3 VoxelSize3 = uvec3(VoxelSize);
const float voxelDistance = 64.0;
#define BLOCK_EMPTY 0

View File

@ -0,0 +1,11 @@
ivec3 GetVoxelIndex(const in vec3 playerPos) {
vec3 cameraOffset = fract(cameraPosition);
return ivec3(floor(playerPos + cameraOffset) + VoxelSize3/2u);
}
void SetVoxelBlock(const in vec3 playerPos, const in uint blockId) {
ivec3 voxelPos = GetVoxelIndex(playerPos);
if (clamp(voxelPos, ivec3(0), ivec3(VoxelSize-1u)) != voxelPos) return;
imageStore(imgVoxelMask, voxelPos, uvec4(blockId));
}

View File

@ -57,14 +57,17 @@ float getWaterHeightmap(vec2 posxz) {
vec3 getWaveNormal(vec3 posxz, bool isLOD){
// vary the normal's "smooth" factor as distance changes, to avoid noise from too much details.
float range = pow(clamp(1.0 - length(posxz - cameraPosition)/(32*4),0.0,1.0),2.0);
float deltaPos = mix(0.5, 0.1, range);
float normalMult = 10.0 * WATER_WAVE_STRENGTH;
// float range = pow(clamp(1.0 - length(posxz - cameraPosition)/(32*4),0.0,1.0),2.0);
// float deltaPos = mix(0.5, 0.1, range);
float range = min(length(posxz - cameraPosition) / (16*14.0), 3.0);
float deltaPos = range + 0.15;
if(isLOD){
normalMult = mix(5.0, normalMult, range);
deltaPos = mix(0.9, deltaPos, range);
}
// float normalMult = 1.0 * WATER_WAVE_STRENGTH;
// if(isLOD){
// deltaPos = mix(0.9, deltaPos, range);
// }
// added detail for snells window
// if(isEyeInWater == 1) deltaPos = 0.025;
@ -72,17 +75,17 @@ vec3 getWaveNormal(vec3 posxz, bool isLOD){
deltaPos = 0.025;
#endif
vec2 coord = posxz.xz;// - posxz.y;
vec2 coord = posxz.xz;
float h0 = getWaterHeightmap(coord);
float h1 = getWaterHeightmap(coord + vec2(deltaPos,0.0));
float h3 = getWaterHeightmap(coord + vec2(0.0,deltaPos));
float xDelta = ((h1-h0)/deltaPos)*normalMult;
float yDelta = ((h3-h0)/deltaPos)*normalMult;
float xDelta = (h1-h0)/deltaPos;
float yDelta = (h3-h0)/deltaPos;
vec3 wave = normalize(vec3(xDelta,yDelta,1.0-pow(abs(xDelta+yDelta),2.0)));
vec3 wave = normalize(vec3(xDelta, yDelta, 1.0-pow(abs(xDelta+yDelta),2.0)));
return wave ;
return wave;
}