Lack of experience in this kind of errors makes such mistakes , Thanks guys for your replies and letting me know to provide more details about my issue.
now, I've written a function that can write the error message in a note. (that would be great if i could write these things inside the Visual Studio, if anybody knows, please tell me)
if we don't care about warnings, this is what I've got:
C:\Users\Nate\Documents\Visual Studio 2013\Projects\DX11Revision_Project2_1\DX11Revision_Project2\Effects.fx(162,10): error X4014: cannot have gradient operations inside loops with divergent flow control
and this is the part of code that i have an error. as you see in line 162, i try to add random neighbor pixels to my projectTexCoord and calculate Virtual point lights for my Global illumination:
// Calculate the projected texture coordinates.
projectTexCoord.x = input.lightPos.x / input.lightPos.w / 2.0f + 0.5f;
projectTexCoord.y = -input.lightPos.y / input.lightPos.w / 2.0f + 0.5f;
for (int i = 0; i < 16; i++)
for (int j = 0; j < 16; j++)
{
float2 data = float2(light.pixelSamplesArray[i / 4][j % 4], light.pixelSamplesArray[i+1 / 4][j+1 % 4]);
float2 newTexCoord = projectTexCoord + data;
float3 flux = fluxMapTexture.Sample(ObjSamplerState, newTexCoord, 0).xyz;
float3 rsmNormal = normalMapTexture.Sample(ObjSamplerState, newTexCoord, 0).xyz;
float3 rsmPosition = positionMapTexture.Sample(ObjSamplerState, newTexCoord, 0).xyz;
float3 omega = normalize(input.Pos.xyz - rsmPosition).xyz;
float distance = length(input.Pos.xyz - rsmPosition);
float ndotl1 = max(0, dot(rsmNormal, omega));
float ndotl2 = max(0, dot(input.normal, -omega));
totalIrradiance += flux *((ndotl1 * ndotl2) / (distance * distance));
}
finalColor += totalIrradiance;
return float4 (finalColor, 1.0f);
}
as i've searched over internet, someone said to change your SampleLevel to this and put the LOD to zero which i still get the same error.
someone said my problem solved by changing D3D11_FILTER_MIN_MAG_MIP_LINEAR to D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR of the sample state, but unfortunately it's the same.
this is my sampler state:
D3D11_SAMPLER_DESC sampDesc;
ZeroMemory(&sampDesc, sizeof(sampDesc));
sampDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
sampDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
sampDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
sampDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
sampDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
sampDesc.MinLOD = 0;
sampDesc.MaxLOD = D3D11_FLOAT32_MAX;
//Create the Sample State
hr = d3d11Device->CreateSamplerState(&sampDesc, &CubesTexSamplerState);
moreover, the general solution was don't use texture samples inside the for loop iteration. but i'm not have any idea of how can I generate virtual point lights without for loop.
anybody has an idea ?
Thanks so much guys
Regards