Skip to content

Commit 96d7fda

Browse files
committed
Add fake sss
1 parent ecff0d1 commit 96d7fda

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

armorpaint/sources/make_paint.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,8 @@ function make_paint_run(data: material_t, matcon: material_context_t): node_shad
275275
// Height used for the first time, also rebuild vertex shader
276276
return make_paint_run(data, matcon);
277277
}
278-
if (emis != "0.0" && emis != "0") {
279-
make_material_emis_used = true;
280-
}
281-
if (subs != "0.0" && subs != "0") {
282-
make_material_subs_used = true;
283-
}
278+
make_material_emis_used = emis != "0.0" && emis != "0";
279+
make_material_subs_used = subs != "0.0" && subs != "0";
284280
}
285281

286282
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
391387
node_shader_write(frag, "float matid = " + matid_string + ";");
392388

393389
// matid % 3 == 0 - normal, 1 - emission, 2 - subsurface
394-
if (context_raw.material.paint_emis) {
390+
if (context_raw.material.paint_emis && make_material_emis_used) {
395391
node_shader_write(frag, "if (emis > 0.0) {");
396392
node_shader_write(frag, " matid += 1.0 / 255.0;");
397393
node_shader_write(frag, " if (str == 0.0) discard;");
398394
node_shader_write(frag, "}");
399395
}
400-
else if (context_raw.material.paint_subs) {
396+
else if (context_raw.material.paint_subs && make_material_subs_used) {
401397
node_shader_write(frag, "if (subs > 0.0) {");
402398
node_shader_write(frag, " matid += 2.0 / 255.0;");
403399
node_shader_write(frag, " if (str == 0.0) discard;");
348 Bytes
Binary file not shown.
348 Bytes
Binary file not shown.

base/shaders/raytrace/src/raytrace_brute.hlsl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#define _EMISSION
44
#define _SUBSURFACE
55
#define _TRANSLUCENCY
6-
#define _ROULETTE
76
#define _TRANSPARENCY
7+
#define _ROULETTE
88
// #define _FRESNEL
99
#endif
1010
// #define _RENDER
@@ -97,11 +97,11 @@ void raygeneration() {
9797
}
9898
#endif
9999

100-
#ifdef _SUBSURFACE
101-
TraceRay(scene, RAY_FLAG_FORCE_OPAQUE | RAY_FLAG_CULL_BACK_FACING_TRIANGLES, ~0, 0, 1, 0, ray, payload);
102-
#else
100+
// #ifdef _SUBSURFACE
101+
// TraceRay(scene, RAY_FLAG_FORCE_OPAQUE | RAY_FLAG_CULL_BACK_FACING_TRIANGLES, ~0, 0, 1, 0, ray, payload);
102+
// #else
103103
TraceRay(scene, RAY_FLAG_FORCE_OPAQUE, ~0, 0, 1, 0, ray, payload);
104-
#endif
104+
// #endif
105105

106106
#ifdef _EMISSION
107107
if (payload.color.a == -3) {
@@ -278,7 +278,13 @@ void closesthit(inout RayPayload payload, in BuiltInTriangleIntersectionAttribut
278278

279279
#ifdef _SUBSURFACE
280280
if (int(texpaint1.a * 255.0f) % 3 == 2) {
281-
payload.ray_origin += WorldRayDirection() * f;
281+
// Thickness
282+
float d = min(1.0 / min(RayTCurrent() * 2.0, 1.0) / 10.0, 0.5);
283+
payload.color.xyz += payload.color.xyz * d;
284+
// Fake scatter
285+
if (f < 0.5) {
286+
payload.ray_origin += WorldRayDirection() * f * 0.001;
287+
}
282288
}
283289
#endif
284290
}

0 commit comments

Comments
 (0)