@@ -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;" ) ;
0 commit comments