From 48215794137b4a00dede80b31a24661dca212366 Mon Sep 17 00:00:00 2001 From: Lubos Lenco Date: Tue, 26 May 2020 19:22:39 +0200 Subject: [PATCH] Shader cleanup --- .../Sources/arm/node/MaterialFunctions.hx | 6 ------ Shaders/common/Gizmo_overlay.frag.glsl | 16 +------------- Shaders/common/Material2_mesh.frag.glsl | 4 +--- Shaders/common/Material_mesh.frag.glsl | 4 +--- Shaders/common/armdefault_mesh.frag.glsl | 4 +--- Shaders/common/ssr_pass.frag.glsl | 5 +---- Shaders/creator/deferred_light.frag.glsl | 21 +++++++++---------- .../creator/deferred_light_voxel.frag.glsl | 21 +++++++++---------- Shaders/painter/deferred_light.frag.glsl | 21 +++++++++---------- .../painter/deferred_light_voxel.frag.glsl | 21 +++++++++---------- Shaders/std/gbuffer.glsl | 9 -------- Shaders/std/light.glsl | 6 +++--- Sources/arm/node/MakeMesh.hx | 8 +++---- Sources/arm/node/MakeMeshPreview.hx | 6 +++--- 14 files changed, 55 insertions(+), 97 deletions(-) diff --git a/Libraries/nodelib/Sources/arm/node/MaterialFunctions.hx b/Libraries/nodelib/Sources/arm/node/MaterialFunctions.hx index 1a7867b1..1659788b 100644 --- a/Libraries/nodelib/Sources/arm/node/MaterialFunctions.hx +++ b/Libraries/nodelib/Sources/arm/node/MaterialFunctions.hx @@ -263,12 +263,6 @@ mat3 cotangentFrame(const vec3 n, const vec3 p, const vec2 texCoord) { vec2 octahedronWrap(const vec2 v) { return (1.0 - abs(v.yx)) * (vec2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0)); } -"; - - public static var str_packFloat2 = " -float packFloat2(const float f1, const float f2) { - return floor(f1 * 255.0) + min(f2, 1.0 - 1.0 / 100.0); -} "; public static var str_packFloatInt16 = " diff --git a/Shaders/common/Gizmo_overlay.frag.glsl b/Shaders/common/Gizmo_overlay.frag.glsl index f51646d4..de8f0a27 100644 --- a/Shaders/common/Gizmo_overlay.frag.glsl +++ b/Shaders/common/Gizmo_overlay.frag.glsl @@ -3,20 +3,6 @@ in vec3 vcolor; in vec3 wnormal; out vec4 fragColor; void main() { - vec3 n = normalize(wnormal); - vec3 basecol; - float roughness; - float metallic; - float occlusion; - float specular; - float emission; - vec3 Attribute_Color_res = vcolor; - basecol = Attribute_Color_res; - roughness = 0.0; - metallic = 0.0; - occlusion = 1.0; - specular = 0.0; - emission = 0.0; - fragColor = vec4(basecol, 1.0); + fragColor = vec4(vcolor, 1.0); fragColor.rgb = pow(fragColor.rgb, vec3(1.0 / 2.2)); } diff --git a/Shaders/common/Material2_mesh.frag.glsl b/Shaders/common/Material2_mesh.frag.glsl index 4343149d..be938341 100644 --- a/Shaders/common/Material2_mesh.frag.glsl +++ b/Shaders/common/Material2_mesh.frag.glsl @@ -10,20 +10,18 @@ vec3 n = normalize(wnormal); float roughness; float metallic; float occlusion; - float specular; float emission; basecol = vec3(0.800000011920929, 0.800000011920929, 0.800000011920929); roughness = 0.0; metallic = 0.0; occlusion = 1.0; - specular = 0.0; emission = 0.0; n /= (abs(n.x) + abs(n.y) + abs(n.z)); n.xy = n.z >= 0.0 ? n.xy : octahedronWrap(n.xy); uint matid = 0; if (emission > 0) { basecol *= emission; matid = 1; } fragColor[0] = vec4(n.xy, roughness, packFloatInt16(metallic, matid)); - fragColor[1] = vec4(basecol, packFloat2(occlusion, specular)); + fragColor[1] = vec4(basecol, occlusion); vec2 posa = (wvpposition.xy / wvpposition.w) * 0.5 + 0.5; vec2 posb = (prevwvpposition.xy / prevwvpposition.w) * 0.5 + 0.5; fragColor[2].rg = vec2(posa - posb); diff --git a/Shaders/common/Material_mesh.frag.glsl b/Shaders/common/Material_mesh.frag.glsl index 98ec3055..80a33bd1 100644 --- a/Shaders/common/Material_mesh.frag.glsl +++ b/Shaders/common/Material_mesh.frag.glsl @@ -12,7 +12,6 @@ void main() { float roughness; float metallic; float occlusion; - float specular; float emission; float Mix_fac = 0.0; vec3 RGB_Color_res = vec3(0.2176000028848648, 0.2176000028848648, 0.2176000028848648); @@ -24,14 +23,13 @@ void main() { roughness = 0.4000000059604645; metallic = 0.0; occlusion = 1.0; - specular = 1.0; emission = 0.0; n /= (abs(n.x) + abs(n.y) + abs(n.z)); n.xy = n.z >= 0.0 ? n.xy : octahedronWrap(n.xy); uint matid = 0; if (emission > 0) { basecol *= emission; matid = 1; } fragColor[0] = vec4(n.xy, roughness, packFloatInt16(metallic, matid)); - fragColor[1] = vec4(basecol, packFloat2(occlusion, specular)); + fragColor[1] = vec4(basecol, occlusion); vec2 posa = (wvpposition.xy / wvpposition.w) * 0.5 + 0.5; vec2 posb = (prevwvpposition.xy / prevwvpposition.w) * 0.5 + 0.5; fragColor[2].rg = vec2(posa - posb); diff --git a/Shaders/common/armdefault_mesh.frag.glsl b/Shaders/common/armdefault_mesh.frag.glsl index ded6ab2b..38b080c8 100644 --- a/Shaders/common/armdefault_mesh.frag.glsl +++ b/Shaders/common/armdefault_mesh.frag.glsl @@ -10,20 +10,18 @@ vec3 n = normalize(wnormal); float roughness; float metallic; float occlusion; - float specular; float emission; basecol = vec3(0.800000011920929, 0.800000011920929, 0.800000011920929); roughness = 0.25; metallic = 0.0; occlusion = 1.0; - specular = 0.5; emission = 0.0; n /= (abs(n.x) + abs(n.y) + abs(n.z)); n.xy = n.z >= 0.0 ? n.xy : octahedronWrap(n.xy); uint matid = 0; if (emission > 0) { basecol *= emission; matid = 1; } fragColor[0] = vec4(n.xy, roughness, packFloatInt16(metallic, matid)); - fragColor[1] = vec4(basecol, packFloat2(occlusion, specular)); + fragColor[1] = vec4(basecol, occlusion); vec2 posa = (wvpposition.xy / wvpposition.w) * 0.5 + 0.5; vec2 posb = (prevwvpposition.xy / prevwvpposition.w) * 0.5 + 0.5; fragColor[2].rg = vec2(posa - posb); diff --git a/Shaders/common/ssr_pass.frag.glsl b/Shaders/common/ssr_pass.frag.glsl index ab501ab9..2fe0c823 100644 --- a/Shaders/common/ssr_pass.frag.glsl +++ b/Shaders/common/ssr_pass.frag.glsl @@ -12,7 +12,7 @@ const float ssrJitter = 0.6; uniform sampler2D tex; uniform sampler2D gbufferD; uniform sampler2D gbuffer0; // Normal, roughness -uniform sampler2D gbuffer1; // basecol, spec +uniform sampler2D gbuffer1; // basecol, occ uniform mat4 P; uniform mat3 V3; uniform vec2 cameraProj; @@ -71,9 +71,6 @@ void main() { float roughness = g0.b; if (roughness == 1.0) { fragColor.rgb = vec3(0.0); return; } - float spec = fract(textureLod(gbuffer1, texCoord, 0.0).a); - if (spec == 0.0) { fragColor.rgb = vec3(0.0); return; } - float d = textureLod(gbufferD, texCoord, 0.0).r * 2.0 - 1.0; if (d == 1.0) { fragColor.rgb = vec3(0.0); return; } diff --git a/Shaders/creator/deferred_light.frag.glsl b/Shaders/creator/deferred_light.frag.glsl index a56cf967..94806c37 100644 --- a/Shaders/creator/deferred_light.frag.glsl +++ b/Shaders/creator/deferred_light.frag.glsl @@ -183,8 +183,8 @@ void main() { float metallic; uint matid; unpackFloatInt16(g0.a, metallic, matid); - vec4 g1 = textureLod(gbuffer1, texCoord, 0.0); // Basecolor.rgb, spec/occ - vec2 occspec = unpackFloat2(g1.a); + vec4 g1 = textureLod(gbuffer1, texCoord, 0.0); // Basecolor.rgb, occ + float occ = g1.a; vec3 albedo = surfaceAlbedo(g1.rgb, metallic); // g1.rgb - basecolor vec3 f0 = surfaceF0(g1.rgb, metallic); @@ -194,7 +194,7 @@ void main() { float dotNV = max(dot(n, v), 0.0); #ifdef _MicroShadowing - occspec.x = mix(1.0, occspec.x, dotNV); // AO Fresnel + occ = mix(1.0, occ, dotNV); // AO Fresnel #endif #ifdef _Brdf @@ -227,14 +227,14 @@ void main() { envl.rgb *= albedo; #ifdef _Rad // Indirect specular - envl.rgb += prefilteredColor * (f0 * envBRDF.x + envBRDF.y) * 1.5 * occspec.y; + envl.rgb += prefilteredColor * (f0 * envBRDF.x + envBRDF.y) * 1.5; #else #ifdef _EnvCol envl.rgb += backgroundCol * surfaceF0(g1.rgb, metallic); // f0 #endif #endif - envl.rgb *= envmapStrength * occspec.x; + envl.rgb *= envmapStrength * occ; #ifdef _VoxelAOvar @@ -292,7 +292,7 @@ void main() { float sdotNL = dot(n, sunDir); float svisibility = 1.0; vec3 sdirect = lambertDiffuseBRDF(albedo, sdotNL) + - specularBRDF(f0, roughness, sdotNL, sdotNH, dotNV, sdotVH) * occspec.y; + specularBRDF(f0, roughness, sdotNL, sdotNH, dotNV, sdotVH); #ifdef _ShadowMap #ifdef _CSM @@ -323,7 +323,7 @@ void main() { #endif #ifdef _MicroShadowing - svisibility *= sdotNL + 2.0 * occspec.x * occspec.x - 1.0; + svisibility *= sdotNL + 2.0 * occ * occ - 1.0; #endif fragColor.rgb += sdirect * svisibility * sunCol; @@ -353,7 +353,7 @@ void main() { #ifdef _SinglePoint fragColor.rgb += sampleLight( - p, n, v, dotNV, pointPos, pointCol, albedo, roughness, occspec.y, f0 + p, n, v, dotNV, pointPos, pointCol, albedo, roughness, f0 #ifdef _ShadowMap , 0, pointBias #endif @@ -366,7 +366,7 @@ void main() { #endif #endif #ifdef _MicroShadowing - , occspec.x + , occ #endif ); @@ -403,7 +403,6 @@ void main() { lightsArray[li * 2 + 1].xyz, // lightCol albedo, roughness, - occspec.y, f0 #ifdef _ShadowMap , li, lightsArray[li * 2].w // bias @@ -415,7 +414,7 @@ void main() { , lightsArraySpot[li].xyz // spotDir #endif #ifdef _MicroShadowing - , occspec.x + , occ #endif ); } diff --git a/Shaders/creator/deferred_light_voxel.frag.glsl b/Shaders/creator/deferred_light_voxel.frag.glsl index 8c50a5ab..68a71ba3 100644 --- a/Shaders/creator/deferred_light_voxel.frag.glsl +++ b/Shaders/creator/deferred_light_voxel.frag.glsl @@ -187,8 +187,8 @@ void main() { float metallic; uint matid; unpackFloatInt16(g0.a, metallic, matid); - vec4 g1 = textureLod(gbuffer1, texCoord, 0.0); // Basecolor.rgb, spec/occ - vec2 occspec = unpackFloat2(g1.a); + vec4 g1 = textureLod(gbuffer1, texCoord, 0.0); // Basecolor.rgb, occ + float occ = g1.a; vec3 albedo = surfaceAlbedo(g1.rgb, metallic); // g1.rgb - basecolor vec3 f0 = surfaceF0(g1.rgb, metallic); @@ -198,7 +198,7 @@ void main() { float dotNV = max(dot(n, v), 0.0); #ifdef _MicroShadowing - occspec.x = mix(1.0, occspec.x, dotNV); // AO Fresnel + occ = mix(1.0, occ, dotNV); // AO Fresnel #endif #ifdef _Brdf @@ -231,14 +231,14 @@ void main() { envl.rgb *= albedo; #ifdef _Rad // Indirect specular - envl.rgb += prefilteredColor * (f0 * envBRDF.x + envBRDF.y) * 1.5 * occspec.y; + envl.rgb += prefilteredColor * (f0 * envBRDF.x + envBRDF.y) * 1.5; #else #ifdef _EnvCol envl.rgb += backgroundCol * surfaceF0(g1.rgb, metallic); // f0 #endif #endif - envl.rgb *= envmapStrength * occspec.x; + envl.rgb *= envmapStrength * occ; #ifdef _VoxelAOvar @@ -296,7 +296,7 @@ void main() { float sdotNL = dot(n, sunDir); float svisibility = 1.0; vec3 sdirect = lambertDiffuseBRDF(albedo, sdotNL) + - specularBRDF(f0, roughness, sdotNL, sdotNH, dotNV, sdotVH) * occspec.y; + specularBRDF(f0, roughness, sdotNL, sdotNH, dotNV, sdotVH); #ifdef _ShadowMap #ifdef _CSM @@ -327,7 +327,7 @@ void main() { #endif #ifdef _MicroShadowing - svisibility *= sdotNL + 2.0 * occspec.x * occspec.x - 1.0; + svisibility *= sdotNL + 2.0 * occ * occ - 1.0; #endif fragColor.rgb += sdirect * svisibility * sunCol; @@ -357,7 +357,7 @@ void main() { #ifdef _SinglePoint fragColor.rgb += sampleLight( - p, n, v, dotNV, pointPos, pointCol, albedo, roughness, occspec.y, f0 + p, n, v, dotNV, pointPos, pointCol, albedo, roughness, f0 #ifdef _ShadowMap , 0, pointBias #endif @@ -370,7 +370,7 @@ void main() { #endif #endif #ifdef _MicroShadowing - , occspec.x + , occ #endif ); @@ -407,7 +407,6 @@ void main() { lightsArray[li * 2 + 1].xyz, // lightCol albedo, roughness, - occspec.y, f0 #ifdef _ShadowMap , li, lightsArray[li * 2].w // bias @@ -419,7 +418,7 @@ void main() { , lightsArraySpot[li].xyz // spotDir #endif #ifdef _MicroShadowing - , occspec.x + , occ #endif ); } diff --git a/Shaders/painter/deferred_light.frag.glsl b/Shaders/painter/deferred_light.frag.glsl index e0dc64be..f3d60a4c 100644 --- a/Shaders/painter/deferred_light.frag.glsl +++ b/Shaders/painter/deferred_light.frag.glsl @@ -186,8 +186,8 @@ void main() { float metallic; uint matid; unpackFloatInt16(g0.a, metallic, matid); - vec4 g1 = textureLod(gbuffer1, texCoord, 0.0); // Basecolor.rgb, spec/occ - vec2 occspec = unpackFloat2(g1.a); + vec4 g1 = textureLod(gbuffer1, texCoord, 0.0); // Basecolor.rgb, occ + float occ = g1.a; vec3 albedo = surfaceAlbedo(g1.rgb, metallic); // g1.rgb - basecolor vec3 f0 = surfaceF0(g1.rgb, metallic); @@ -197,7 +197,7 @@ void main() { float dotNV = max(dot(n, v), 0.0); #ifdef _MicroShadowing - occspec.x = mix(1.0, occspec.x, dotNV); // AO Fresnel + occ = mix(1.0, occ, dotNV); // AO Fresnel #endif #ifdef _Brdf @@ -230,14 +230,14 @@ void main() { envl.rgb *= albedo; #ifdef _Rad // Indirect specular - envl.rgb += prefilteredColor * (f0 * envBRDF.x + envBRDF.y) * 1.5 * occspec.y; + envl.rgb += prefilteredColor * (f0 * envBRDF.x + envBRDF.y) * 1.5; #else #ifdef _EnvCol envl.rgb += backgroundCol * surfaceF0(g1.rgb, metallic); // f0 #endif #endif - envl.rgb *= envmapStrength * occspec.x; + envl.rgb *= envmapStrength * occ; #ifdef _VoxelAOvar @@ -295,7 +295,7 @@ void main() { float sdotNL = dot(n, sunDir); float svisibility = 1.0; vec3 sdirect = lambertDiffuseBRDF(albedo, sdotNL) + - specularBRDF(f0, roughness, sdotNL, sdotNH, dotNV, sdotVH) * occspec.y; + specularBRDF(f0, roughness, sdotNL, sdotNH, dotNV, sdotVH); #ifdef _ShadowMap #ifdef _CSM @@ -326,7 +326,7 @@ void main() { #endif #ifdef _MicroShadowing - svisibility *= sdotNL + 2.0 * occspec.x * occspec.x - 1.0; + svisibility *= sdotNL + 2.0 * occ * occ - 1.0; #endif fragColor.rgb += sdirect * svisibility * sunCol; @@ -356,7 +356,7 @@ void main() { #ifdef _SinglePoint fragColor.rgb += sampleLight( - p, n, v, dotNV, pointPos, pointCol, albedo, roughness, occspec.y, f0 + p, n, v, dotNV, pointPos, pointCol, albedo, roughness, f0 #ifdef _ShadowMap , 0, pointBias #endif @@ -369,7 +369,7 @@ void main() { #endif #endif #ifdef _MicroShadowing - , occspec.x + , occ #endif ); @@ -406,7 +406,6 @@ void main() { lightsArray[li * 2 + 1].xyz, // lightCol albedo, roughness, - occspec.y, f0 #ifdef _ShadowMap , li, lightsArray[li * 2].w // bias @@ -418,7 +417,7 @@ void main() { , lightsArraySpot[li].xyz // spotDir #endif #ifdef _MicroShadowing - , occspec.x + , occ #endif ); } diff --git a/Shaders/painter/deferred_light_voxel.frag.glsl b/Shaders/painter/deferred_light_voxel.frag.glsl index 2ebd9e0c..46364d55 100644 --- a/Shaders/painter/deferred_light_voxel.frag.glsl +++ b/Shaders/painter/deferred_light_voxel.frag.glsl @@ -187,8 +187,8 @@ void main() { float metallic; uint matid; unpackFloatInt16(g0.a, metallic, matid); - vec4 g1 = textureLod(gbuffer1, texCoord, 0.0); // Basecolor.rgb, spec/occ - vec2 occspec = unpackFloat2(g1.a); + vec4 g1 = textureLod(gbuffer1, texCoord, 0.0); // Basecolor.rgb, occ + float occ = g1.a; vec3 albedo = surfaceAlbedo(g1.rgb, metallic); // g1.rgb - basecolor vec3 f0 = surfaceF0(g1.rgb, metallic); @@ -198,7 +198,7 @@ void main() { float dotNV = max(dot(n, v), 0.0); #ifdef _MicroShadowing - occspec.x = mix(1.0, occspec.x, dotNV); // AO Fresnel + occ = mix(1.0, occ, dotNV); // AO Fresnel #endif #ifdef _Brdf @@ -231,14 +231,14 @@ void main() { envl.rgb *= albedo; #ifdef _Rad // Indirect specular - envl.rgb += prefilteredColor * (f0 * envBRDF.x + envBRDF.y) * 1.5 * occspec.y; + envl.rgb += prefilteredColor * (f0 * envBRDF.x + envBRDF.y) * 1.5; #else #ifdef _EnvCol envl.rgb += backgroundCol * surfaceF0(g1.rgb, metallic); // f0 #endif #endif - envl.rgb *= envmapStrength * occspec.x; + envl.rgb *= envmapStrength * occ; #ifdef _VoxelAOvar @@ -296,7 +296,7 @@ void main() { float sdotNL = dot(n, sunDir); float svisibility = 1.0; vec3 sdirect = lambertDiffuseBRDF(albedo, sdotNL) + - specularBRDF(f0, roughness, sdotNL, sdotNH, dotNV, sdotVH) * occspec.y; + specularBRDF(f0, roughness, sdotNL, sdotNH, dotNV, sdotVH); #ifdef _ShadowMap #ifdef _CSM @@ -327,7 +327,7 @@ void main() { #endif #ifdef _MicroShadowing - svisibility *= sdotNL + 2.0 * occspec.x * occspec.x - 1.0; + svisibility *= sdotNL + 2.0 * occ * occ - 1.0; #endif fragColor.rgb += sdirect * svisibility * sunCol; @@ -357,7 +357,7 @@ void main() { #ifdef _SinglePoint fragColor.rgb += sampleLight( - p, n, v, dotNV, pointPos, pointCol, albedo, roughness, occspec.y, f0 + p, n, v, dotNV, pointPos, pointCol, albedo, roughness, f0 #ifdef _ShadowMap , 0, pointBias #endif @@ -370,7 +370,7 @@ void main() { #endif #endif #ifdef _MicroShadowing - , occspec.x + , occ #endif ); @@ -407,7 +407,6 @@ void main() { lightsArray[li * 2 + 1].xyz, // lightCol albedo, roughness, - occspec.y, f0 #ifdef _ShadowMap , li, lightsArray[li * 2].w // bias @@ -419,7 +418,7 @@ void main() { , lightsArraySpot[li].xyz // spotDir #endif #ifdef _MicroShadowing - , occspec.x + , occ #endif ); } diff --git a/Shaders/std/gbuffer.glsl b/Shaders/std/gbuffer.glsl index f63652f9..f42a5102 100644 --- a/Shaders/std/gbuffer.glsl +++ b/Shaders/std/gbuffer.glsl @@ -71,15 +71,6 @@ vec3 getPos2NoEye(const vec3 eye, const mat4 invVP, const float depth, const vec return pos.xyz - eye; } -float packFloat2(const float f1, const float f2) { - // Higher f1 = less precise f2 - return floor(f1 * 255.0) + min(f2, 1.0 - 1.0 / 100.0); -} - -vec2 unpackFloat2(const float f) { - return vec2(floor(f) / 255.0, fract(f)); -} - vec4 encodeRGBM(const vec3 rgb) { const float maxRange = 6.0; float maxRGB = max(rgb.x, max(rgb.g, rgb.b)); diff --git a/Shaders/std/light.glsl b/Shaders/std/light.glsl index e8c5b38b..9ba2f93a 100644 --- a/Shaders/std/light.glsl +++ b/Shaders/std/light.glsl @@ -64,7 +64,7 @@ uniform sampler2D sltcMag; #endif vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, const vec3 lp, const vec3 lightCol, - const vec3 albedo, const float rough, const float spec, const vec3 f0 + const vec3 albedo, const float rough, const vec3 f0 #ifdef _ShadowMap , int index, float bias #endif @@ -99,10 +99,10 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co float ltcspec = ltcEvaluate(n, v, dotNV, p, invM, lightArea0, lightArea1, lightArea2, lightArea3); ltcspec *= textureLod(sltcMag, tuv, 0.0).a; float ltcdiff = ltcEvaluate(n, v, dotNV, p, mat3(1.0), lightArea0, lightArea1, lightArea2, lightArea3); - vec3 direct = albedo * ltcdiff + ltcspec * spec * 0.05; + vec3 direct = albedo * ltcdiff + ltcspec * 0.05; #else vec3 direct = lambertDiffuseBRDF(albedo, dotNL) + - specularBRDF(f0, rough, dotNL, dotNH, dotNV, dotVH) * spec; + specularBRDF(f0, rough, dotNL, dotNH, dotNV, dotVH); #endif direct *= attenuate(distance(p, lp)); direct *= lightCol; diff --git a/Sources/arm/node/MakeMesh.hx b/Sources/arm/node/MakeMesh.hx index 8ba1e686..6ea09a69 100644 --- a/Sources/arm/node/MakeMesh.hx +++ b/Sources/arm/node/MakeMesh.hx @@ -14,7 +14,8 @@ class MakeMesh { compare_mode: "less", cull_mode: Context.cullBackfaces ? "clockwise" : "none", vertex_elements: [{name: "pos", data: "short4norm"},{name: "nor", data: "short2norm"},{name: "tex", data: "short2norm"}], - color_attachments: ["RGBA64", "RGBA64", "RGBA64"] + color_attachments: ["RGBA64", "RGBA64", "RGBA64"], + depth_attachment: "DEPTH32" }); var vert = con_mesh.make_vert(); @@ -64,13 +65,12 @@ class MakeMesh { frag.n = true; frag.add_function(MaterialFunctions.str_packFloatInt16); - frag.add_function(MaterialFunctions.str_packFloat2); if (Context.tool == ToolColorId) { frag.add_uniform('sampler2D texcolorid', '_texcolorid'); frag.write('fragColor[0] = vec4(n.xy, 1.0, packFloatInt16(0.0, uint(0)));'); // met/rough frag.write('vec3 idcol = pow(textureLod(texcolorid, texCoord, 0.0).rgb, vec3(2.2, 2.2, 2.2));'); - frag.write('fragColor[1] = vec4(idcol.rgb, packFloat2(1.0, 1.0));'); // occ/spec + frag.write('fragColor[1] = vec4(idcol.rgb, 1.0);'); // occ } else { frag.add_function(MaterialFunctions.str_octahedronWrap); @@ -392,7 +392,7 @@ class MakeMesh { } else { // Deferred, Pathtraced if (MaterialBuilder.emisUsed) frag.write('if (matid == 1.0) basecol *= 10.0;'); // Boost for bloom - frag.write('fragColor[1] = vec4(basecol, packFloat2(occlusion, 1.0));'); // occ/spec + frag.write('fragColor[1] = vec4(basecol, occlusion);'); } } else if (Context.viewportMode == ViewBaseColor) { diff --git a/Sources/arm/node/MakeMeshPreview.hx b/Sources/arm/node/MakeMeshPreview.hx index f8832353..eae12b83 100644 --- a/Sources/arm/node/MakeMeshPreview.hx +++ b/Sources/arm/node/MakeMeshPreview.hx @@ -21,7 +21,8 @@ class MakeMeshPreview { compare_mode: "less", cull_mode: (Context.cullBackfaces || !isScene) ? "clockwise" : "none", vertex_elements: [{name: "pos", data: "short4norm"}, {name: "nor", data: "short2norm"}, {name: "tex", data: "short2norm"}], - color_attachments: ["RGBA64", "RGBA64", "RGBA64"] + color_attachments: ["RGBA64", "RGBA64", "RGBA64"], + depth_attachment: "DEPTH32" }); var vert = con_mesh.make_vert(); @@ -92,7 +93,6 @@ class MakeMeshPreview { frag.n = true; frag.add_function(MaterialFunctions.str_packFloatInt16); - frag.add_function(MaterialFunctions.str_packFloat2); frag.add_function(MaterialFunctions.str_cotangentFrame); frag.add_function(MaterialFunctions.str_octahedronWrap); @@ -116,7 +116,7 @@ class MakeMeshPreview { frag.write('n.xy = n.z >= 0.0 ? n.xy : octahedronWrap(n.xy);'); // uint matid = 0; frag.write('fragColor[0] = vec4(n.x, n.y, roughness, packFloatInt16(metallic, uint(0)));'); // metallic/matid - frag.write('fragColor[1] = vec4(basecol.r, basecol.g, basecol.b, packFloat2(occlusion, 1.0));'); // occ/spec + frag.write('fragColor[1] = vec4(basecol.r, basecol.g, basecol.b, occlusion);'); frag.write('fragColor[2] = vec4(0.0, 0.0, 0.0, 0.0);'); // veloc Material.finalize(con_mesh);