mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2026-10-10 05:03:04 +08:00
potentially Fix LOD flicker on AMD
This commit is contained in:
@@ -172,14 +172,14 @@ void main() {
|
||||
}
|
||||
#endif
|
||||
|
||||
vec3 normals = (normals_and_materials.xyz);
|
||||
vec3 normals = normalize(normals_and_materials.xyz); // normals in viewspace by default
|
||||
float materials = normals_and_materials.a;
|
||||
vec2 PackLightmaps = lightmapCoords;
|
||||
|
||||
// PackLightmaps.y *= 1.05;
|
||||
PackLightmaps = min(max(PackLightmaps,0.0)*1.05,1.0);
|
||||
|
||||
vec4 data1 = clamp( encode(viewToWorld(normals), PackLightmaps), 0.0, 1.0);
|
||||
vec4 data1 = clamp( encode(normals, PackLightmaps), 0.0, 1.0);
|
||||
|
||||
// alpha is material masks, set it to 0.65 to make a DH LODs mask.
|
||||
#ifdef DH_NOISE_TEXTURE
|
||||
|
||||
@@ -384,7 +384,8 @@ void main() {
|
||||
vec4 data = texelFetch(colortex1,ivec2(gl_FragCoord.xy),0);
|
||||
vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y));
|
||||
vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w));
|
||||
vec3 normal = mat3(gbufferModelViewInverse) * clamp(worldToView( decode(dataUnpacked0.yw) ),-1.,1.);
|
||||
vec3 normal = decode(dataUnpacked0.yw);
|
||||
|
||||
vec2 lightmap = dataUnpacked1.yz;
|
||||
|
||||
|
||||
@@ -403,6 +404,8 @@ void main() {
|
||||
|
||||
float z = convertHandDepth_2(texelFetch(depthtex1,ivec2(gl_FragCoord.xy),0).x,hand);
|
||||
|
||||
if(z >= 1.0) normal = viewToWorld(normal);
|
||||
|
||||
#ifdef USING_LOD_MOD
|
||||
float DH_depth1 = texelFetch(LOD_DEPTHTEX1,ivec2(gl_FragCoord.xy),0).x;
|
||||
float swappedDepth = z >= 1.0 ? DH_depth1 : z;
|
||||
|
||||
@@ -817,6 +817,9 @@ void main() {
|
||||
vec3 albedo = toLinear(vec3(dataUnpacked0.xz,dataUnpacked1.x));
|
||||
|
||||
vec3 normal = decode(dataUnpacked0.yw);
|
||||
|
||||
if(isDHrange) normal = viewToWorld(normal);
|
||||
|
||||
vec2 lightmap = dataUnpacked1.yz;
|
||||
// special curve to give more precision on high/low values of the gradient. this curve will be inverted after sampling and decoding.
|
||||
// lightmap = 1.0-pow(1.0-pow(lightmap,vec2(2)),vec2(2));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// THANK YOU SIXTHSURGE FOR ALLOWING USAGE OF PHOTON CODE TO BUILD THIS VOXY IMPLEMENTATION FROM: https://github.com/sixthsurge/photon
|
||||
|
||||
#define SUB_SURFACE_SCATTERING_RELATED_SETTINGS
|
||||
#include "/lib/settings.glsl"
|
||||
#include "/lib/blocks.glsl"
|
||||
|
||||
@@ -29,6 +29,20 @@ float readVoxyDepth(sampler2D colortex, in ivec2 coords){
|
||||
return sqrt(texelFetch(colortex, coords, 0).x/65000.0);
|
||||
}
|
||||
|
||||
vec3 viewToWorld(vec3 viewPos) {
|
||||
vec4 pos;
|
||||
pos.xyz = viewPos;
|
||||
pos.w = 0.0;
|
||||
pos = gbufferModelViewInverse * pos ;
|
||||
return pos.xyz;
|
||||
}
|
||||
|
||||
vec3 worldToView(vec3 worldPos) {
|
||||
vec4 pos = vec4(worldPos, 0.0);
|
||||
pos = gbufferModelView * pos;
|
||||
return pos.xyz;
|
||||
}
|
||||
|
||||
/*
|
||||
struct VoxyFragmentParameters {
|
||||
vec4 sampledColour;
|
||||
@@ -49,8 +63,8 @@ layout(location = 2) out vec4 MISC_DATA;
|
||||
void voxy_emitFragment(VoxyFragmentParameters parameters) {
|
||||
|
||||
vec3 normal = vec3( uint((parameters.face >> 1) == 2), uint((parameters.face >> 1) == 0), uint((parameters.face >> 1) == 1) ) * (float(int(parameters.face) & 1) * 2.0 - 1.0);
|
||||
normal.z = clamp(normal.z-1.0,-1.0,1.0)*0.5+0.5;
|
||||
normal = normalize(normal);
|
||||
// normal.z = clamp(normal.z-1.0,-1.0,1.0)*0.5+0.5;
|
||||
normal = normalize(normal); // normals in worldspace by default
|
||||
|
||||
vec3 Albedo = parameters.sampledColour.rgb * parameters.tinting.rgb;
|
||||
|
||||
@@ -59,7 +73,7 @@ void voxy_emitFragment(VoxyFragmentParameters parameters) {
|
||||
#endif
|
||||
|
||||
vec2 lightMaps = parameters.lightMap.xy;
|
||||
vec4 data1 = clamp( encode(normal, lightMaps), 0.0, 1.0);
|
||||
vec4 data1 = clamp( encode(worldToView(normal), lightMaps), 0.0, 1.0);
|
||||
float pixelMask = 0.0;
|
||||
|
||||
DEFERRED_DATA.xyzw = vec4( encodeVec2(Albedo.x, data1.x),
|
||||
@@ -68,7 +82,7 @@ void voxy_emitFragment(VoxyFragmentParameters parameters) {
|
||||
encodeVec2(data1.w, pixelMask) );
|
||||
|
||||
float subSurfaceScattering = 0.0;
|
||||
|
||||
#if SSS_TYPE > 0
|
||||
if(
|
||||
parameters.customId == BLOCK_SSS_STRONG || parameters.customId == BLOCK_SAPLING ||
|
||||
parameters.customId == BLOCK_AIR_WAVING
|
||||
@@ -92,7 +106,7 @@ void voxy_emitFragment(VoxyFragmentParameters parameters) {
|
||||
// ) subSurfaceScattering = 0.5;
|
||||
|
||||
if(parameters.customId == BLOCK_SSS_WEAK_3) subSurfaceScattering = 0.4;
|
||||
|
||||
#endif
|
||||
SPECULAR_DATA.xyzw = vec4(0.0,0.0,subSurfaceScattering,0.0);
|
||||
|
||||
MISC_DATA.xyzw = vec4(normal.xyz * 0.5 + 0.5, 0.0);
|
||||
|
||||
Reference in New Issue
Block a user