Skip to content

Commit a8012e8

Browse files
committed
Automatic merge of T1.5.1-346-g3831af9fa and 8 pull requests
- Pull request #570 at 14abf7a: Experimental glTF 2.0 support with PBR lighting - Pull request #722 at fb9079e: Fix Windows Forms deprecations in ActivityEditor - Pull request #732 at 1edb2e5: Improvements for air brakes - Pull request #751 at 00981a2: Web interface to control cab controls with external hardware - Pull request #767 at 4cb5c77: Refine sunrise and sunset - Pull request #803 at 7157e08: Various adjustments to steam adhesion - Pull request #809 at f67822a: Some on-screen messages not suppressed, Bug #2008012 - Pull request #812 at d07f812: Bug fix for https://bugs.launchpad.net/or/+bug/2009955 Missing code to rotate DMU display in 2D cabs
10 parents 9665144 + 3831af9 + 14abf7a + fb9079e + 1edb2e5 + 00981a2 + 4cb5c77 + 7157e08 + f67822a + d07f812 commit a8012e8

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed

Source/RunActivity/Content/SceneryShader.fx

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ struct VERTEX_OUTPUT_PBR
345345
void _VSNormalProjection(in float3 InNormal, in float4x4 WorldTransform, inout float4 OutPosition, inout float4 OutRelPosition, inout float4 OutNormal_Light)
346346
{
347347
OutRelPosition.xyz = mul(OutPosition, WorldTransform).xyz - ViewerPos;
348-
OutPosition = mul(mul(mul(OutPosition, World), View), Projection);
348+
OutPosition = mul(mul(mul(OutPosition, WorldTransform), View), Projection);
349349
OutRelPosition.w = OutPosition.z;
350350
OutNormal_Light.xyz = normalize(mul(InNormal, (float3x3)WorldTransform).xyz);
351351

@@ -489,18 +489,13 @@ VERTEX_OUTPUT_PBR VSSkinned(in VERTEX_INPUT_SKINNED In)
489489
VERTEX_OUTPUT_PBR Out = (VERTEX_OUTPUT_PBR) 0;
490490

491491
_VSInstances(In.Position, In.Normal, In.Instance);
492-
float4x4 skinTransform = _VSSkinTransform(In.Joints, In.Weights);
492+
float4x4 worldTransform = _VSSkinTransform(In.Joints, In.Weights);
493493

494-
// Beware: Out.Position will contain Pos*World, and WorldViewProjection is uploaded as View*Projection here,
495-
// in contrast with e.g. VSGeneral, where Out.Position is just a position, and WorldViewProjection is WVP.
496-
Out.Position = mul(In.Position, skinTransform);
497-
float4 worldPosition = Out.Position;
498-
_VSNormalProjection(In.Normal, skinTransform, Out.Position, Out.RelPosition, Out.Normal_Light);
499-
Out.RelPosition.xyz = worldPosition - ViewerPos; // Need to amend the calculation of _VSNormalProjection here, because of the above.
500-
_VSLightsAndShadows(worldPosition, skinTransform, length(Out.Position.xyz), Out.Tangent.w, Out.Shadow);
501-
Out.Shadow = worldPosition; // Need to amend this as well.
494+
Out.Position = In.Position;
495+
_VSNormalProjection(In.Normal, worldTransform, Out.Position, Out.RelPosition, Out.Normal_Light);
496+
_VSLightsAndShadows(Out.Position, worldTransform, length(Out.Position.xyz), Out.Tangent.w, Out.Shadow);
502497

503-
_VSNormalMapTransform(In.Tangent, In.Normal, skinTransform, Out);
498+
_VSNormalMapTransform(In.Tangent, In.Normal, worldTransform, Out);
504499

505500
// Z-bias to reduce and eliminate z-fighting on track ballast. ZBias is 0 or 1.
506501
Out.Position.z -= ZBias_Lighting.x * saturate(In.TexCoords.x) / 1000;
@@ -515,12 +510,8 @@ VERTEX_OUTPUT_PBR VSMorphing(in VERTEX_INPUT_MORPHED In)
515510
{
516511
VERTEX_OUTPUT_PBR Out = (VERTEX_OUTPUT_PBR)0;
517512

518-
float4x4 skinTransform = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; // Identity
519-
if (MorphConfig[6] == 1)
520-
skinTransform = _VSSkinTransform(In.Joints, In.Weights);
513+
float4x4 worldTransform = MorphConfig[6] == 1 ? _VSSkinTransform(In.Joints, In.Weights) : World;
521514

522-
// Beware: Out.Position will contain Pos*World, and WorldViewProjection is uploaded as View*Projection here,
523-
// in contrast with e.g. VSGeneral, where Out.Position is just a position, and WorldViewProjection is WVP.
524515
Out.Position = In.Position;
525516
float3 normal = In.Normal;
526517
float4 tangent = In.Tangent;
@@ -545,14 +536,10 @@ VERTEX_OUTPUT_PBR VSMorphing(in VERTEX_INPUT_MORPHED In)
545536
Out.Color += In.MorphTargets[MorphConfig[8] * i + MorphConfig[5]] * MorphWeights[i];
546537
}
547538

548-
Out.Position = mul(Out.Position, skinTransform);
549-
float4 worldPosition = Out.Position;
550-
_VSNormalProjection(normal, skinTransform, Out.Position, Out.RelPosition, Out.Normal_Light);
551-
Out.RelPosition.xyz = worldPosition - ViewerPos; // Need to amend the calculation of _VSNormalProjection here, because of the above.
552-
_VSLightsAndShadows(worldPosition, skinTransform, length(Out.Position.xyz), Out.Tangent.w, Out.Shadow);
553-
Out.Shadow = worldPosition; // Need to amend this as well.
539+
_VSNormalProjection(normal, worldTransform, Out.Position, Out.RelPosition, Out.Normal_Light);
540+
_VSLightsAndShadows(Out.Position, worldTransform, length(Out.Position.xyz), Out.Tangent.w, Out.Shadow);
554541

555-
_VSNormalMapTransform(tangent, normal, skinTransform, Out);
542+
_VSNormalMapTransform(tangent, normal, worldTransform, Out);
556543

557544
// Z-bias to reduce and eliminate z-fighting on track ballast. ZBias is 0 or 1.
558545
Out.Position.z -= ZBias_Lighting.x * saturate(In.TexCoords.x) / 1000;

0 commit comments

Comments
 (0)