Skip to content
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

preprocessor #if folding is incorrect #250

Open
Andrej730 opened this issue Jun 10, 2023 · 0 comments
Open

preprocessor #if folding is incorrect #250

Andrej730 opened this issue Jun 10, 2023 · 0 comments

Comments

@Andrej730
Copy link

For the code below I was expecting folding #if 1 to fold the entire thing or for #else to fold the second half but what it does it folds the part of the code until next #if statement. It's a real pain to work with.

Code_-_Insiders_w9FPANr0ph.mp4
#if 1 // shadow sample distribution
					// Non-linear shadow sample distribution, hardcoded to x^2
					float PreviousNormT = 0.0f;
					for (float ShadowT = InvShadowStepCount; ShadowT <= 1.00001f; ShadowT += InvShadowStepCount)
					{
						DebugGroundShadowMaterialSampleCount++;
						float CurrentNormT = ShadowT * ShadowT; // CurrentNormT is the end of the considered segment to integrate, PreviousNormT is its beginning.
						const float DetlaNormT = CurrentNormT - PreviousNormT;
						const float ShadowSampleDistance = ShadowLengthTest * (CurrentNormT - 0.5 * DetlaNormT);
						UpdateMaterialCloudParam(MaterialParameters, LWCAdd(SampleWorldPosition, LWCPromote(float3(0.0f, 0.0f, -1.0f) * ShadowSampleDistance)),
							ResolvedView, CloudLayerParams, ShadowSampleDistance);
						PreviousNormT = CurrentNormT;
#if MATERIAL_VOLUMETRIC_ADVANCED_CONSERVATIVE_DENSITY
						if (MaterialParameters.VolumeSampleConservativeDensity.x <= 0.0f)
						{
							continue; // Conservative density is 0 so skip and go to the next sample
						}
#endif
						CalcPixelMaterialInputs(MaterialParameters, PixelMaterialInputs);
						OpticalDepth += SampleExtinctionCoefficients(PixelMaterialInputs) * ShadowLengthTest * CENTIMETER_TO_METER * DetlaNormT;
					}
#else // shadow sample distribution
					// Linear shadow sample distribution.
					const float ShadowDtMeter = ShadowLengthTest * CENTIMETER_TO_METER / ShadowStepCount;
					const float ShadowJitteringSeed = float(ResolvedView.StateFrameIndexMod8) + PseudoRandom(SvPosition.xy) + i * 17;
					const float ShadowJitterNorm = InterleavedGradientNoise(SvPosition.xy, ShadowJitteringSeed) - 0.5f;
					for (float ShadowT = 0.5; ShadowT < ShadowStepCount; ShadowT += 1.0f)
					{
						const float ShadowSampleDistance = ShadowLengthTest * (ShadowT * InvShadowStepCount);
						UpdateMaterialCloudParam(MaterialParameters, LWCAdd(SampleWorldPosition, LWCPromote(float3(0.0f, 0.0f, -1.0f) * ShadowSampleDistance)),
							ResolvedView, CloudLayerParams, ShadowSampleDistance);
#if MATERIAL_VOLUMETRIC_ADVANCED_CONSERVATIVE_DENSITY
						if (MaterialParameters.VolumeSampleConservativeDensity.x <= 0.0f)
						{
							continue; // Conservative density is 0 so skip and go to the next sample
						}
#endif // MATERIAL_VOLUMETRIC_ADVANCED_CONSERVATIVE_DENSITY
						CalcPixelMaterialInputs(MaterialParameters, PixelMaterialInputs);
						OpticalDepth += SampleExtinctionCoefficients(PixelMaterialInputs) * ShadowDtMeter;
					}
#endif // shadow sample distribution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant