mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2024-12-22 09:38:52 +08:00
encode normal and albedo for translucents
also a clean up the translucent gbuffer program a bit
This commit is contained in:
parent
e1c82709f0
commit
233056d61c
@ -15,7 +15,7 @@
|
||||
block.10004 = minecraft:fern minecraft:packed_ice minecraft:blue_ice minecraft:melon_stem minecraft:pumpkin_stem minecraft:attached_melon_stem minecraft:attached_pumpkin_stem minecraft:lily_pad minecraft:azalea_leaves minecraft:flowering_azalea_leaves minecraft:azalea minecraft:flowering_azalea
|
||||
|
||||
## weak
|
||||
block.10006 = weeping_vines weeping_vines_plant twisting_vines twisting_vines_plant vine tube_coral tube_coral_block tube_coral_fan tube_coral_wall_fan horn_coral horn_coral_block horn_coral_fan horn_coral_wall_fan fire_coral fire_coral_block fire_coral_fan fire_coral_wall_fan dead_brain_coral dead_brain_coral_block dead_brain_coral_fan dead_brain_coral_wall_fan dead_bubble_coral dead_bubble_coral_block dead_bubble_coral_fan dead_bubble_coral_wall_fan dead_bush dead_fire_coral dead_fire_coral_block dead_fire_coral_fan dead_fire_coral_wall_fan dead_horn_coral dead_horn_coral_block dead_horn_coral_fan dead_horn_coral_wall_fan dead_tube_coral dead_tube_coral_block dead_tube_coral_fan dead_tube_coral_wall_fan bubble_coral bubble_coral_block bubble_coral_fan bubble_coral_wall_fan brain_coral brain_coral_block brain_coral_fan brain_coral_wall_fan bamboo bamboo_sapling minecraft:tall_seagrass minecraft:seagrass minecraft:kelp minecraft:large_fern minecraft:tall_grass minecraft:tall_seagrass minecraft:kelp_plant minecraft:peony minecraft:rose_bush minecraft:lilac minecraft:sunflower minecraft:spore_blossom minecraft:cave_vines minecraft:cave_vines_plant minecraft:glow_lichen minecraft:melon minecraft:pumpkin minecraft:big_dripleaf minecraft:big_dripleaf_stem minecraft:cactus minecraft:hay_block minecraft:brown_mushroom minecraft:mushroom_stem minecraft:sugar_cane minecraft:crimson_fungus minecraft:warped_fungus minecraft:sea_pickle minecraft:honeycomb_block
|
||||
block.10006 = red_mushroom_block brown_mushroom_block weeping_vines weeping_vines_plant twisting_vines twisting_vines_plant vine tube_coral tube_coral_block tube_coral_fan tube_coral_wall_fan horn_coral horn_coral_block horn_coral_fan horn_coral_wall_fan fire_coral fire_coral_block fire_coral_fan fire_coral_wall_fan dead_brain_coral dead_brain_coral_block dead_brain_coral_fan dead_brain_coral_wall_fan dead_bubble_coral dead_bubble_coral_block dead_bubble_coral_fan dead_bubble_coral_wall_fan dead_bush dead_fire_coral dead_fire_coral_block dead_fire_coral_fan dead_fire_coral_wall_fan dead_horn_coral dead_horn_coral_block dead_horn_coral_fan dead_horn_coral_wall_fan dead_tube_coral dead_tube_coral_block dead_tube_coral_fan dead_tube_coral_wall_fan bubble_coral bubble_coral_block bubble_coral_fan bubble_coral_wall_fan brain_coral brain_coral_block brain_coral_fan brain_coral_wall_fan bamboo bamboo_sapling minecraft:tall_seagrass minecraft:seagrass minecraft:kelp minecraft:large_fern minecraft:tall_grass minecraft:tall_seagrass minecraft:kelp_plant minecraft:peony minecraft:rose_bush minecraft:lilac minecraft:sunflower minecraft:spore_blossom minecraft:cave_vines minecraft:cave_vines_plant minecraft:glow_lichen minecraft:melon minecraft:pumpkin minecraft:big_dripleaf minecraft:big_dripleaf_stem minecraft:cactus minecraft:hay_block minecraft:brown_mushroom minecraft:mushroom_stem minecraft:sugar_cane minecraft:crimson_fungus minecraft:warped_fungus minecraft:sea_pickle minecraft:honeycomb_block
|
||||
block.100061 = minecraft:cobweb
|
||||
|
||||
block.200 = minecraft:white_wool minecraft:orange_wool minecraft:magenta_wool minecraft:light_blue_wool minecraft:yellow_wool minecraft:lime_wool minecraft:pink_wool minecraft:gray_wool minecraft:light_gray_wool minecraft:cyan_wool minecraft:purple_wool minecraft:blue_wool minecraft:brown_wool minecraft:green_wool minecraft:red_wool minecraft:black_wool minecraft:orange_carpet minecraft:magenta_carpet minecraft:light_blue_carpet minecraft:yellow_carpet minecraft:lime_carpet minecraft:pink_carpet minecraft:gray_carpet minecraft:light_gray_carpet minecraft:cyan_carpet minecraft:purple_carpet minecraft:blue_carpet minecraft:brown_carpet minecraft:green_carpet minecraft:red_carpet minecraft:black_carpet
|
||||
|
@ -11,21 +11,15 @@ const bool colortex12MipmapEnabled = true;
|
||||
const bool shadowHardwareFiltering = true;
|
||||
flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon)
|
||||
flat varying vec3 avgAmbient;
|
||||
// flat varying vec3 ambientUp;
|
||||
// flat varying vec3 ambientLeft;
|
||||
// flat varying vec3 ambientRight;
|
||||
// flat varying vec3 ambientB;
|
||||
// flat varying vec3 ambientF;
|
||||
// flat varying vec3 ambientDown;
|
||||
flat varying vec3 WsunVec;
|
||||
flat varying vec2 TAA_Offset;
|
||||
flat varying float tempOffsets;
|
||||
|
||||
|
||||
uniform float eyeAltitude;
|
||||
|
||||
/*
|
||||
const int colortex12Format = RGBA16F; //Final output, transparencies id (gbuffer->composite4)
|
||||
const int colortex11Format = RGBA16F; //Final output, transparencies id (gbuffer->composite4)
|
||||
const int colortex15Format = RGBA16F; //Final output, transparencies id (gbuffer->composite4)
|
||||
*/
|
||||
|
||||
@ -40,11 +34,11 @@ uniform sampler2D colortex7; // normal
|
||||
uniform sampler2D colortex6; // Noise
|
||||
uniform sampler2D colortex8; // specular
|
||||
// uniform sampler2D colortex9; // specular
|
||||
uniform sampler2D colortex10; // specular
|
||||
uniform sampler2D colortex11; // specular
|
||||
uniform sampler2D colortex10; // specular
|
||||
uniform sampler2D colortex12; // specular
|
||||
uniform sampler2D colortex13; // specular
|
||||
uniform sampler2D colortex14; // specular
|
||||
// uniform sampler2D colortex14; // specular
|
||||
uniform sampler2D colortex15; // specular
|
||||
uniform sampler2D colortex16; // specular
|
||||
uniform sampler2D depthtex1;//depth
|
||||
@ -820,19 +814,25 @@ void main() {
|
||||
float iswaterstuff = texture2D(colortex7,texcoord).a ;
|
||||
bool iswater = iswaterstuff > 0.99;
|
||||
|
||||
vec4 data = texture2D(colortex1,texcoord); // terraom
|
||||
vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y));
|
||||
vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w));
|
||||
vec4 dataUnpacked2 = vec4(decodeVec2(data.z),decodeVec2(data.w));
|
||||
vec3 normal = decode(dataUnpacked0.yw);
|
||||
// Color //
|
||||
////// --------------- UNPACK OPAQUE GBUFFERS --------------- //////
|
||||
vec4 data = texture2D(colortex1,texcoord);
|
||||
vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y)); // albedo, masks
|
||||
vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w)); // normals, lightmaps
|
||||
// vec4 dataUnpacked2 = vec4(decodeVec2(data.z),decodeVec2(data.w));
|
||||
|
||||
vec3 albedo = toLinear(vec3(dataUnpacked0.xz,dataUnpacked1.x));
|
||||
vec4 translucentCol = texture2D(colortex13,texcoord); // translucents
|
||||
vec2 lightmap = dataUnpacked1.yz;
|
||||
vec3 normal = decode(dataUnpacked0.yw);
|
||||
|
||||
// Specular //
|
||||
////// --------------- UNPACK TRANSLUCENT GBUFFERS --------------- //////
|
||||
// vec4 dataTranslucent = texture2D(colortex11,texcoord);
|
||||
// vec4 dataT_Unpacked0 = vec4(decodeVec2(dataTranslucent.x),decodeVec2(dataTranslucent.y));
|
||||
// vec4 dataT_Unpacked1 = vec4(decodeVec2(dataTranslucent.z),decodeVec2(dataTranslucent.w));
|
||||
// vec4 dataT_Unpacked2 = vec4(decodeVec2(dataTranslucent.z),decodeVec2(dataTranslucent.w));
|
||||
|
||||
////// --------------- UNPACK MISC --------------- //////
|
||||
vec4 SpecularTex = texture2D(colortex8,texcoord);
|
||||
|
||||
// Normal //
|
||||
vec4 normalAndAO = texture2D(colortex15,texcoord);
|
||||
vec3 FlatNormals = normalAndAO.rgb * 2.0 - 1.0;
|
||||
vec3 slopednormal = normal;
|
||||
@ -848,7 +848,6 @@ void main() {
|
||||
normalAndAO.a = clamp(pow(normalAndAO.a*5,4),0,1);
|
||||
|
||||
|
||||
vec2 lightmap = dataUnpacked1.yz;
|
||||
|
||||
bool translucent = abs(dataUnpacked1.w-0.5) <0.01; // Strong translucency
|
||||
bool translucent2 = abs(dataUnpacked1.w-0.6) <0.01; // Weak translucency
|
||||
@ -1164,9 +1163,9 @@ void main() {
|
||||
float estimatedDepth = Vdiff * abs(VdotU) ; //assuming water plane
|
||||
float estimatedSunDepth = estimatedDepth/abs(WsunVec.y); //assuming water plane
|
||||
|
||||
float custom_lightmap_T = texture2D(colortex14, texcoord).x; // y = torch
|
||||
// float custom_lightmap_T = texture2D(colortex14, texcoord).x; * max(custom_lightmap_T,0.005)// y = torch
|
||||
|
||||
vec3 ambientColVol = (avgAmbient * 8./150./1.5) * max(custom_lightmap_T,0.005);
|
||||
vec3 ambientColVol = (avgAmbient * 8./150./1.5);
|
||||
vec3 lightColVol = (lightCol.rgb / 80.) ;
|
||||
|
||||
if (isEyeInWater == 0) waterVolumetrics(gl_FragData[0].rgb, fragpos0, fragpos, estimatedDepth , estimatedSunDepth, Vdiff, noise, totEpsilon, scatterCoef, ambientColVol, lightColVol, dot(np3, WsunVec));
|
||||
|
@ -131,7 +131,6 @@ vec3 decode (vec2 encn){
|
||||
n.xy = n.z <= 0.0 ? (1.0 - n.yx) * sign(encn) : encn;
|
||||
return clamp(normalize(n.xyz),-1.0,1.0);
|
||||
}
|
||||
|
||||
vec2 decodeVec2(float a){
|
||||
const vec2 constant1 = 65535. / vec2( 256., 65536.);
|
||||
const float constant2 = 256. / 255.;
|
||||
@ -167,9 +166,10 @@ vec3 viewToWorld(vec3 viewPosition) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 texcoord = gl_FragCoord.xy*texelSize;
|
||||
/* DRAWBUFFERS:73 */
|
||||
|
||||
vec2 texcoord = gl_FragCoord.xy*texelSize;
|
||||
|
||||
vec4 trpData = texture2D(colortex7,texcoord);
|
||||
|
||||
bool iswater = trpData.a > 0.99;
|
||||
@ -186,24 +186,21 @@ void main() {
|
||||
// vec4 vl = texture2D(colortex0,texcoord * 0.5);
|
||||
|
||||
|
||||
vec4 data = texture2D(colortex11,texcoord); // translucents
|
||||
vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y));
|
||||
vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w));
|
||||
|
||||
vec3 normals = mat3(gbufferModelViewInverse) * worldToView(decode(dataUnpacked0.yw) );
|
||||
////// --------------- UNPACK TRANSLUCENT GBUFFERS --------------- //////
|
||||
|
||||
vec4 data_terrain = texture2D(colortex1,texcoord); // terraom
|
||||
vec4 dataUnpacked1_terrain = vec4(decodeVec2(data_terrain.z),decodeVec2(data_terrain.w));
|
||||
vec3 data = texture2D(colortex11,texcoord).rgb;
|
||||
|
||||
bool hand = (abs(dataUnpacked1_terrain.w-0.75) < 0.01);
|
||||
vec4 unpack0 = vec4(decodeVec2(data.r),decodeVec2(data.g)) ;
|
||||
vec4 unpack1 = vec4(decodeVec2(data.b),0,0) ;
|
||||
|
||||
vec2 tangentNormals = unpack0.xy*2.0-1.0;
|
||||
vec4 albedo = vec4(unpack0.ba,unpack1.rg);
|
||||
|
||||
vec4 TranslucentShader = texture2D(colortex2,texcoord);
|
||||
|
||||
float lightleakfix = clamp((eyeBrightnessSmooth.y )/240.0,0.0,1.0);
|
||||
|
||||
|
||||
float rainDrops = clamp(texture2D(colortex9,texcoord).a, 0.0,1.0); // bloomy rain effect
|
||||
|
||||
|
||||
vec4 Translucent_Programs = texture2D(colortex2,texcoord); // the shader for all translucent progams.
|
||||
|
||||
vec2 tempOffset = TAA_Offset;
|
||||
vec3 fragpos = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z));
|
||||
@ -213,19 +210,15 @@ void main() {
|
||||
|
||||
|
||||
vec2 refractedCoord = texcoord;
|
||||
float glassdepth = clamp((ld(z2) - ld(z)) * 0.5,0.0,0.15);
|
||||
|
||||
#ifdef Refraction
|
||||
refractedCoord += (normals.xy * glassdepth) * RENDER_SCALE;
|
||||
|
||||
float refractedalpha = texture2D(colortex13,refractedCoord).a;
|
||||
if(refractedalpha <= 0.0) refractedCoord = texcoord; // remove refracted coords on solids
|
||||
refractedCoord += (tangentNormals * clamp((ld(z2) - ld(z)) * 0.5,0.0,0.15)) * RENDER_SCALE;
|
||||
|
||||
if(decodeVec2(texture2D(colortex11,refractedCoord).b).g < 0.01 ) refractedCoord = texcoord; // remove refracted coords on solids
|
||||
#endif
|
||||
|
||||
// underwater squiggles
|
||||
// if(isEyeInWater == 1 && !iswater) refractedCoord = texcoord + pow(texture2D(noisetex,texcoord - vec2(0,frameTimeCounter/25)).b - 0.5, 2.0)*0.05;
|
||||
|
||||
|
||||
/// --- MAIN COLOR BUFFER --- ///
|
||||
// it is sampled with distorted texcoords
|
||||
vec3 color = texture2D(colortex3,refractedCoord).rgb;
|
||||
|
||||
#ifdef BorderFog
|
||||
@ -233,18 +226,18 @@ void main() {
|
||||
float fog = 1.0 - clamp(exp(-pow(length(fragpos / far),10.)*4.0) ,0.0,1.0);
|
||||
float heightFalloff = clamp( pow(abs(np3.y-1.01),5) ,0,1) ;
|
||||
|
||||
if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, sky, fog*heightFalloff* lightleakfix);
|
||||
if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, sky, fog * heightFalloff* lightleakfix);
|
||||
#endif
|
||||
|
||||
vec4 vl = BilateralUpscale(colortex0,depthtex1,gl_FragCoord.xy,frDepth, vec2(0.0));
|
||||
vec4 vl = BilateralUpscale(colortex0, depthtex1, gl_FragCoord.xy, frDepth, vec2(0.0));
|
||||
|
||||
if (Translucent_Programs.a > 0.0){
|
||||
if (TranslucentShader.a > 0.0){
|
||||
#ifdef Glass_Tint
|
||||
vec3 GlassAlbedo = texture2D(colortex13,texcoord).rgb * 5.0;
|
||||
color = color*GlassAlbedo.rgb + color * clamp(pow(1.0-luma(GlassAlbedo.rgb),10.),0.0,1.0);
|
||||
// if(albedo.a < 0) color = color*albedo.rgb + color * clamp(pow(1.0-luma(albedo.rgb),10.),0.0,1.0);
|
||||
if(albedo.a > 0.2) color = color*albedo.rgb + color * clamp(pow(1.0-luma(albedo.rgb),20.),0.0,1.0);
|
||||
#endif
|
||||
|
||||
color = color*(1.0-Translucent_Programs.a) + Translucent_Programs.rgb;
|
||||
color = color*(1.0-TranslucentShader.a) + TranslucentShader.rgb;
|
||||
|
||||
#ifdef BorderFog
|
||||
if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, sky, fog * heightFalloff * lightleakfix);
|
||||
@ -271,10 +264,12 @@ void main() {
|
||||
vl.a *= fogfade*0.70+0.3 ;
|
||||
}
|
||||
|
||||
|
||||
color *= vl.a;
|
||||
color += vl.rgb;
|
||||
|
||||
|
||||
|
||||
float rainDrops = clamp(texture2D(colortex9,texcoord).a, 0.0,1.0); // bloomy rain effect
|
||||
if(rainDrops > 0.0) vl.a *= clamp(exp2(-rainDrops*5),0.,1.); // bloomy rain effect
|
||||
gl_FragData[0].r = vl.a;
|
||||
|
||||
@ -300,6 +295,10 @@ void main() {
|
||||
if(texcoord.x < 0.45 ) color.rgb = texture2D(colortex4,movedTC).rgb / 150. * 5.0;
|
||||
#endif
|
||||
|
||||
|
||||
gl_FragData[1].rgb = clamp(color.rgb,0.0,68000.0);
|
||||
|
||||
// gl_FragData[1].rgb = vec3(albedo.rgb*albedo.a);
|
||||
// if(texcoord.x > 0.5) gl_FragData[1].rgb = vec3(tangentNormals,0.0);
|
||||
|
||||
}
|
@ -20,15 +20,19 @@ const int colortex3Format = R11F_G11F_B10F; //frame buffer + bloom (deferred6-
|
||||
const int colortex4Format = RGBA16F; //light values and skyboxes (everything)
|
||||
|
||||
|
||||
const int colortex11Format = RGBA16; //Final output, transparencies id (gbuffer->composite4)
|
||||
|
||||
const int colortex13Format = RGBA8; //Final output, transparencies id (gbuffer->composite4)
|
||||
|
||||
const int colortex6Format = R11F_G11F_B10F; //additionnal buffer for bloom (composite3->final)
|
||||
const int colortex7Format = RGBA8; //Final output, transparencies id (gbuffer->composite4)
|
||||
const int colortex8Format = RGBA16F; //Final output, transparencies id (gbuffer->composite4)
|
||||
const int colortex9Format = RGBA8; //Final output, transparencies id (gbuffer->composite4)
|
||||
const int colortex10Format = RGBA16F; //Final output, transparencies id (gbuffer->composite4)
|
||||
|
||||
const int colortex13Format = RGBA16F; //Final output, transparencies id (gbuffer->composite4)
|
||||
// const int colortex15Format = RGBA16F; // flat normals and vanilla
|
||||
*/
|
||||
|
||||
//no need to clear the buffers, saves a few fps
|
||||
/*
|
||||
const bool colortex0Clear = false;
|
||||
|
@ -41,13 +41,15 @@ varying vec4 color;
|
||||
varying vec4 NoSeasonCol;
|
||||
varying vec4 seasonColor;
|
||||
uniform float far;
|
||||
|
||||
|
||||
uniform float wetness;
|
||||
varying vec4 normalMat;
|
||||
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
varying vec4 tangent;
|
||||
uniform float wetness;
|
||||
uniform sampler2D normals;
|
||||
varying vec4 tangent;
|
||||
varying vec3 FlatNormals;
|
||||
#endif
|
||||
|
||||
@ -99,11 +101,7 @@ float R2_dither(){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter) ;
|
||||
}
|
||||
vec2 decodeVec2(float a){
|
||||
const vec2 constant1 = 65535. / vec2( 256., 65536.);
|
||||
const float constant2 = 256. / 255.;
|
||||
return fract( a * constant1 ) * constant2 ;
|
||||
}
|
||||
|
||||
mat3 inverse(mat3 m) {
|
||||
float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];
|
||||
float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];
|
||||
@ -242,12 +240,7 @@ float densityAtPosSNOW(in vec3 pos){
|
||||
/* RENDERTARGETS: 1,7,8,15 */
|
||||
void main() {
|
||||
|
||||
|
||||
float phi = 2 * 3.14159265359;
|
||||
float noise = fract(fract(frameCounter * (1.0 / phi)) + interleaved_gradientNoise() ) ;
|
||||
|
||||
vec3 normal = normalMat.xyz;
|
||||
vec3 normal2 = normalMat.xyz;
|
||||
|
||||
#ifdef MC_NORMAL_MAP
|
||||
vec3 tangent2 = normalize(cross(tangent.rgb,normal)*tangent.w);
|
||||
@ -434,9 +427,6 @@ void main() {
|
||||
|
||||
normal = applyBump(tbnMatrix, NormalTex.xyz, mix(1.0,1.0-Puddle_shape,rainfall) );
|
||||
|
||||
// #ifdef ENTITIES
|
||||
// if(NameTags == 1 || NameTags == 2) normal = normal2;
|
||||
// #endif
|
||||
#ifdef ENTITIES
|
||||
if(NameTags == 1) normal = vec3(1);
|
||||
#endif
|
||||
@ -528,7 +518,7 @@ void main() {
|
||||
////////////////////////////////
|
||||
|
||||
vec4 data1 = clamp( encode(viewToWorld(normal), (blueNoise()*lmtexcoord.zw/30.0) + lmtexcoord.zw), 0.0, 1.0);
|
||||
gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x), encodeVec2(Albedo.y,data1.y), encodeVec2(Albedo.z,data1.z), encodeVec2(data1.w,Albedo.w));
|
||||
gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x), encodeVec2(Albedo.y,data1.y), encodeVec2(Albedo.z,data1.z), encodeVec2(data1.w,Albedo.w));
|
||||
|
||||
gl_FragData[1].a = 0.0;
|
||||
#endif
|
||||
|
@ -143,6 +143,7 @@ void main() {
|
||||
|
||||
NameTags = 0;
|
||||
|
||||
blockID = mc_Entity.x;
|
||||
velocity = at_velocity;
|
||||
|
||||
// emission and shit...
|
||||
@ -153,10 +154,6 @@ void main() {
|
||||
|
||||
|
||||
lmtexcoord.xy = (gl_MultiTexCoord0).xy;
|
||||
FlatNormals = normalize(gl_NormalMatrix * gl_Normal);
|
||||
|
||||
blockID = mc_Entity.x;
|
||||
|
||||
|
||||
#ifdef POM
|
||||
vec2 midcoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
|
||||
@ -167,11 +164,13 @@ void main() {
|
||||
#endif
|
||||
|
||||
vec2 lmcoord = gl_MultiTexCoord1.xy / 255.0; // is this even correct? lol
|
||||
|
||||
lmtexcoord.zw = lmcoord;
|
||||
|
||||
|
||||
|
||||
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
|
||||
|
||||
FlatNormals = normalize(gl_NormalMatrix * gl_Normal);
|
||||
color = gl_Color;
|
||||
|
||||
VanillaAO = 1.0 - clamp(color.a,0,1);
|
||||
|
@ -3,11 +3,15 @@
|
||||
|
||||
varying vec4 lmtexcoord;
|
||||
varying vec4 color;
|
||||
|
||||
|
||||
uniform sampler2D normals;
|
||||
varying vec4 tangent;
|
||||
|
||||
varying vec4 normalMat;
|
||||
varying vec3 binormal;
|
||||
uniform sampler2D normals;
|
||||
varying vec3 tangent;
|
||||
varying vec4 tangent_other;
|
||||
|
||||
|
||||
varying vec3 viewVector;
|
||||
|
||||
#include "lib/settings.glsl"
|
||||
@ -64,62 +68,120 @@ flat varying vec3 avgAmbient;
|
||||
#include "lib/clouds.glsl"
|
||||
#include "lib/stars.glsl"
|
||||
#include "lib/volumetricClouds.glsl"
|
||||
|
||||
#include "lib/diffuse_lighting.glsl"
|
||||
|
||||
|
||||
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
|
||||
vec2(-1.,3.)/8.,
|
||||
vec2(5.0,1.)/8.,
|
||||
vec2(-3,-5.)/8.,
|
||||
vec2(-5.,5.)/8.,
|
||||
vec2(-7.,-1.)/8.,
|
||||
vec2(3,7.)/8.,
|
||||
vec2(7.,-7.)/8.);
|
||||
|
||||
float blueNoise(){
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
|
||||
}
|
||||
float R2_dither(){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter) ;
|
||||
}
|
||||
float interleaved_gradientNoise(){
|
||||
vec2 coord = gl_FragCoord.xy + (frameCounter%40000);
|
||||
// vec2 coord = gl_FragCoord.xy + frameTimeCounter;
|
||||
// vec2 coord = gl_FragCoord.xy;
|
||||
float noise = fract( 52.9829189 * fract( (coord.x * 0.06711056) + (coord.y * 0.00583715)) );
|
||||
return noise ;
|
||||
}
|
||||
float interleaved_gradientNoise(float temporal){
|
||||
vec2 coord = gl_FragCoord.xy;
|
||||
float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)+temporal);
|
||||
return noise;
|
||||
}
|
||||
vec3 srgbToLinear2(vec3 srgb){
|
||||
return mix(
|
||||
srgb / 12.92,
|
||||
pow(.947867 * srgb + .0521327, vec3(2.4) ),
|
||||
step( .04045, srgb )
|
||||
);
|
||||
|
||||
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
|
||||
vec2(-1.,3.)/8.,
|
||||
vec2(5.0,1.)/8.,
|
||||
vec2(-3,-5.)/8.,
|
||||
vec2(-5.,5.)/8.,
|
||||
vec2(-7.,-1.)/8.,
|
||||
vec2(3,7.)/8.,
|
||||
vec2(7.,-7.)/8.);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define PW_DEPTH 1.0 //[0.5 1.0 1.5 2.0 2.5 3.0]
|
||||
#define PW_POINTS 1 //[2 4 6 8 16 32]
|
||||
|
||||
vec3 getParallaxDisplacement(vec3 posxz, float iswater,float bumpmult,vec3 viewVec) {
|
||||
float waveZ = mix(20.0,0.25,iswater);
|
||||
float waveM = mix(0.0,4.0,iswater);
|
||||
|
||||
vec3 parallaxPos = posxz;
|
||||
vec2 vec = viewVector.xy * (1.0 / float(PW_POINTS)) * 22.0 * PW_DEPTH;
|
||||
float waterHeight = getWaterHeightmap(posxz.xz, waveM, waveZ, iswater) ;
|
||||
|
||||
parallaxPos.xz += waterHeight * vec;
|
||||
|
||||
return parallaxPos;
|
||||
|
||||
}
|
||||
vec3 blackbody2(float Temp)
|
||||
|
||||
vec3 applyBump(mat3 tbnMatrix, vec3 bump, float puddle_values){
|
||||
float bumpmult = 1;
|
||||
bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult);
|
||||
return normalize(bump*tbnMatrix);
|
||||
}
|
||||
|
||||
vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter,float distort)
|
||||
{
|
||||
float t = pow(Temp, -1.5);
|
||||
float lt = log(Temp);
|
||||
float alpha = (sampleNumber+jitter)/nb;
|
||||
float angle = jitter*6.28 + alpha * nbRot * 6.28;
|
||||
|
||||
vec3 col = vec3(0.0);
|
||||
col.x = 220000.0 * t + 0.58039215686;
|
||||
col.y = 0.39231372549 * lt - 2.44549019608;
|
||||
col.y = Temp > 6500. ? 138039.215686 * t + 0.72156862745 : col.y;
|
||||
col.z = 0.76078431372 * lt - 5.68078431373;
|
||||
col = clamp(col,0.0,1.0);
|
||||
col = Temp < 1000. ? col * Temp * 0.001 : col;
|
||||
float sin_v, cos_v;
|
||||
|
||||
return srgbToLinear2(col);
|
||||
sin_v = sin(angle);
|
||||
cos_v = cos(angle);
|
||||
|
||||
return vec2(cos_v, sin_v)*sqrt(alpha);
|
||||
}
|
||||
|
||||
float blueNoise(){
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
|
||||
|
||||
vec3 viewToWorld(vec3 viewPosition) {
|
||||
vec4 pos;
|
||||
pos.xyz = viewPosition;
|
||||
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;
|
||||
}
|
||||
vec4 encode (vec3 n, vec2 lightmaps){
|
||||
n.xy = n.xy / dot(abs(n), vec3(1.0));
|
||||
n.xy = n.z <= 0.0 ? (1.0 - abs(n.yx)) * sign(n.xy) : n.xy;
|
||||
vec2 encn = clamp(n.xy * 0.5 + 0.5,-1.0,1.0);
|
||||
|
||||
return vec4(encn,vec2(lightmaps.x,lightmaps.y));
|
||||
}
|
||||
|
||||
//encoding by jodie
|
||||
float encodeVec2(vec2 a){
|
||||
const vec2 constant1 = vec2( 1., 256.) / 65535.;
|
||||
vec2 temp = floor( a * 255. );
|
||||
return temp.x*constant1.x+temp.y*constant1.y;
|
||||
}
|
||||
float encodeVec2(float x,float y){
|
||||
return encodeVec2(vec2(x,y));
|
||||
}
|
||||
|
||||
|
||||
float invLinZ (float lindepth){
|
||||
return -((2.0*near/lindepth)-far-near)/(far-near);
|
||||
}
|
||||
float ld(float dist) {
|
||||
return (2.0 * near) / (far + near - dist * (far - near));
|
||||
}
|
||||
vec3 nvec3(vec4 pos){
|
||||
return pos.xyz/pos.w;
|
||||
}
|
||||
|
||||
vec4 nvec4(vec3 pos){
|
||||
return vec4(pos.xyz, 1.0);
|
||||
}
|
||||
vec3 rayTrace(vec3 dir,vec3 position,float dither, float fresnel, bool inwater){
|
||||
|
||||
float quality = mix(15,SSR_STEPS,fresnel);
|
||||
@ -168,219 +230,6 @@ vec3 rayTrace(vec3 dir,vec3 position,float dither, float fresnel, bool inwater){
|
||||
return vec3(1.1);
|
||||
}
|
||||
|
||||
|
||||
float facos(float sx){
|
||||
float x = clamp(abs( sx ),0.,1.);
|
||||
float a = sqrt( 1. - x ) * ( -0.16882 * x + 1.56734 );
|
||||
return sx > 0. ? a : pi - a;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
float bayer2(vec2 a){
|
||||
a = floor(a);
|
||||
return fract(dot(a,vec2(0.5,a.y*0.75)));
|
||||
}
|
||||
|
||||
float cdist(vec2 coord) {
|
||||
return max(abs(coord.s-0.5),abs(coord.t-0.5))*2.0;
|
||||
}
|
||||
|
||||
#define PW_DEPTH 1.0 //[0.5 1.0 1.5 2.0 2.5 3.0]
|
||||
#define PW_POINTS 2 //[2 4 6 8 16 32]
|
||||
#define bayer4(a) (bayer2( .5*(a))*.25+bayer2(a))
|
||||
#define bayer8(a) (bayer4( .5*(a))*.25+bayer2(a))
|
||||
#define bayer16(a) (bayer8( .5*(a))*.25+bayer2(a))
|
||||
#define bayer32(a) (bayer16(.5*(a))*.25+bayer2(a))
|
||||
#define bayer64(a) (bayer32(.5*(a))*.25+bayer2(a))
|
||||
#define bayer128(a) fract(bayer64(.5*(a))*.25+bayer2(a))
|
||||
|
||||
vec3 getParallaxDisplacement(vec3 posxz, float iswater,float bumpmult,vec3 viewVec) {
|
||||
float waveZ = mix(20.0,0.25,iswater);
|
||||
float waveM = mix(0.0,4.0,iswater);
|
||||
|
||||
vec3 parallaxPos = posxz;
|
||||
vec2 vec = viewVector.xy * (1.0 / float(PW_POINTS)) * 22.0 * PW_DEPTH;
|
||||
float waterHeight = getWaterHeightmap(posxz.xz, waveM, waveZ, iswater) ;
|
||||
|
||||
parallaxPos.xz += waterHeight * vec;
|
||||
|
||||
return parallaxPos;
|
||||
|
||||
}
|
||||
vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter,float distort)
|
||||
{
|
||||
float alpha = (sampleNumber+jitter)/nb;
|
||||
float angle = jitter*6.28 + alpha * nbRot * 6.28;
|
||||
|
||||
float sin_v, cos_v;
|
||||
|
||||
sin_v = sin(angle);
|
||||
cos_v = cos(angle);
|
||||
|
||||
return vec2(cos_v, sin_v)*sqrt(alpha);
|
||||
}
|
||||
//Low discrepancy 2D sequence, integration error is as low as sobol but easier to compute : http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/
|
||||
vec2 R2_samples(int n){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
return fract(alpha * n);
|
||||
}
|
||||
vec4 hash44(vec4 p4)
|
||||
{
|
||||
p4 = fract(p4 * vec4(.1031, .1030, .0973, .1099));
|
||||
p4 += dot(p4, p4.wzxy+33.33);
|
||||
return fract((p4.xxyz+p4.yzzw)*p4.zywx);
|
||||
}
|
||||
vec3 TangentToWorld(vec3 N, vec3 H)
|
||||
{
|
||||
vec3 UpVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
|
||||
vec3 T = normalize(cross(UpVector, N));
|
||||
vec3 B = cross(N, T);
|
||||
|
||||
return vec3((T * H.x) + (B * H.y) + (N * H.z));
|
||||
}
|
||||
float GGX (vec3 n, vec3 v, vec3 l, float r, float F0) {
|
||||
r*=r;r*=r;
|
||||
|
||||
vec3 h = l + v;
|
||||
float hn = inversesqrt(dot(h, h));
|
||||
|
||||
float dotLH = clamp(dot(h,l)*hn,0.,1.);
|
||||
float dotNH = clamp(dot(h,n)*hn,0.,1.);
|
||||
float dotNL = clamp(dot(n,l),0.,1.);
|
||||
float dotNHsq = dotNH*dotNH;
|
||||
|
||||
float denom = dotNHsq * r - dotNHsq + 1.;
|
||||
float D = r / (3.141592653589793 * denom * denom);
|
||||
float F = F0 + (1. - F0) * exp2((-5.55473*dotLH-6.98316)*dotLH);
|
||||
float k2 = .25 * r;
|
||||
|
||||
return dotNL * D * F / (dotLH*dotLH*(1.0-k2)+k2);
|
||||
}
|
||||
|
||||
vec3 applyBump(mat3 tbnMatrix, vec3 bump){
|
||||
float bumpmult = 1.0;
|
||||
bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult);
|
||||
return normalize(bump*tbnMatrix);
|
||||
}
|
||||
|
||||
#define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.)
|
||||
float triangularize(float dither)
|
||||
{
|
||||
float center = dither*2.0-1.0;
|
||||
dither = center*inversesqrt(abs(center));
|
||||
return clamp(dither-fsign(center),0.0,1.0);
|
||||
}
|
||||
vec3 fp10Dither(vec3 color,float dither){
|
||||
const vec3 mantissaBits = vec3(6.,6.,5.);
|
||||
vec3 exponent = floor(log2(color));
|
||||
return color + dither*exp2(-mantissaBits)*exp2(exponent);
|
||||
}
|
||||
float R2_dither(){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter) ;
|
||||
}
|
||||
float interleaved_gradientNoise(){
|
||||
vec2 coord = gl_FragCoord.xy + (frameCounter%40000);
|
||||
// vec2 coord = gl_FragCoord.xy + frameTimeCounter;
|
||||
// vec2 coord = gl_FragCoord.xy;
|
||||
float noise = fract( 52.9829189 * fract( (coord.x * 0.06711056) + (coord.y * 0.00583715)) );
|
||||
return noise ;
|
||||
}
|
||||
//encoding by jodie
|
||||
float encodeVec2(vec2 a){
|
||||
const vec2 constant1 = vec2( 1., 256.) / 65535.;
|
||||
vec2 temp = floor( a * 255. );
|
||||
return temp.x*constant1.x+temp.y*constant1.y;
|
||||
}
|
||||
float encodeVec2(float x,float y){
|
||||
return encodeVec2(vec2(x,y));
|
||||
}
|
||||
vec3 viewToWorld(vec3 viewPosition) {
|
||||
vec4 pos;
|
||||
pos.xyz = viewPosition;
|
||||
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;
|
||||
}
|
||||
vec4 encode (vec3 n, vec2 lightmaps){
|
||||
n.xy = n.xy / dot(abs(n), vec3(1.0));
|
||||
n.xy = n.z <= 0.0 ? (1.0 - abs(n.yx)) * sign(n.xy) : n.xy;
|
||||
vec2 encn = clamp(n.xy * 0.5 + 0.5,-1.0,1.0);
|
||||
|
||||
return vec4(encn,vec2(lightmaps.x,lightmaps.y));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
float square(float x){
|
||||
return x*x;
|
||||
}
|
||||
|
||||
float gSimple(float dp, float roughness){
|
||||
float k = roughness + 1;
|
||||
k *= k/8.0;
|
||||
return dp / (dp * (1.0-k) + k);
|
||||
}
|
||||
vec3 GGX2_2(vec3 n, vec3 v, vec3 l, float r, vec3 F0) {
|
||||
|
||||
float alpha = square(r) + 1e-4; // when roughness is zero it fucks up
|
||||
|
||||
vec3 h = normalize(l + v) ;
|
||||
|
||||
float dotNH = clamp(dot(h,n),0.,1.);
|
||||
float dotVH = clamp(dot(h,v),0.,1.);
|
||||
|
||||
float D = alpha / (2.2 * square( (dotNH * alpha - 1.0) * square(dotNH) + 1.0) );
|
||||
|
||||
vec3 F = F0 + (1. - F0) * pow(clamp(1.0 - dotVH,0.0,1.0),5.0);
|
||||
|
||||
return F * D;
|
||||
}
|
||||
// float SunGGX(vec3 n, vec3 v, vec3 l, float Roughness, float F0){
|
||||
|
||||
// vec3 h = normalize(l + v) ;
|
||||
|
||||
// float dotNH = clamp(dot(h,n),0.,1.);
|
||||
// float dotVH = clamp(dot(h,v),0.,1.);
|
||||
|
||||
// float alpha =max(square(Roughness),1e-4) ;
|
||||
|
||||
// float WallFresnel = F0 + (1. - F0) * pow(clamp(1.0 - dotVH,0.0,1.0),5.0);
|
||||
// float Sun = square( dotNH - pow(alpha,1.5) - 1.0);
|
||||
|
||||
// float Final = ((alpha / (10.0 * Sun + 1e-4)) * WallFresnel);
|
||||
|
||||
// return Final ;
|
||||
// }
|
||||
float SunGGX(vec3 n, vec3 v, vec3 l, float roughness,float F0, float fresnel){
|
||||
|
||||
|
||||
float alpha = square(roughness) + 1e-4; // when roughness is zero it fucks up
|
||||
|
||||
vec3 h = normalize(l + v) * mix(1.000, 1.0025, pow(fresnel,2) );
|
||||
|
||||
float dotLH = clamp(dot(h,l),0.,1.);
|
||||
float dotNH = clamp(dot(h,n),0.,1.);
|
||||
float dotNL = clamp(dot(n,l),0.,1.);
|
||||
float dotNV = clamp(dot(n,v),0.,1.);
|
||||
float dotVH = clamp(dot(h,v),0.,1.);
|
||||
|
||||
|
||||
float D = alpha / (0.0541592653589793*square(square(dotNH) * (alpha - 1.0) + 1.0));
|
||||
float G = gSimple(dotNV, roughness) * gSimple(dotNL, roughness);
|
||||
float F = F0 + (1. - F0) * exp2((-5.55473*dotVH-6.98316)*dotVH);
|
||||
|
||||
return dotNL * F * (G * D / (4 * dotNV * dotNL + 1e-7));
|
||||
}
|
||||
|
||||
vec3 GGX (vec3 n, vec3 v, vec3 l, float r, vec3 F0) {
|
||||
r = pow(r,2.5);
|
||||
// r*=r;
|
||||
@ -402,254 +251,223 @@ vec3 GGX (vec3 n, vec3 v, vec3 l, float r, vec3 F0) {
|
||||
}
|
||||
|
||||
|
||||
vec3 pixelCoord (vec3 Coordinates, int Resolution){
|
||||
return floor(Coordinates / Resolution) * Resolution;
|
||||
}
|
||||
|
||||
#define PHYSICSMOD_FRAGMENT
|
||||
#include "/lib/oceans.glsl"
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
/* RENDERTARGETS:2,7,1,11,13,14 */
|
||||
/* RENDERTARGETS:2,7,11 */
|
||||
void main() {
|
||||
if (gl_FragCoord.x * texelSize.x < RENDER_SCALE.x && gl_FragCoord.y * texelSize.y < RENDER_SCALE.y ) {
|
||||
vec2 tempOffset=offsets[framemod8];
|
||||
float iswater = normalMat.w;
|
||||
vec3 fragC = gl_FragCoord.xyz*vec3(texelSize,1.0);
|
||||
vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0));
|
||||
gl_FragData[0] = texture2D(texture, lmtexcoord.xy,Texture_MipMap_Bias)*color;
|
||||
float alphalabede = gl_FragData[0].a;
|
||||
vec3 Albedo = toLinear(gl_FragData[0].rgb);
|
||||
//pain
|
||||
if (gl_FragCoord.x * texelSize.x < RENDER_SCALE.x && gl_FragCoord.y * texelSize.y < RENDER_SCALE.y ) {
|
||||
vec2 tempOffset = offsets[framemod8];
|
||||
vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0));
|
||||
|
||||
#ifdef HAND
|
||||
iswater = 0.1;
|
||||
#endif
|
||||
gl_FragData[0] = texture2D(texture, lmtexcoord.xy, Texture_MipMap_Bias) * color;
|
||||
vec3 Albedo = toLinear(gl_FragData[0].rgb);
|
||||
|
||||
#ifndef Vanilla_like_water
|
||||
if (iswater > 0.9) {
|
||||
Albedo = vec3(0.0);
|
||||
gl_FragData[0] = vec4(vec3(0.0),1.0/255.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef Vanilla_like_water
|
||||
if (iswater > 0.5) {
|
||||
gl_FragData[0].a = luma(Albedo.rgb);
|
||||
Albedo = color.rgb;
|
||||
}
|
||||
#endif
|
||||
float iswater = normalMat.w;
|
||||
|
||||
gl_FragData[4] = vec4(Albedo, gl_FragData[0].a);
|
||||
#ifdef HAND
|
||||
iswater = 0.1;
|
||||
#endif
|
||||
|
||||
vec3 normal = normalMat.xyz;
|
||||
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
|
||||
tangent.y, binormal.y, normal.y,
|
||||
tangent.z, binormal.z, normal.z);
|
||||
|
||||
vec3 WaterNormals;
|
||||
vec3 TranslucentNormals;
|
||||
|
||||
if (iswater > 0.4){
|
||||
|
||||
if(physics_iterationsNormal < 1.0){
|
||||
float bumpmult = 1.;
|
||||
|
||||
vec3 bump;
|
||||
|
||||
vec3 posxz = p3+cameraPosition;
|
||||
|
||||
posxz.xz -= posxz.y;
|
||||
|
||||
|
||||
posxz.xyz = getParallaxDisplacement(posxz,iswater,bumpmult,normalize(tbnMatrix*fragpos)) ;
|
||||
|
||||
|
||||
bump = normalize(getWaveHeight(posxz.xz,iswater));
|
||||
WaterNormals = bump; // tangent space normals for refraction
|
||||
|
||||
bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult);
|
||||
normal = normalize(bump * tbnMatrix);
|
||||
|
||||
|
||||
}else{
|
||||
vec3 PhysicsMod_normal = physics_waveNormal(physics_localPosition.xz, physics_localWaviness, physics_gameTime);
|
||||
|
||||
normal = normalize(worldToView(PhysicsMod_normal) + mix(normal, vec3(0.0), clamp(physics_localWaviness,0.0,1.0)));
|
||||
|
||||
vec3 worldSpaceNormal = normal;
|
||||
|
||||
vec3 bitangent = normalize(cross(tangent, worldSpaceNormal));
|
||||
mat3 tbn_new = mat3(tangent, binormal, worldSpaceNormal);
|
||||
vec3 tangentSpaceNormal = (worldSpaceNormal * tbn_new);
|
||||
|
||||
WaterNormals = tangentSpaceNormal ;
|
||||
}
|
||||
|
||||
}else{
|
||||
vec3 normalTex = texture2D(normals, lmtexcoord.xy, Texture_MipMap_Bias).rgb;
|
||||
|
||||
normalTex.xy = normalTex.xy*2.0-1.0;
|
||||
normalTex.z = clamp(sqrt(1.0 - dot(normalTex.xy, normalTex.xy)),0.0,1.0);
|
||||
|
||||
TranslucentNormals = normalTex;
|
||||
|
||||
normal = applyBump(tbnMatrix,normalTex);
|
||||
|
||||
#ifndef Vanilla_like_water
|
||||
if (iswater > 0.9) {
|
||||
Albedo = vec3(0.0);
|
||||
gl_FragData[0] = vec4(vec3(0.0),1.0/255.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef Vanilla_like_water
|
||||
if (iswater > 0.5) {
|
||||
gl_FragData[0].a = luma(Albedo.rgb);
|
||||
Albedo = color.rgb;
|
||||
}
|
||||
#endif
|
||||
|
||||
vec4 COLORTEST = vec4(Albedo,gl_FragData[0].a);
|
||||
|
||||
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
|
||||
vec3 normal = normalMat.xyz;
|
||||
vec2 TangentNormal = vec2(0); // for refractions
|
||||
|
||||
vec3 tangent2 = normalize(cross(tangent.rgb,normal)*tangent.w);
|
||||
mat3 tbnMatrix = mat3(tangent.x, tangent2.x, normal.x,
|
||||
tangent.y, tangent2.y, normal.y,
|
||||
tangent.z, tangent2.z, normal.z);
|
||||
|
||||
|
||||
if (iswater > 0.4){
|
||||
|
||||
TranslucentNormals += WaterNormals;
|
||||
vec4 data0 = vec4(1);
|
||||
vec4 data1 = clamp( encode(TranslucentNormals, lmtexcoord.zw),0.0,1.0);
|
||||
gl_FragData[3] = vec4(encodeVec2(data0.x,data1.x), encodeVec2(data0.y,data1.y), encodeVec2(data0.z,data1.z), encodeVec2(data1.w,data0.w));
|
||||
gl_FragData[5] = vec4(encodeVec2(lmtexcoord.a,lmtexcoord.a), encodeVec2(lmtexcoord.a,lmtexcoord.a), encodeVec2(lmtexcoord.a,lmtexcoord.a), encodeVec2(lmtexcoord.a,lmtexcoord.a));
|
||||
if(physics_iterationsNormal < 1.0){
|
||||
float bumpmult = 1.;
|
||||
vec3 bump;
|
||||
vec3 posxz = p3+cameraPosition;
|
||||
|
||||
float NdotL = clamp(lightSign*dot(normal,sunVec) ,0.0,1.0);
|
||||
NdotL = clamp((-15 + NdotL*255.0) / 240.0 ,0.0,1.0);
|
||||
posxz.xz -= posxz.y;
|
||||
posxz.xyz = getParallaxDisplacement(posxz,iswater,bumpmult,normalize(tbnMatrix*fragpos)) ;
|
||||
|
||||
bump = normalize(getWaveHeight(posxz.xz,iswater));
|
||||
|
||||
TangentNormal = bump.xy*0.5+0.5; // tangent space normals for refraction
|
||||
|
||||
bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult);
|
||||
normal = normalize(bump * tbnMatrix);
|
||||
|
||||
}else{
|
||||
vec3 PhysicsMod_normal = physics_waveNormal(physics_localPosition.xz, physics_localWaviness, physics_gameTime);
|
||||
|
||||
float Shadows = 1.0;
|
||||
float cloudShadow = 1.0;
|
||||
//compute shadows only if not backface
|
||||
if (NdotL > 0.001) {
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
vec3 projectedShadowPosition = mat3(shadowModelView) * p3 + shadowModelView[3].xyz;
|
||||
projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
|
||||
normal = normalize(worldToView(PhysicsMod_normal) + mix(normal, vec3(0.0), clamp(physics_localWaviness,0.0,1.0)));
|
||||
|
||||
//apply distortion
|
||||
float distortFactor = calcDistort(projectedShadowPosition.xy);
|
||||
projectedShadowPosition.xy *= distortFactor;
|
||||
//do shadows only if on shadow map
|
||||
if (abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution){
|
||||
const float threshMul = max(2048.0/shadowMapResolution*shadowDistance/128.0,0.95);
|
||||
float distortThresh = (sqrt(1.0-NdotL*NdotL)/NdotL+0.7)/distortFactor;
|
||||
float diffthresh = distortThresh/6000.0*threshMul;
|
||||
vec3 worldSpaceNormal = normal.xyz;
|
||||
|
||||
projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5,0.5,0.5);
|
||||
vec3 bitangent = normalize(cross(tangent.xyz, worldSpaceNormal));
|
||||
mat3 tbn_new = mat3(tangent.xyz, binormal, worldSpaceNormal);
|
||||
vec3 tangentSpaceNormal = worldSpaceNormal * tbn_new;
|
||||
|
||||
Shadows = 0.0;
|
||||
float noise = blueNoise();
|
||||
float rdMul = 4.0/shadowMapResolution;
|
||||
TangentNormal = tangentSpaceNormal.xy ;
|
||||
}
|
||||
|
||||
for(int i = 0; i < 9; i++){
|
||||
vec2 offsetS = tapLocation(i,9, 1.618,noise,0.0);
|
||||
}else{
|
||||
|
||||
float weight = 1.0+(i+noise)*rdMul/9.0*shadowMapResolution;
|
||||
Shadows += shadow2D(shadow,vec3(projectedShadowPosition + vec3(rdMul*offsetS,-diffthresh*weight))).x/9.0;
|
||||
}
|
||||
vec4 NormalTex = texture2D(normals, lmtexcoord.xy, Texture_MipMap_Bias).rgba;
|
||||
NormalTex.xy = NormalTex.xy*2.0-1.0;
|
||||
NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0) ;
|
||||
|
||||
TangentNormal = NormalTex.xy*0.5+0.5;
|
||||
|
||||
normal = applyBump(tbnMatrix, NormalTex.xyz, 1.0);
|
||||
}
|
||||
|
||||
// cannot encode alpha or it will shit its pants
|
||||
gl_FragData[2] = vec4(encodeVec2(TangentNormal), encodeVec2(COLORTEST.rg), encodeVec2(COLORTEST.ba), 1.0);
|
||||
|
||||
|
||||
float NdotL = clamp(lightSign*dot(normal,sunVec) ,0.0,1.0);
|
||||
NdotL = clamp((-15 + NdotL*255.0) / 240.0 ,0.0,1.0);
|
||||
|
||||
float Shadows = 1.0;
|
||||
//compute shadows only if not backface
|
||||
if (NdotL > 0.001) {
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
vec3 projectedShadowPosition = mat3(shadowModelView) * p3 + shadowModelView[3].xyz;
|
||||
projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
|
||||
|
||||
//apply distortion
|
||||
float distortFactor = calcDistort(projectedShadowPosition.xy);
|
||||
projectedShadowPosition.xy *= distortFactor;
|
||||
//do shadows only if on shadow map
|
||||
if (abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution){
|
||||
const float threshMul = max(2048.0/shadowMapResolution*shadowDistance/128.0,0.95);
|
||||
float distortThresh = (sqrt(1.0-NdotL*NdotL)/NdotL+0.7)/distortFactor;
|
||||
float diffthresh = distortThresh/6000.0*threshMul;
|
||||
|
||||
projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5,0.5,0.5);
|
||||
|
||||
Shadows = 0.0;
|
||||
float noise = blueNoise();
|
||||
float rdMul = 4.0/shadowMapResolution;
|
||||
|
||||
for(int i = 0; i < 9; i++){
|
||||
vec2 offsetS = tapLocation(i,9, 1.618,noise,0.0);
|
||||
|
||||
float weight = 1.0+(i+noise)*rdMul/9.0*shadowMapResolution;
|
||||
Shadows += shadow2D(shadow,vec3(projectedShadowPosition + vec3(rdMul*offsetS,-diffthresh*weight))).x/9.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef CLOUDS_SHADOWS
|
||||
Shadows *= GetCloudShadow(p3);
|
||||
#ifdef CLOUDS_SHADOWS
|
||||
Shadows *= GetCloudShadow(p3);
|
||||
#endif
|
||||
}
|
||||
|
||||
vec3 WS_normal = viewToWorld(normal);
|
||||
vec3 ambientCoefs = WS_normal/dot(abs(WS_normal),vec3(1.));
|
||||
float skylight = clamp(abs(ambientCoefs.y+1),0.35,2.0) ;
|
||||
|
||||
vec3 Indirect_lighting = DoAmbientLighting(avgAmbient, vec3(TORCH_R,TORCH_G,TORCH_B), lmtexcoord.zw, skylight);
|
||||
vec3 Direct_lighting = DoDirectLighting(lightCol.rgb/80.0, Shadows, NdotL, 0.0);
|
||||
|
||||
vec3 FinalColor = (Direct_lighting + Indirect_lighting) * Albedo;
|
||||
|
||||
#ifdef Glass_Tint
|
||||
float alphashit = min(pow(gl_FragData[0].a,2.0),1.0);
|
||||
FinalColor *= alphashit;
|
||||
#endif
|
||||
|
||||
|
||||
vec2 SpecularTex = texture2D(specular, lmtexcoord.xy, Texture_MipMap_Bias).rg;
|
||||
SpecularTex = (iswater > 0.0 && iswater < 0.9) && SpecularTex.r > 0.0 && SpecularTex.g < 0.9 ? SpecularTex : vec2(1.0,0.02);
|
||||
|
||||
if (iswater > 0.0 && (SpecularTex.g > 0.0 || SpecularTex.r > 0.0)){
|
||||
vec3 Reflections_Final = vec3(0.0);
|
||||
float roughness = max(pow(1.0-SpecularTex.r,2.0),0.05);
|
||||
float f0 = SpecularTex.g;
|
||||
|
||||
float F0 = f0;
|
||||
|
||||
vec3 reflectedVector = reflect(normalize(fragpos), normal);
|
||||
float normalDotEye = dot(normal, normalize(fragpos));
|
||||
float fresnel = pow(clamp(1.0 + normalDotEye,0.0,1.0), 5.0);
|
||||
// float unchangedfresnel = fresnel;
|
||||
|
||||
// snells window looking thing
|
||||
if(isEyeInWater == 1 && iswater > 0.99) fresnel = clamp(pow(1.66 + normalDotEye,25),0.02,1.0);
|
||||
|
||||
if(isEyeInWater == 1 && physics_iterationsNormal > 0.0) fresnel = clamp( 1.0 - (pow( normalDotEye * 1.66 ,25)),0.02,1.0);
|
||||
|
||||
fresnel = mix(F0, 1.0, fresnel);
|
||||
// fresnel = F0 + (1.0 - F0) * fresnel;
|
||||
float indoors = clamp((lmtexcoord.w-0.6)*5.0, 0.0,1.0);
|
||||
vec3 wrefl = mat3(gbufferModelViewInverse)*reflectedVector;
|
||||
|
||||
// SSR, Sky, and Sun reflections
|
||||
vec4 Reflections = vec4(0.0);
|
||||
vec3 SkyReflection = skyCloudsFromTex(wrefl,colortex4).rgb / 150. * 5.;
|
||||
vec3 SunReflection = Direct_lighting * GGX(normal, -normalize(fragpos), lightSign*sunVec, roughness, vec3(f0));
|
||||
|
||||
if(iswater > 0.0){
|
||||
#ifdef SCREENSPACE_REFLECTIONS
|
||||
vec3 rtPos = rayTrace(reflectedVector,fragpos.xyz, interleaved_gradientNoise(), fresnel, isEyeInWater == 1);
|
||||
if (rtPos.z < 1.){
|
||||
vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(rtPos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition;
|
||||
previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz;
|
||||
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) {
|
||||
Reflections.a = 1.0;
|
||||
Reflections.rgb = texture2D(colortex5,previousPosition.xy).rgb;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// vec3 ambientLight = (texture2D(gaux1,(lmtexcoord.zw*15.+0.5)*texelSize).rgb * 2.0) * 8./150./3.;
|
||||
float visibilityFactor = clamp(exp2((pow(roughness,3.0) / f0) * -4),0,1);
|
||||
|
||||
// direct *= (iswater > 0.9 ? 0.2: 1.0)*NdotL*lmtexcoord.w;
|
||||
Reflections_Final = mix(SkyReflection*indoors, Reflections.rgb, Reflections.a);
|
||||
Reflections_Final = mix(FinalColor, Reflections_Final, fresnel * visibilityFactor);
|
||||
Reflections_Final += SunReflection;
|
||||
|
||||
// vec3 directLight = direct;
|
||||
vec3 WS_normal = viewToWorld(normal);
|
||||
vec3 ambientCoefs = WS_normal/dot(abs(WS_normal),vec3(1.));
|
||||
float skylight = clamp(abs(ambientCoefs.y+1),0.35,2.0) ;
|
||||
gl_FragData[0].rgb = Reflections_Final;
|
||||
|
||||
vec3 Indirect_lighting = DoAmbientLighting(avgAmbient, vec3(TORCH_R,TORCH_G,TORCH_B), lmtexcoord.zw, skylight);
|
||||
vec3 Direct_lighting = DoDirectLighting(lightCol.rgb/80.0, Shadows, NdotL, 0.0);
|
||||
|
||||
vec3 FinalColor = (Direct_lighting + Indirect_lighting) * Albedo;
|
||||
|
||||
// if (iswater > 0.9) FinalColor = Albedo;
|
||||
|
||||
#ifdef Glass_Tint
|
||||
float alphashit = min(pow(gl_FragData[0].a,2.0),1.0);
|
||||
FinalColor *= alphashit;
|
||||
#endif
|
||||
|
||||
|
||||
vec2 SpecularTex = texture2D(specular, lmtexcoord.xy, Texture_MipMap_Bias).rg;
|
||||
SpecularTex = iswater > 0.0 && SpecularTex.r > 0.0 && SpecularTex.g < 0.9 ? SpecularTex : vec2(1.0,0.02);
|
||||
|
||||
if (iswater > 0.0 && (SpecularTex.g > 0.0 || SpecularTex.r > 0.0)){
|
||||
vec3 Reflections_Final = vec3(0.0);
|
||||
float roughness = max(pow(1.0-SpecularTex.r,2.0),0.1);
|
||||
float f0 = SpecularTex.g;
|
||||
|
||||
float F0 = f0;
|
||||
|
||||
vec3 reflectedVector = reflect(normalize(fragpos), normal);
|
||||
float normalDotEye = dot(normal, normalize(fragpos));
|
||||
float fresnel = pow(clamp(1.0 + normalDotEye,0.0,1.0), 5.0);
|
||||
// float unchangedfresnel = fresnel;
|
||||
|
||||
// snells window looking thing
|
||||
if(isEyeInWater == 1 && iswater > 0.99) fresnel = clamp(pow(1.66 + normalDotEye,25),0.02,1.0);
|
||||
|
||||
if(isEyeInWater == 1 && physics_iterationsNormal > 0.0) fresnel = clamp( 1.0 - (pow( normalDotEye * 1.66 ,25)),0.02,1.0);
|
||||
|
||||
// fresnel = mix(F0, 1.0, fresnel);
|
||||
fresnel = F0 + (1.0 - F0) * fresnel;
|
||||
float indoors = clamp((lmtexcoord.w-0.6)*5.0, 0.0,1.0);
|
||||
vec3 wrefl = mat3(gbufferModelViewInverse)*reflectedVector;
|
||||
|
||||
// SSR, Sky, and Sun reflections
|
||||
vec4 Reflections = vec4(0.0);
|
||||
vec3 SkyReflection = skyCloudsFromTex(wrefl,colortex4).rgb / 150. * 5.;
|
||||
vec3 SunReflection = Direct_lighting * GGX(normal, -normalize(fragpos), lightSign*sunVec, roughness, f0);
|
||||
// vec3 SunReflection = Direct_lighting * SunGGX(normal, -normalize(fragpos), lightSign*sunVec, roughness, f0, fresnel);
|
||||
|
||||
if(iswater > 0.0){
|
||||
#ifdef SCREENSPACE_REFLECTIONS
|
||||
vec3 rtPos = rayTrace(reflectedVector,fragpos.xyz, interleaved_gradientNoise(), fresnel, isEyeInWater == 1);
|
||||
if (rtPos.z < 1.){
|
||||
vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(rtPos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition;
|
||||
previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz;
|
||||
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) {
|
||||
|
||||
Reflections.a = 1.0;
|
||||
Reflections.rgb = texture2D(colortex5,previousPosition.xy).rgb;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
float visibilityFactor = clamp(exp2((pow(roughness,3.0) / f0) * -4),0,1);
|
||||
|
||||
Reflections_Final = mix(SkyReflection*indoors, Reflections.rgb, Reflections.a);
|
||||
Reflections_Final = mix(FinalColor, Reflections_Final, fresnel * visibilityFactor);
|
||||
Reflections_Final += SunReflection;
|
||||
|
||||
|
||||
gl_FragData[0].rgb = Reflections_Final;
|
||||
|
||||
//correct alpha channel with fresnel
|
||||
float alpha0 = gl_FragData[0].a;
|
||||
gl_FragData[0].a = -gl_FragData[0].a*fresnel+gl_FragData[0].a+fresnel;
|
||||
|
||||
if (gl_FragData[0].r > 65000.) gl_FragData[0].rgba = vec4(0.);
|
||||
|
||||
// //suffering
|
||||
// #ifdef SPIDEREYES
|
||||
// gl_FragData[0].rgb = Albedo.rgb * 10;
|
||||
// #endif
|
||||
|
||||
} else {
|
||||
gl_FragData[0].rgb = FinalColor;
|
||||
}
|
||||
|
||||
#ifndef HAND
|
||||
gl_FragData[1] = vec4(Albedo,iswater);
|
||||
#endif
|
||||
// #endif
|
||||
//correct alpha channel with fresnel
|
||||
float alpha0 = gl_FragData[0].a;
|
||||
gl_FragData[0].a = -gl_FragData[0].a*fresnel+gl_FragData[0].a+fresnel;
|
||||
|
||||
if (gl_FragData[0].r > 65000.) gl_FragData[0].rgba = vec4(0.);
|
||||
|
||||
} else {
|
||||
gl_FragData[0].rgb = FinalColor;
|
||||
}
|
||||
|
||||
#ifndef HAND
|
||||
gl_FragData[1] = vec4(Albedo,iswater);
|
||||
#endif
|
||||
}
|
||||
}
|
@ -15,7 +15,8 @@ varying vec4 lmtexcoord;
|
||||
varying vec4 color;
|
||||
varying vec4 normalMat;
|
||||
varying vec3 binormal;
|
||||
varying vec3 tangent;
|
||||
varying vec4 tangent;
|
||||
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
varying vec3 viewVector;
|
||||
|
||||
@ -84,12 +85,16 @@ void main() {
|
||||
}
|
||||
|
||||
lmtexcoord.xy = (gl_MultiTexCoord0).xy;
|
||||
vec2 lmcoord = gl_MultiTexCoord1.xy/255.;
|
||||
vec2 lmcoord = gl_MultiTexCoord1.xy / 255.0; // is this even correct? lol
|
||||
lmtexcoord.zw = lmcoord;
|
||||
|
||||
|
||||
|
||||
vec3 position = mat3(gl_ModelViewMatrix) * vec3(Swtich_gl_vertex) + gl_ModelViewMatrix[3].xyz;
|
||||
gl_Position = toClipSpace3(position);
|
||||
color = gl_Color;
|
||||
|
||||
color = vec4(gl_Color.rgb,1.0);
|
||||
|
||||
float mat = 0.0;
|
||||
|
||||
if(mc_Entity.x == 8.0 || mc_Entity.x == 9.0) {
|
||||
@ -106,18 +111,21 @@ void main() {
|
||||
#endif
|
||||
|
||||
|
||||
normalMat = vec4(normalize( gl_NormalMatrix*gl_Normal),mat);
|
||||
tangent = vec4(normalize(gl_NormalMatrix *at_tangent.rgb),at_tangent.w);
|
||||
|
||||
normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal), 1.0);
|
||||
normalMat.a = mat;
|
||||
|
||||
|
||||
|
||||
tangent_other = vec4(normalize(gl_NormalMatrix * at_tangent.rgb),normalMat.a);
|
||||
|
||||
tangent = normalize( gl_NormalMatrix *at_tangent.rgb);
|
||||
binormal = normalize(cross(tangent.rgb,normalMat.xyz)*at_tangent.w);
|
||||
|
||||
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normalMat.x,
|
||||
tangent.y, binormal.y, normalMat.y,
|
||||
tangent.z, binormal.z, normalMat.z);
|
||||
vec3 tangent2 = normalize( gl_NormalMatrix *at_tangent.rgb);
|
||||
binormal = normalize(cross(tangent2.rgb,normalMat.xyz)*at_tangent.w);
|
||||
|
||||
mat3 tbnMatrix = mat3(tangent2.x, binormal.x, normalMat.x,
|
||||
tangent2.y, binormal.y, normalMat.y,
|
||||
tangent2.z, binormal.z, normalMat.z);
|
||||
|
||||
viewVector = ( gl_ModelViewMatrix * Swtich_gl_vertex).xyz;
|
||||
viewVector = normalize(tbnMatrix * viewVector);
|
||||
|
@ -447,7 +447,7 @@ void main() {
|
||||
|
||||
|
||||
|
||||
gl_FragData[4] = vec4(Albedo, gl_FragData[0].a);
|
||||
// gl_FragData[4] = vec4(Albedo, gl_FragData[0].a);
|
||||
|
||||
|
||||
vec2 tempOffset=offsets[framemod8];
|
||||
|
Loading…
Reference in New Issue
Block a user