Posted By: txesmi
unrolling for loop - 07/26/15 12:49
Hi,
I have written a small shader that contains a for loop to sample an image by rows but I am getting an unrolling error that is breaking my nuts.
Here is the shader:
I set the material skills as follows:
And the error:
I checked layerCount and contains the correct value. How the hell can the for loop be unable to unroll? I am totally lost. Any idea would be appreciated.
Salud!
I have written a small shader that contains a for loop to sample an image by rows but I am getting an unrolling error that is breaking my nuts.
Here is the shader:
Code:
float4 vecSkill1; texture mtlSkin1; sampler texSampler = sampler_state { Texture = <mtlSkin1>; Mipfilter = Point; Minfilter = Point; Magfilter = Point; AddressU = Wrap; AddressV = Wrap; }; float4 PS ( in float2 inTex: TEXCOORD0 ) : COLOR0 { inTex.xy *= vecSkill1.xy; float4 color1 = 0; int layerCount = vecSkill1.z; for ( int layer=0; layer<layerCount; layer+=1 ) { float4 color2 = tex2D ( texSampler, inTex.xy ); color1.rgb = lerp ( color1.rgb, color2.rgb, color2.a ); color1.a = max ( color1.a, color2.a ); inTex.y += vecSkill1.w; } return color1; }
I set the material skills as follows:
Code:
mtlRenderer->skill1 = floatd ( bmap_width(bmp), bmap_width(bmpRenderer) ); // width proportion between render target (bmp) and color sampler (bmpRenderer) mtlRenderer->skill2 = floatd ( bmap_height(bmp), bmap_height(bmpRenderer) ); // height proportion between render target (bmp) and color sampler (bmpRenderer) mtlRenderer->skill3 = floatv ( 2 ); // number of loops mtlRenderer->skill4 = floatd ( 1, bmap_height(bmpRenderer) / bmap_height(bmp) ); // height of render target inside color sampler 0<>1 height range mtlRenderer->skin1 = bmpRenderer; bmap_process ( bmp, NULL, mtlRenderer );
And the error:
I checked layerCount and contains the correct value. How the hell can the for loop be unable to unroll? I am totally lost. Any idea would be appreciated.
Salud!