-
Notifications
You must be signed in to change notification settings - Fork 137
perf(tv): improve compile time #1415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,18 @@ | |
|
|
||
| #if defined(TERRAIN_VARIATION) && defined(LANDSCAPE) | ||
| # include "TerrainVariation/TerrainVariation.hlsli" | ||
|
|
||
| // Optimized terrain sampling helper for Extended Materials | ||
| inline float4 SampleTerrainTextureEM(Texture2D tex, SamplerState samp, float2 coords, float mipLevel, bool useVariation, StochasticOffsets offsets, float2 dx, float2 dy) | ||
| { | ||
| return useVariation ? StochasticEffectParallax(tex, samp, coords, mipLevel, offsets, dx, dy) : tex.SampleLevel(samp, coords, mipLevel); | ||
| } | ||
| #else | ||
| // Fallback when terrain variation is not defined | ||
| inline float4 SampleTerrainTextureEM(Texture2D tex, SamplerState samp, float2 coords, float mipLevel, bool useVariation, float4 dummy1, float2 dummy2, float2 dummy3) | ||
| { | ||
| return tex.SampleLevel(samp, coords, mipLevel); | ||
| } | ||
| #endif | ||
|
|
||
| struct DisplacementParams | ||
|
|
@@ -123,63 +135,45 @@ namespace ExtendedMaterials | |
| float heightBlend = 1 + blendFactor * HEIGHT_POWER; | ||
| float heights[6] = { 0, 0, 0, 0, 0, 0 }; | ||
|
|
||
| [branch] if ((PBRFlags & PBR::TerrainFlags::LandTile0HasDisplacement) != 0 && w1.x > 0.01) | ||
| { | ||
| // Centralized terrain variation check | ||
| bool useVariation = false; | ||
| # if defined(TERRAIN_VARIATION) | ||
| heights[0] = ScaleDisplacement(StochasticEffectParallax(TexLandDisplacement0Sampler, SampTerrainParallaxSampler, coords, mipLevels[0], sharedOffset, dx, dy).x, params[0]); | ||
| # else | ||
| heights[0] = ScaleDisplacement(TexLandDisplacement0Sampler.SampleLevel(SampTerrainParallaxSampler, coords, mipLevels[0]).x, params[0]); | ||
| useVariation = SharedData::terrainVariationSettings.enableTilingFix; | ||
| # endif | ||
|
|
||
| [branch] if ((PBRFlags & PBR::TerrainFlags::LandTile0HasDisplacement) != 0 && w1.x > 0.01) | ||
| { | ||
| heights[0] = ScaleDisplacement(SampleTerrainTextureEM(TexLandDisplacement0Sampler, SampTerrainParallaxSampler, coords, mipLevels[0], useVariation, sharedOffset, dx, dy).x, params[0]); | ||
| } | ||
|
Comment on lines
+138
to
147
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Build breaks when TERRAIN_VARIATION is undefined: sharedOffset/dx/dy referenced unconditionally Within both GetTerrainHeight variants, calls to SampleTerrainTextureEM pass sharedOffset, dx, dy unconditionally. When TERRAIN_VARIATION is not defined, those identifiers do not exist (they’re not function parameters), causing compilation errors. The fallback overload of SampleTerrainTextureEM doesn’t help here because the arguments themselves are unresolved. Fix by introducing a small macro for the argument list and using it at all callsites. This avoids scattering #if guards and compiles cleanly in both configurations. Apply the following diffs:
@@
#endif
+
+// Expand TV-only call arguments safely when TERRAIN_VARIATION is undefined.
+#if defined(TERRAIN_VARIATION)
+# define TV_ARGS sharedOffset, dx, dy
+#else
+# define TV_ARGS float4(0,0,0,0), 0, 0
+#endif
@@
- heights[0] = ScaleDisplacement(SampleTerrainTextureEM(TexLandDisplacement0Sampler, SampTerrainParallaxSampler, coords, mipLevels[0], useVariation, sharedOffset, dx, dy).x, params[0]);
+ heights[0] = ScaleDisplacement(SampleTerrainTextureEM(TexLandDisplacement0Sampler, SampTerrainParallaxSampler, coords, mipLevels[0], useVariation, TV_ARGS).x, params[0]);
@@
- heights[1] = ScaleDisplacement(SampleTerrainTextureEM(TexLandDisplacement1Sampler, SampTerrainParallaxSampler, coords, mipLevels[1], useVariation, sharedOffset, dx, dy).x, params[1]);
+ heights[1] = ScaleDisplacement(SampleTerrainTextureEM(TexLandDisplacement1Sampler, SampTerrainParallaxSampler, coords, mipLevels[1], useVariation, TV_ARGS).x, params[1]);
@@
- heights[2] = ScaleDisplacement(SampleTerrainTextureEM(TexLandDisplacement2Sampler, SampTerrainParallaxSampler, coords, mipLevels[2], useVariation, sharedOffset, dx, dy).x, params[2]);
+ heights[2] = ScaleDisplacement(SampleTerrainTextureEM(TexLandDisplacement2Sampler, SampTerrainParallaxSampler, coords, mipLevels[2], useVariation, TV_ARGS).x, params[2]);
@@
- heights[3] = ScaleDisplacement(SampleTerrainTextureEM(TexLandDisplacement3Sampler, SampTerrainParallaxSampler, coords, mipLevels[3], useVariation, sharedOffset, dx, dy).x, params[3]);
+ heights[3] = ScaleDisplacement(SampleTerrainTextureEM(TexLandDisplacement3Sampler, SampTerrainParallaxSampler, coords, mipLevels[3], useVariation, TV_ARGS).x, params[3]);
@@
- heights[4] = ScaleDisplacement(SampleTerrainTextureEM(TexLandDisplacement4Sampler, SampTerrainParallaxSampler, coords, mipLevels[4], useVariation, sharedOffset, dx, dy).x, params[4]);
+ heights[4] = ScaleDisplacement(SampleTerrainTextureEM(TexLandDisplacement4Sampler, SampTerrainParallaxSampler, coords, mipLevels[4], useVariation, TV_ARGS).x, params[4]);
@@
- heights[5] = ScaleDisplacement(SampleTerrainTextureEM(TexLandDisplacement5Sampler, SampTerrainParallaxSampler, coords, mipLevels[5], useVariation, sharedOffset, dx, dy).x, params[5]);
+ heights[5] = ScaleDisplacement(SampleTerrainTextureEM(TexLandDisplacement5Sampler, SampTerrainParallaxSampler, coords, mipLevels[5], useVariation, TV_ARGS).x, params[5]);
@@
- heights[0] = ScaleDisplacement(SampleTerrainTextureEM(TexLandTHDisp0Sampler, SampTerrainParallaxSampler, coords, mipLevels[0], useVariation, sharedOffset, dx, dy).x, params[0]);
+ heights[0] = ScaleDisplacement(SampleTerrainTextureEM(TexLandTHDisp0Sampler, SampTerrainParallaxSampler, coords, mipLevels[0], useVariation, TV_ARGS).x, params[0]);
@@
- heights[0] = ScaleDisplacement(SampleTerrainTextureEM(TexColorSampler, SampTerrainParallaxSampler, coords, mipLevels[0], useVariation, sharedOffset, dx, dy).w, params[0]);
+ heights[0] = ScaleDisplacement(SampleTerrainTextureEM(TexColorSampler, SampTerrainParallaxSampler, coords, mipLevels[0], useVariation, TV_ARGS).w, params[0]);
@@
- heights[1] = ScaleDisplacement(SampleTerrainTextureEM(TexLandTHDisp1Sampler, SampTerrainParallaxSampler, coords, mipLevels[1], useVariation, sharedOffset, dx, dy).x, params[1]);
+ heights[1] = ScaleDisplacement(SampleTerrainTextureEM(TexLandTHDisp1Sampler, SampTerrainParallaxSampler, coords, mipLevels[1], useVariation, TV_ARGS).x, params[1]);
@@
- heights[1] = ScaleDisplacement(SampleTerrainTextureEM(TexLandColor2Sampler, SampTerrainParallaxSampler, coords, mipLevels[1], useVariation, sharedOffset, dx, dy).w, params[1]);
+ heights[1] = ScaleDisplacement(SampleTerrainTextureEM(TexLandColor2Sampler, SampTerrainParallaxSampler, coords, mipLevels[1], useVariation, TV_ARGS).w, params[1]);
@@
- heights[3] = ScaleDisplacement(SampleTerrainTextureEM(TexLandTHDisp3Sampler, SampTerrainParallaxSampler, coords, mipLevels[3], useVariation, sharedOffset, dx, dy).x, params[3]);
+ heights[3] = ScaleDisplacement(SampleTerrainTextureEM(TexLandTHDisp3Sampler, SampTerrainParallaxSampler, coords, mipLevels[3], useVariation, TV_ARGS).x, params[3]);
@@
- heights[3] = ScaleDisplacement(SampleTerrainTextureEM(TexLandColor4Sampler, SampTerrainParallaxSampler, coords, mipLevels[3], useVariation, sharedOffset, dx, dy).w, params[3]);
+ heights[3] = ScaleDisplacement(SampleTerrainTextureEM(TexLandColor4Sampler, SampTerrainParallaxSampler, coords, mipLevels[3], useVariation, TV_ARGS).w, params[3]);
@@
- heights[4] = ScaleDisplacement(SampleTerrainTextureEM(TexLandTHDisp4Sampler, SampTerrainParallaxSampler, coords, mipLevels[4], useVariation, sharedOffset, dx, dy).x, params[4]);
+ heights[4] = ScaleDisplacement(SampleTerrainTextureEM(TexLandTHDisp4Sampler, SampTerrainParallaxSampler, coords, mipLevels[4], useVariation, TV_ARGS).x, params[4]);
@@
- heights[4] = ScaleDisplacement(SampleTerrainTextureEM(TexLandColor5Sampler, SampTerrainParallaxSampler, coords, mipLevels[4], useVariation, sharedOffset, dx, dy).w, params[4]);
+ heights[4] = ScaleDisplacement(SampleTerrainTextureEM(TexLandColor5Sampler, SampTerrainParallaxSampler, coords, mipLevels[4], useVariation, TV_ARGS).w, params[4]);
@@
- heights[5] = ScaleDisplacement(SampleTerrainTextureEM(TexLandTHDisp5Sampler, SampTerrainParallaxSampler, coords, mipLevels[5], useVariation, sharedOffset, dx, dy).x, params[5]);
+ heights[5] = ScaleDisplacement(SampleTerrainTextureEM(TexLandTHDisp5Sampler, SampTerrainParallaxSampler, coords, mipLevels[5], useVariation, TV_ARGS).x, params[5]);
@@
- heights[5] = ScaleDisplacement(SampleTerrainTextureEM(TexLandColor6Sampler, SampTerrainParallaxSampler, coords, mipLevels[5], useVariation, sharedOffset, dx, dy).w, params[5]);
+ heights[5] = ScaleDisplacement(SampleTerrainTextureEM(TexLandColor6Sampler, SampTerrainParallaxSampler, coords, mipLevels[5], useVariation, TV_ARGS).w, params[5]);Also applies to: 194-201, 201-203, 207-213, 227-231, 235-239, 243-247 🤖 Prompt for AI Agents |
||
| [branch] if ((PBRFlags & PBR::TerrainFlags::LandTile1HasDisplacement) != 0 && w1.y > 0.01) | ||
| { | ||
| # if defined(TERRAIN_VARIATION) | ||
| heights[1] = ScaleDisplacement(StochasticEffectParallax(TexLandDisplacement1Sampler, SampTerrainParallaxSampler, coords, mipLevels[1], sharedOffset, dx, dy).x, params[1]); | ||
| # else | ||
| heights[1] = ScaleDisplacement(TexLandDisplacement1Sampler.SampleLevel(SampTerrainParallaxSampler, coords, mipLevels[1]).x, params[1]); | ||
| # endif | ||
| heights[1] = ScaleDisplacement(SampleTerrainTextureEM(TexLandDisplacement1Sampler, SampTerrainParallaxSampler, coords, mipLevels[1], useVariation, sharedOffset, dx, dy).x, params[1]); | ||
| } | ||
| [branch] if ((PBRFlags & PBR::TerrainFlags::LandTile2HasDisplacement) != 0 && w1.z > 0.01) | ||
| { | ||
| # if defined(TERRAIN_VARIATION) | ||
| heights[2] = ScaleDisplacement(StochasticEffectParallax(TexLandDisplacement2Sampler, SampTerrainParallaxSampler, coords, mipLevels[2], sharedOffset, dx, dy).x, params[2]); | ||
| # else | ||
| heights[2] = ScaleDisplacement(TexLandDisplacement2Sampler.SampleLevel(SampTerrainParallaxSampler, coords, mipLevels[2]).x, params[2]); | ||
| # endif | ||
| heights[2] = ScaleDisplacement(SampleTerrainTextureEM(TexLandDisplacement2Sampler, SampTerrainParallaxSampler, coords, mipLevels[2], useVariation, sharedOffset, dx, dy).x, params[2]); | ||
| } | ||
| [branch] if ((PBRFlags & PBR::TerrainFlags::LandTile3HasDisplacement) != 0 && w1.w > 0.01) | ||
| { | ||
| # if defined(TERRAIN_VARIATION) | ||
| heights[3] = ScaleDisplacement(StochasticEffectParallax(TexLandDisplacement3Sampler, SampTerrainParallaxSampler, coords, mipLevels[3], sharedOffset, dx, dy).x, params[3]); | ||
| # else | ||
| heights[3] = ScaleDisplacement(TexLandDisplacement3Sampler.SampleLevel(SampTerrainParallaxSampler, coords, mipLevels[3]).x, params[3]); | ||
| # endif | ||
| heights[3] = ScaleDisplacement(SampleTerrainTextureEM(TexLandDisplacement3Sampler, SampTerrainParallaxSampler, coords, mipLevels[3], useVariation, sharedOffset, dx, dy).x, params[3]); | ||
| } | ||
| [branch] if ((PBRFlags & PBR::TerrainFlags::LandTile4HasDisplacement) != 0 && w2.x > 0.01) | ||
| { | ||
| # if defined(TERRAIN_VARIATION) | ||
| heights[4] = ScaleDisplacement(StochasticEffectParallax(TexLandDisplacement4Sampler, SampTerrainParallaxSampler, coords, mipLevels[4], sharedOffset, dx, dy).x, params[4]); | ||
| # else | ||
| heights[4] = ScaleDisplacement(TexLandDisplacement4Sampler.SampleLevel(SampTerrainParallaxSampler, coords, mipLevels[4]).x, params[4]); | ||
| # endif | ||
| heights[4] = ScaleDisplacement(SampleTerrainTextureEM(TexLandDisplacement4Sampler, SampTerrainParallaxSampler, coords, mipLevels[4], useVariation, sharedOffset, dx, dy).x, params[4]); | ||
| } | ||
| [branch] if ((PBRFlags & PBR::TerrainFlags::LandTile5HasDisplacement) != 0 && w2.y > 0.01) | ||
| { | ||
| # if defined(TERRAIN_VARIATION) | ||
| heights[5] = ScaleDisplacement(StochasticEffectParallax(TexLandDisplacement5Sampler, SampTerrainParallaxSampler, coords, mipLevels[5], sharedOffset, dx, dy).x, params[5]); | ||
| # else | ||
| heights[5] = ScaleDisplacement(TexLandDisplacement5Sampler.SampleLevel(SampTerrainParallaxSampler, coords, mipLevels[5]).x, params[5]); | ||
| # endif | ||
| heights[5] = ScaleDisplacement(SampleTerrainTextureEM(TexLandDisplacement5Sampler, SampTerrainParallaxSampler, coords, mipLevels[5], useVariation, sharedOffset, dx, dy).x, params[5]); | ||
| } | ||
|
|
||
| float total; | ||
| ProcessTerrainHeightWeights(heightBlend, w1, w2, heights, weights, total); | ||
| # if defined(TERRAIN_VARIATION) | ||
| // Boost height by 30% when terrain variation is enabled to enhance depth perception | ||
| [branch] if (SharedData::terrainVariationSettings.enableTilingFix) { | ||
|
|
||
| // Apply height boost for terrain variation if enabled | ||
| if (useVariation) { | ||
| total *= 1.3; | ||
| } | ||
| # endif | ||
|
|
||
| return total; } | ||
| # else | ||
| float GetTerrainHeight(float screenNoise, PS_INPUT input, float2 coords, float mipLevels[6], DisplacementParams params[6], float blendFactor, float4 w1, float2 w2, | ||
|
|
@@ -191,117 +185,75 @@ namespace ExtendedMaterials | |
| float heightBlend = 1 + blendFactor * HEIGHT_POWER; | ||
| float heights[6] = { 0, 0, 0, 0, 0, 0 }; | ||
|
|
||
| // Centralized terrain variation check | ||
| bool useVariation = false; | ||
| # if defined(TERRAIN_VARIATION) | ||
| useVariation = SharedData::terrainVariationSettings.enableTilingFix; | ||
| # endif | ||
|
|
||
| if (w1.x > 0.01) { | ||
| [branch] if ((Permutation::ExtraFeatureDescriptor & Permutation::ExtraFeatureFlags::THLand0HasDisplacement) != 0) | ||
| { | ||
| # if defined(TERRAIN_VARIATION) | ||
| heights[0] = ScaleDisplacement(StochasticEffectParallax(TexLandTHDisp0Sampler, SampTerrainParallaxSampler, coords, mipLevels[0], sharedOffset, dx, dy).x, params[0]); | ||
| # else | ||
| heights[0] = ScaleDisplacement(TexLandTHDisp0Sampler.SampleLevel(SampTerrainParallaxSampler, coords, mipLevels[0]).x, params[0]); | ||
| # endif | ||
| heights[0] = ScaleDisplacement(SampleTerrainTextureEM(TexLandTHDisp0Sampler, SampTerrainParallaxSampler, coords, mipLevels[0], useVariation, sharedOffset, dx, dy).x, params[0]); | ||
| } | ||
| else | ||
| { | ||
| # if defined(TERRAIN_VARIATION) | ||
| heights[0] = ScaleDisplacement(StochasticEffectParallax(TexColorSampler, SampTerrainParallaxSampler, coords, mipLevels[0], sharedOffset, dx, dy).w, params[0]); | ||
| # else | ||
| heights[0] = ScaleDisplacement(TexColorSampler.SampleLevel(SampTerrainParallaxSampler, coords, mipLevels[0]).w, params[0]); | ||
| # endif | ||
| heights[0] = ScaleDisplacement(SampleTerrainTextureEM(TexColorSampler, SampTerrainParallaxSampler, coords, mipLevels[0], useVariation, sharedOffset, dx, dy).w, params[0]); | ||
| } | ||
| } | ||
| if (w1.y > 0.01) { | ||
| [branch] if ((Permutation::ExtraFeatureDescriptor & Permutation::ExtraFeatureFlags::THLand1HasDisplacement) != 0) | ||
| { | ||
| # if defined(TERRAIN_VARIATION) | ||
| heights[1] = ScaleDisplacement(StochasticEffectParallax(TexLandTHDisp1Sampler, SampTerrainParallaxSampler, coords, mipLevels[1], sharedOffset, dx, dy).x, params[1]); | ||
| # else | ||
| heights[1] = ScaleDisplacement(TexLandTHDisp1Sampler.SampleLevel(SampTerrainParallaxSampler, coords, mipLevels[1]).x, params[1]); | ||
| # endif | ||
| heights[1] = ScaleDisplacement(SampleTerrainTextureEM(TexLandTHDisp1Sampler, SampTerrainParallaxSampler, coords, mipLevels[1], useVariation, sharedOffset, dx, dy).x, params[1]); | ||
| } | ||
| else | ||
| { | ||
| # if defined(TERRAIN_VARIATION) | ||
| heights[1] = ScaleDisplacement(StochasticEffectParallax(TexLandColor2Sampler, SampTerrainParallaxSampler, coords, mipLevels[1], sharedOffset, dx, dy).w, params[1]); | ||
| # else | ||
| heights[1] = ScaleDisplacement(TexLandColor2Sampler.SampleLevel(SampTerrainParallaxSampler, coords, mipLevels[1]).w, params[1]); | ||
| # endif | ||
| heights[1] = ScaleDisplacement(SampleTerrainTextureEM(TexLandColor2Sampler, SampTerrainParallaxSampler, coords, mipLevels[1], useVariation, sharedOffset, dx, dy).w, params[1]); | ||
| } | ||
| } | ||
| if (w1.z > 0.01) { | ||
| [branch] if ((Permutation::ExtraFeatureDescriptor & Permutation::ExtraFeatureFlags::THLand2HasDisplacement) != 0) | ||
| { | ||
| # if defined(TERRAIN_VARIATION) | ||
| heights[2] = ScaleDisplacement(StochasticEffectParallax(TexLandTHDisp2Sampler, SampTerrainParallaxSampler, coords, mipLevels[2], sharedOffset, dx, dy).x, params[2]); | ||
| # else | ||
| heights[2] = ScaleDisplacement(TexLandTHDisp2Sampler.SampleLevel(SampTerrainParallaxSampler, coords, mipLevels[2]).x, params[2]); | ||
| # endif | ||
| heights[2] = ScaleDisplacement(SampleTerrainTextureEM(TexLandTHDisp2Sampler, SampTerrainParallaxSampler, coords, mipLevels[2], useVariation, sharedOffset, dx, dy).x, params[2]); | ||
| } | ||
| else | ||
| { | ||
| # if defined(TERRAIN_VARIATION) | ||
| heights[2] = ScaleDisplacement(StochasticEffectParallax(TexLandColor3Sampler, SampTerrainParallaxSampler, coords, mipLevels[2], sharedOffset, dx, dy).w, params[2]); | ||
| # else | ||
| heights[2] = ScaleDisplacement(TexLandColor3Sampler.SampleLevel(SampTerrainParallaxSampler, coords, mipLevels[2]).w, params[2]); | ||
| # endif | ||
| heights[2] = ScaleDisplacement(SampleTerrainTextureEM(TexLandColor3Sampler, SampTerrainParallaxSampler, coords, mipLevels[2], useVariation, sharedOffset, dx, dy).w, params[2]); | ||
| } | ||
| } | ||
| [branch] if ((Permutation::ExtraFeatureDescriptor & Permutation::ExtraFeatureFlags::THLand3HasDisplacement) != 0 && w1.w > 0.01) | ||
| { | ||
| # if defined(TERRAIN_VARIATION) | ||
| heights[3] = ScaleDisplacement(StochasticEffectParallax(TexLandTHDisp3Sampler, SampTerrainParallaxSampler, coords, mipLevels[3], sharedOffset, dx, dy).x, params[3]); | ||
| # else | ||
| heights[3] = ScaleDisplacement(TexLandTHDisp3Sampler.SampleLevel(SampTerrainParallaxSampler, coords, mipLevels[3]).x, params[3]); | ||
| # endif | ||
| heights[3] = ScaleDisplacement(SampleTerrainTextureEM(TexLandTHDisp3Sampler, SampTerrainParallaxSampler, coords, mipLevels[3], useVariation, sharedOffset, dx, dy).x, params[3]); | ||
| } | ||
| else if (w1.w > 0.01) | ||
| { | ||
| # if defined(TERRAIN_VARIATION) | ||
| heights[3] = ScaleDisplacement(StochasticEffectParallax(TexLandColor4Sampler, SampTerrainParallaxSampler, coords, mipLevels[3], sharedOffset, dx, dy).w, params[3]); | ||
| # else | ||
| heights[3] = ScaleDisplacement(TexLandColor4Sampler.SampleLevel(SampTerrainParallaxSampler, coords, mipLevels[3]).w, params[3]); | ||
| # endif | ||
| heights[3] = ScaleDisplacement(SampleTerrainTextureEM(TexLandColor4Sampler, SampTerrainParallaxSampler, coords, mipLevels[3], useVariation, sharedOffset, dx, dy).w, params[3]); | ||
| } | ||
| [branch] if ((Permutation::ExtraFeatureDescriptor & Permutation::ExtraFeatureFlags::THLand4HasDisplacement) != 0 && w2.x > 0.01) | ||
| { | ||
| # if defined(TERRAIN_VARIATION) | ||
| heights[4] = ScaleDisplacement(StochasticEffectParallax(TexLandTHDisp4Sampler, SampTerrainParallaxSampler, coords, mipLevels[4], sharedOffset, dx, dy).x, params[4]); | ||
| # else | ||
| heights[4] = ScaleDisplacement(TexLandTHDisp4Sampler.SampleLevel(SampTerrainParallaxSampler, coords, mipLevels[4]).x, params[4]); | ||
| # endif | ||
| heights[4] = ScaleDisplacement(SampleTerrainTextureEM(TexLandTHDisp4Sampler, SampTerrainParallaxSampler, coords, mipLevels[4], useVariation, sharedOffset, dx, dy).x, params[4]); | ||
| } | ||
| else if (w2.x > 0.01) | ||
| { | ||
| # if defined(TERRAIN_VARIATION) | ||
| heights[4] = ScaleDisplacement(StochasticEffectParallax(TexLandColor5Sampler, SampTerrainParallaxSampler, coords, mipLevels[4], sharedOffset, dx, dy).w, params[4]); | ||
| # else | ||
| heights[4] = ScaleDisplacement(TexLandColor5Sampler.SampleLevel(SampTerrainParallaxSampler, coords, mipLevels[4]).w, params[4]); | ||
| # endif | ||
| heights[4] = ScaleDisplacement(SampleTerrainTextureEM(TexLandColor5Sampler, SampTerrainParallaxSampler, coords, mipLevels[4], useVariation, sharedOffset, dx, dy).w, params[4]); | ||
| } | ||
| [branch] if ((Permutation::ExtraFeatureDescriptor & Permutation::ExtraFeatureFlags::THLand5HasDisplacement) != 0 && w2.y > 0.01) | ||
| { | ||
| # if defined(TERRAIN_VARIATION) | ||
| heights[5] = ScaleDisplacement(StochasticEffectParallax(TexLandTHDisp5Sampler, SampTerrainParallaxSampler, coords, mipLevels[5], sharedOffset, dx, dy).x, params[5]); | ||
| # else | ||
| heights[5] = ScaleDisplacement(TexLandTHDisp5Sampler.SampleLevel(SampTerrainParallaxSampler, coords, mipLevels[5]).x, params[5]); | ||
| # endif | ||
| heights[5] = ScaleDisplacement(SampleTerrainTextureEM(TexLandTHDisp5Sampler, SampTerrainParallaxSampler, coords, mipLevels[5], useVariation, sharedOffset, dx, dy).x, params[5]); | ||
| } | ||
| else if (w2.y > 0.01) | ||
| { | ||
| # if defined(TERRAIN_VARIATION) | ||
| heights[5] = ScaleDisplacement(StochasticEffectParallax(TexLandColor6Sampler, SampTerrainParallaxSampler, coords, mipLevels[5], sharedOffset, dx, dy).w, params[5]); | ||
| # else | ||
| heights[5] = ScaleDisplacement(TexLandColor6Sampler.SampleLevel(SampTerrainParallaxSampler, coords, mipLevels[5]).w, params[5]); | ||
| # endif | ||
| heights[5] = ScaleDisplacement(SampleTerrainTextureEM(TexLandColor6Sampler, SampTerrainParallaxSampler, coords, mipLevels[5], useVariation, sharedOffset, dx, dy).w, params[5]); | ||
| } | ||
|
|
||
| float total; | ||
| ProcessTerrainHeightWeights(heightBlend, w1, w2, heights, weights, total); | ||
| # if defined(TERRAIN_VARIATION) | ||
| // Boost height by 30% when terrain variation is enabled to enhance depth perception | ||
| [branch] if (SharedData::terrainVariationSettings.enableTilingFix) { | ||
|
|
||
| // Apply height boost for terrain variation if enabled | ||
| if (useVariation) { | ||
| total *= 1.3; | ||
| } | ||
| # endif | ||
|
|
||
| return total; | ||
| } | ||
| # endif | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move into namespace