@@ -313,6 +313,7 @@ public ShaderInfo GetShaderInfo()
313
313
314
314
// Check the transparency bit.
315
315
const ushort transparencyBit = 16 ;
316
+ const ushort backfaceBit = 1 ;
316
317
var bit = ( ushort ) ( ShaderNumber & transparencyBit ) ;
317
318
318
319
if ( bit > 0 )
@@ -323,6 +324,17 @@ public ShaderInfo GetShaderInfo()
323
324
info . TransparencyEnabled = false ;
324
325
}
325
326
327
+ bit = ( ushort ) ( ShaderNumber & backfaceBit ) ;
328
+
329
+ if ( bit > 0 )
330
+ {
331
+ info . RenderBackfaces = false ;
332
+ }
333
+ else
334
+ {
335
+ info . RenderBackfaces = true ;
336
+ }
337
+
326
338
info . Preset = MtrlShaderPreset . Default ;
327
339
if ( info . Shader == MtrlShader . Standard )
328
340
{
@@ -386,6 +398,7 @@ public void SetShaderInfo(ShaderInfo info, bool forced = false)
386
398
387
399
// Set transparency bit as needed.
388
400
const ushort transparencyBit = 16 ;
401
+ const ushort backfaceBit = 1 ;
389
402
var transparency = info . ForcedTransparency == null ? info . TransparencyEnabled : ( bool ) info . ForcedTransparency ;
390
403
if ( transparency )
391
404
{
@@ -396,6 +409,35 @@ public void SetShaderInfo(ShaderInfo info, bool forced = false)
396
409
ShaderNumber = ( ushort ) ( ShaderNumber & ( ~ transparencyBit ) ) ;
397
410
}
398
411
412
+ // Set Backfaces bit.
413
+ var backfaces = info . RenderBackfaces ;
414
+ if ( ! backfaces )
415
+ {
416
+ ShaderNumber = ( ushort ) ( ShaderNumber | backfaceBit ) ;
417
+ }
418
+ else
419
+ {
420
+ ShaderNumber = ( ushort ) ( ShaderNumber & ( ~ backfaceBit ) ) ;
421
+ }
422
+
423
+ // Update us to DX11 material style if we're not already.
424
+ for ( var idx = 0 ; idx < Unknown2 . Length ; idx ++ )
425
+ {
426
+ if ( idx == 0 )
427
+ {
428
+ Unknown2 [ idx ] = 12 ;
429
+ }
430
+ else
431
+ {
432
+ Unknown2 [ idx ] = 0 ;
433
+ }
434
+ }
435
+
436
+ for ( var idx = 0 ; idx < TexturePathUnknownList . Count ; idx ++ )
437
+ {
438
+ TexturePathUnknownList [ idx ] = 0 ;
439
+ }
440
+
399
441
400
442
if ( forced == false && info . Shader == old . Shader && info . Preset == old . Preset )
401
443
{
@@ -474,23 +516,6 @@ public void SetShaderInfo(ShaderInfo info, bool forced = false)
474
516
}
475
517
}
476
518
477
-
478
- // Clear out the unknown lists back to known default working values.
479
- for ( var idx = 0 ; idx < TexturePathUnknownList . Count ; idx ++ )
480
- {
481
- TexturePathUnknownList [ idx ] = 0 ;
482
- }
483
-
484
- for ( var idx = 0 ; idx < Unknown2 . Length ; idx ++ )
485
- {
486
- if ( idx == 0 )
487
- {
488
- Unknown2 [ idx ] = 12 ;
489
- } else
490
- {
491
- Unknown2 [ idx ] = 0 ;
492
- }
493
- }
494
519
}
495
520
496
521
/// <summary>
@@ -1444,6 +1469,7 @@ public class ShaderInfo
1444
1469
public MtrlShader Shader ;
1445
1470
public MtrlShaderPreset Preset ;
1446
1471
public bool TransparencyEnabled ;
1472
+ public bool RenderBackfaces = false ;
1447
1473
public bool HasColorset
1448
1474
{
1449
1475
get
0 commit comments