diff --git a/armorpaint/sources/make_paint.ts b/armorpaint/sources/make_paint.ts index 979e336f..12f1395f 100644 --- a/armorpaint/sources/make_paint.ts +++ b/armorpaint/sources/make_paint.ts @@ -275,12 +275,8 @@ function make_paint_run(data: material_t, matcon: material_context_t): node_shad // Height used for the first time, also rebuild vertex shader return make_paint_run(data, matcon); } - if (emis != "0.0" && emis != "0") { - make_material_emis_used = true; - } - if (subs != "0.0" && subs != "0") { - make_material_subs_used = true; - } + make_material_emis_used = emis != "0.0" && emis != "0"; + make_material_subs_used = subs != "0.0" && subs != "0"; } if (context_raw.brush_mask_image != null && context_raw.tool == workspace_tool_t.DECAL) { @@ -391,13 +387,13 @@ function make_paint_run(data: material_t, matcon: material_context_t): node_shad node_shader_write(frag, "float matid = " + matid_string + ";"); // matid % 3 == 0 - normal, 1 - emission, 2 - subsurface - if (context_raw.material.paint_emis) { + if (context_raw.material.paint_emis && make_material_emis_used) { node_shader_write(frag, "if (emis > 0.0) {"); node_shader_write(frag, " matid += 1.0 / 255.0;"); node_shader_write(frag, " if (str == 0.0) discard;"); node_shader_write(frag, "}"); } - else if (context_raw.material.paint_subs) { + else if (context_raw.material.paint_subs && make_material_subs_used) { node_shader_write(frag, "if (subs > 0.0) {"); node_shader_write(frag, " matid += 2.0 / 255.0;"); node_shader_write(frag, " if (str == 0.0) discard;"); diff --git a/base/shaders/raytrace/raytrace_brute_forge_full.spirv b/base/shaders/raytrace/raytrace_brute_forge_full.spirv index 82bbaa19..dce7e210 100644 Binary files a/base/shaders/raytrace/raytrace_brute_forge_full.spirv and b/base/shaders/raytrace/raytrace_brute_forge_full.spirv differ diff --git a/base/shaders/raytrace/raytrace_brute_full.spirv b/base/shaders/raytrace/raytrace_brute_full.spirv index a0081142..283ea236 100644 Binary files a/base/shaders/raytrace/raytrace_brute_full.spirv and b/base/shaders/raytrace/raytrace_brute_full.spirv differ diff --git a/base/shaders/raytrace/src/raytrace_brute.hlsl b/base/shaders/raytrace/src/raytrace_brute.hlsl index 284c3268..b90a1565 100644 --- a/base/shaders/raytrace/src/raytrace_brute.hlsl +++ b/base/shaders/raytrace/src/raytrace_brute.hlsl @@ -3,8 +3,8 @@ #define _EMISSION #define _SUBSURFACE #define _TRANSLUCENCY -#define _ROULETTE #define _TRANSPARENCY +#define _ROULETTE // #define _FRESNEL #endif // #define _RENDER @@ -97,11 +97,11 @@ void raygeneration() { } #endif - #ifdef _SUBSURFACE - TraceRay(scene, RAY_FLAG_FORCE_OPAQUE | RAY_FLAG_CULL_BACK_FACING_TRIANGLES, ~0, 0, 1, 0, ray, payload); - #else + // #ifdef _SUBSURFACE + // TraceRay(scene, RAY_FLAG_FORCE_OPAQUE | RAY_FLAG_CULL_BACK_FACING_TRIANGLES, ~0, 0, 1, 0, ray, payload); + // #else TraceRay(scene, RAY_FLAG_FORCE_OPAQUE, ~0, 0, 1, 0, ray, payload); - #endif + // #endif #ifdef _EMISSION if (payload.color.a == -3) { @@ -278,7 +278,13 @@ void closesthit(inout RayPayload payload, in BuiltInTriangleIntersectionAttribut #ifdef _SUBSURFACE if (int(texpaint1.a * 255.0f) % 3 == 2) { - payload.ray_origin += WorldRayDirection() * f; + // Thickness + float d = min(1.0 / min(RayTCurrent() * 2.0, 1.0) / 10.0, 0.5); + payload.color.xyz += payload.color.xyz * d; + // Fake scatter + if (f < 0.5) { + payload.ray_origin += WorldRayDirection() * f * 0.001; + } } #endif }