GeonBit icon indicating copy to clipboard operation
GeonBit copied to clipboard

An error occurred while compiling the resource

Open ClEngine opened this issue 7 years ago • 4 comments

image unable to unroll loop, loop does not appear to terminate in a timely manner (21 iterations), use the [unroll(n)] attribute to force an exact higher number Content\GeonBit.Core\Effects\NormalMapLitEffect.fx 141 Content\GeonBit.Core\Effects\LitEffectAlphaTest.fx 123 Content\GeonBit.Core\Effects\LitEffect.fx 116

What are the problems with these fx files?

ClEngine avatar Jun 27 '18 04:06 ClEngine

Please post code that caused the error.. Thanks.

RonenNess avatar Jun 27 '18 05:06 RonenNess

This is where the Error in NormalMapLitEffect.fx 141 is reported

for (i = DirectionalLightsCount; i < ActiveLightsCount; ++i)
	{
		// if fully lit stop here
		if (LightsColor.r > 1 && LightsColor.g > 1 && LightsColor.b > 1) { break; }

		// calculate distance and angle factors for point light
		float disFactor = 1.0f - (distance(input.WorldPos, LightPosition[i]) / LightRange[i]);

		// out of range? skip this light.
		if (disFactor > 0)
		{
			// power distance factor
			disFactor = pow(disFactor, 2);

			// calc with normal factor
			float3 lightDir = normalize(input.WorldPos - LightPosition[i]);
			float cosTheta = saturate(dot(-lightDir, fragNormal));

			// add light to pixel
			LightsColor.rgb += (LightColor[i]) * (cosTheta * LightIntensity[i] * disFactor);
		}
	}

This is where the Error in LitEffectAlphaTest.fx 123 is reported

for (i = DirectionalLightsCount; i < ActiveLightsCount; ++i)
	{
		// if fully lit stop here
		if (LightsColor.r > 1 && LightsColor.g > 1 && LightsColor.b > 1) { break; }

		// calculate distance and angle factors for point light
		float disFactor = 1.0f - (distance(input.WorldPos, LightPosition[i]) / LightRange[i]);

		// out of range? skip this light.
		if (disFactor > 0)
		{
			// power distance factor
			disFactor = pow(disFactor, 2);

			// calc with normal factor
			float3 lightDir = normalize(input.WorldPos - LightPosition[i]);
			float cosTheta = saturate(dot(-lightDir, input.Normal));

			// add light to pixel
			LightsColor.rgb += (LightColor[i]) * (cosTheta * LightIntensity[i] * disFactor);
		}
	}

This is where the Error in LitEffect.fx 116 is reported

for (i = DirectionalLightsCount; i < ActiveLightsCount; ++i)
	{
		// if fully lit stop here
		if (LightsColor.r > 1 && LightsColor.g > 1 && LightsColor.b > 1) { break; }

		// calculate distance and angle factors for point light
		float disFactor = 1.0f - (distance(input.WorldPos, LightPosition[i]) / LightRange[i]);

		// out of range? skip this light.
		if (disFactor > 0)
		{
			// power distance factor
			disFactor = pow(disFactor, 2);

			// calc with normal factor
			float3 lightDir = normalize(input.WorldPos - LightPosition[i]);
			float cosTheta = saturate(dot(-lightDir, input.Normal));

			// add light to pixel
			LightsColor.rgb += (LightColor[i]) * (cosTheta * LightIntensity[i] * disFactor);
		}
	}

They all went wrong on this paragraph. The three places seem to have the same mistake

ClEngine avatar Jun 27 '18 08:06 ClEngine

Are you working on windows?

RonenNess avatar Jun 29 '18 08:06 RonenNess

yes. windows10

ClEngine avatar Jun 29 '18 10:06 ClEngine