add strength slider for on-fire distortion effect. revisit large wave displacement and improve it a little

This commit is contained in:
Xonk
2025-04-06 19:29:05 -04:00
parent 77c2559751
commit f0ad8e93f6
5 changed files with 50 additions and 42 deletions

View File

@ -72,7 +72,7 @@ varying vec4 normalMat;
varying vec3 binormal; varying vec3 binormal;
varying vec3 flatnormal; varying vec3 flatnormal;
#ifdef LARGE_WAVE_DISPLACEMENT #ifdef LARGE_WAVE_DISPLACEMENT
varying vec3 shitnormal; varying vec3 largeWaveDisplacementNormal;
#endif #endif
uniform vec3 sunVec; uniform vec3 sunVec;
@ -385,7 +385,6 @@ void Emission(
uniform vec3 eyePosition; uniform vec3 eyePosition;
//////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN//////////////////////////////
@ -493,22 +492,21 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
} }
#endif #endif
#ifdef LARGE_WAVE_DISPLACEMENT
if (isWater){
normal = viewToWorld(normal);
normal.xz = shitnormal.xy;
normal = worldToView(normal);
}
#endif
vec3 worldSpaceNormal = viewToWorld(normal).xyz; vec3 worldSpaceNormal = viewToWorld(normal).xyz;
vec2 TangentNormal = vec2(0); // for refractions vec2 TangentNormal = vec2(0); // for refractions
vec3 tangent2 = normalize(cross(tangent.rgb,normal)*tangent.w); #ifdef LARGE_WAVE_DISPLACEMENT
if (isWater){
normal = largeWaveDisplacementNormal;
}
#endif
vec3 tangent2 = normalize(cross(tangent.rgb, normal)*tangent.w);
mat3 tbnMatrix = mat3(tangent.x, tangent2.x, normal.x, mat3 tbnMatrix = mat3(tangent.x, tangent2.x, normal.x,
tangent.y, tangent2.y, normal.y, tangent.y, tangent2.y, normal.y,
tangent.z, tangent2.z, normal.z); tangent.z, tangent2.z, normal.z);
vec3 NormalTex = vec3(texture2D(normals, lmtexcoord.xy, Texture_MipMap_Bias).xy,0.0); vec3 NormalTex = vec3(texture2D(normals, lmtexcoord.xy, Texture_MipMap_Bias).xy,0.0);
NormalTex.xy = NormalTex.xy*2.0-1.0; NormalTex.xy = NormalTex.xy*2.0-1.0;
NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0); NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0);
@ -776,7 +774,10 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
bool WATER = texture2D(colortex7, gl_FragCoord.xy*texelSize).a > 0.0 && length(feetPlayerPos) > clamp(far-16*4, 16, maxOverdrawDistance) && texture2D(depthtex1, gl_FragCoord.xy*texelSize).x >= 1.0; bool WATER = texture2D(colortex7, gl_FragCoord.xy*texelSize).a > 0.0 && length(feetPlayerPos) > clamp(far-16*4, 16, maxOverdrawDistance) && texture2D(depthtex1, gl_FragCoord.xy*texelSize).x >= 1.0;
if(WATER) gl_FragData[0].a = 0.0; if(WATER) {
gl_FragData[0].a = 0.0;
MATERIALS = 0.0;
}
#endif #endif
gl_FragData[1] = vec4(Albedo, MATERIALS); gl_FragData[1] = vec4(Albedo, MATERIALS);

View File

@ -37,7 +37,7 @@ varying vec4 tangent;
varying vec3 flatnormal; varying vec3 flatnormal;
#ifdef LARGE_WAVE_DISPLACEMENT #ifdef LARGE_WAVE_DISPLACEMENT
varying vec3 shitnormal; varying vec3 largeWaveDisplacementNormal;
#endif #endif
uniform mat4 gbufferModelViewInverse; uniform mat4 gbufferModelViewInverse;
@ -87,8 +87,10 @@ vec4 toClipSpace3(vec3 viewSpacePosition) {
float getWave (vec3 pos, float range){ float getWave (vec3 pos, float range){
return pow(1.0-texture2D(noisetex, (pos.xz + frameTimeCounter * WATER_WAVE_SPEED)/150.0).b,2) * WATER_WAVE_STRENGTH / range; // return pow(1.0-texture2D(noisetex, (pos.xz + frameTimeCounter * WATER_WAVE_SPEED)/150.0).b,2.0) * WATER_WAVE_STRENGTH * range;
return pow(1.0-texture2D(noisetex, (pos.xz + frameTimeCounter * WATER_WAVE_SPEED)/125.0).r,5.0) * WATER_WAVE_STRENGTH * range;
} }
vec3 getWaveNormal(vec3 posxz, float range){ vec3 getWaveNormal(vec3 posxz, float range){
float deltaPos = 0.5; float deltaPos = 0.5;
@ -100,12 +102,13 @@ vec3 getWaveNormal(vec3 posxz, float range){
float h3 = getWave(coord - vec3(0.0,0.0,deltaPos),range); float h3 = getWave(coord - vec3(0.0,0.0,deltaPos),range);
float xDelta = (h1-h0)/deltaPos*1.5; float xDelta = (h1-h0)/deltaPos * 1.5;
float yDelta = (h3-h0)/deltaPos*1.5; float yDelta = (h3-h0)/deltaPos * 1.5;
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;
} }
//////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN//////////////////////////////
@ -133,25 +136,28 @@ void main() {
vec2 lmcoord = gl_MultiTexCoord1.xy / 240.0; vec2 lmcoord = gl_MultiTexCoord1.xy / 240.0;
lmtexcoord.zw = lmcoord; lmtexcoord.zw = lmcoord;
#ifdef LARGE_WAVE_DISPLACEMENT #ifdef LARGE_WAVE_DISPLACEMENT
if(mc_Entity.x == 8.0) { if(mc_Entity.x == 8.0) {
vec3 displacedPos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz + cameraPosition;
vec3 playerPos = mat3(gbufferModelViewInverse) * position.xyz;
#ifdef DISTANT_HORIZONS #ifdef DISTANT_HORIZONS
float range = min(1.0 + pow(length(displacedPos - cameraPosition) / min(far,256.0),2.0), 256.0); float range = pow(1-pow(1-clamp(1.0 - length(playerPos) / far, 0.0,1.0),3.0),3.0);
#else #else
float range = min(1.0 + pow(length(displacedPos - cameraPosition) / 256,2.0), 256.0); float range = min(1.0 + pow(length(playerPos) / 256,2.0), 256.0);
#endif #endif
displacedPos.y -= (1.0-getWave(displacedPos, range)) * 0.5 - 0.2; vec4 displacedVertex = vec4(gl_Vertex.x, gl_Vertex.y + (getWave(gl_Vertex.xyz + cameraPosition, range)*0.6-0.5), gl_Vertex.z, gl_Vertex.w);
shitnormal = getWaveNormal(displacedPos, range); position = mat3(gl_ModelViewMatrix) * vec3(displacedVertex) + gl_ModelViewMatrix[3].xyz;
position = mat3(gbufferModelView) * (displacedPos - cameraPosition) + gbufferModelView[3].xyz;
playerPos = mat3(gbufferModelViewInverse) * position.xyz;
largeWaveDisplacementNormal = getWaveNormal(playerPos + cameraPosition, range);
} }
#endif #endif
// vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz; vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz;
#ifdef PLANET_CURVATURE #ifdef PLANET_CURVATURE
float curvature = length(worldpos) / (16*8); float curvature = length(worldpos) / (16*8);
worldpos.y -= curvature*curvature * CURVATURE_AMOUNT; worldpos.y -= curvature*curvature * CURVATURE_AMOUNT;
@ -192,24 +198,24 @@ void main() {
if (entityId == 1600) NAMETAG = 1; if (entityId == 1600) NAMETAG = 1;
#endif #endif
tangent = vec4(normalize(gl_NormalMatrix *at_tangent.rgb),at_tangent.w);
normalMat = vec4(normalize(gl_NormalMatrix * gl_Normal), 1.0);
normalMat.a = mat;
vec3 tangent2 = normalize( gl_NormalMatrix *at_tangent.rgb); tangent = vec4(normalize(gl_NormalMatrix * at_tangent.rgb),at_tangent.w);
binormal = normalize(cross(tangent2.rgb,normalMat.xyz)*at_tangent.w); normalMat = vec4(normalize(gl_NormalMatrix * gl_Normal), mat);
binormal = normalize(cross(tangent.rgb,normalMat.xyz)*at_tangent.w);
mat3 tbnMatrix = mat3(tangent2.x, binormal.x, normalMat.x, mat3 tbnMatrix = mat3(tangent.x, binormal.x, normalMat.x,
tangent2.y, binormal.y, normalMat.y, tangent.y, binormal.y, normalMat.y,
tangent2.z, binormal.z, normalMat.z); tangent.z, binormal.z, normalMat.z);
if(mc_Entity.x == 8.0) {
largeWaveDisplacementNormal = normalize(largeWaveDisplacementNormal * tbnMatrix);
}else{
largeWaveDisplacementNormal = normalMat.xyz;
}
flatnormal = normalMat.xyz; flatnormal = normalMat.xyz;
viewVector = position.xyz; viewVector = position.xyz;
// viewVector = (gl_ModelViewMatrix * gl_Vertex).xyz;
viewVector = normalize(tbnMatrix * viewVector);
viewVector = normalize(tbnMatrix * viewVector);
color = vec4(gl_Color.rgb, 1.0); color = vec4(gl_Color.rgb, 1.0);

View File

@ -89,7 +89,7 @@ void applyGameplayEffects(inout vec3 color, in vec2 texcoord, float noise){
vec2 UV = zoomin; vec2 UV = zoomin;
float flameDistort = texture2D(noisetex, UV * vec2(aspectRatio,1.0) - vec2(0.0,frameTimeCounter*0.3)).b * clamp(-texcoord.y*0.3+0.3,0.0,1.0) * 0.75 * exitLava; float flameDistort = texture2D(noisetex, UV * vec2(aspectRatio,1.0) - vec2(0.0,frameTimeCounter*0.3)).b * clamp(-texcoord.y*0.3+0.3,0.0,1.0) * ON_FIRE_DISTORT_EFFECT_STRENGTH * exitLava;
distortmask = max(distortmask, flameDistort); distortmask = max(distortmask, flameDistort);
} }

View File

@ -617,6 +617,7 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
#define WATER_ON_CAMERA_EFFECT #define WATER_ON_CAMERA_EFFECT
#define ON_FIRE_DISTORT_EFFECT #define ON_FIRE_DISTORT_EFFECT
#define ON_FIRE_DISTORT_EFFECT_STRENGTH 0.7 // [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]
#ifdef LOW_HEALTH_EFFECT #ifdef LOW_HEALTH_EFFECT
#endif #endif

File diff suppressed because one or more lines are too long