Corrail
2006-11-03, 12:36:35
Hallo!
Ich versuche gerade folgendes Codestück von GLSL nach DX/HLSL zu portieren:
vec3 tmp_texcoord = v2f_Texcoord;
vec3 offset = view*my_delta;
float height = texture2D(a2v_Heightmap, tmp_texcoord.xy).w;
bool found = false;
if (height < tmp_texcoord.z)
{
for (int i = 0; i <= my_sample_count; i++)
{
tmp_texcoord += offset;
height = texture2D(a2v_Heightmap, tmp_texcoord.xy).w;
if (height >= tmp_texcoord.z)
{
found = true;
break;
}
}
}
das würde bei mir so ausschauen:
float3 tmp_texcoord = IN.TexCoord;
float3 offset = view*my_delta;
float height = tex2D(DMapSampler, tmp_texcoord.xy).w;
bool found = false;
if (height < tmp_texcoord.z)
{
for (int i = 0; i <= my_sample_count; i++)
{
tmp_texcoord += offset;
height = tex2D(DMapSampler, tmp_texcoord.xy).w;
if (height >= tmp_texcoord.z)
{
found = true;
break;
}
}
}
Wenn ich das jetzt mit ps_3_0 kompiliere, schreit er, dass er "break" nicht mag. Kennt HLSL im ps_3_0 kein break? Gut, dann hab ich folgendes probiert:
float3 tmp_texcoord = IN.TexCoord;
float3 offset = view*my_delta;
float height = tex2D(DMapSampler, tmp_texcoord.xy).w;
bool found = false;
if (height < tmp_texcoord.z)
{
for (int i = 0; i <= my_sample_count; i++)
{
if (!found)
{
tmp_texcoord += offset;
height = tex2D(DMapSampler, tmp_texcoord.xy).w;
if (height >= tmp_texcoord.z)
{
found = true;
//break;
}
}
}
}
Alles andere als schön und es funktioniert auch nicht. Bei der for Schleife schreit er, dass es nicht gewährleistet ist, dass sie mit 1024 iterationen endet. Irgendwie kommt mir das sehr suspekt vor. Was kann ich da tun?
Ich versuche gerade folgendes Codestück von GLSL nach DX/HLSL zu portieren:
vec3 tmp_texcoord = v2f_Texcoord;
vec3 offset = view*my_delta;
float height = texture2D(a2v_Heightmap, tmp_texcoord.xy).w;
bool found = false;
if (height < tmp_texcoord.z)
{
for (int i = 0; i <= my_sample_count; i++)
{
tmp_texcoord += offset;
height = texture2D(a2v_Heightmap, tmp_texcoord.xy).w;
if (height >= tmp_texcoord.z)
{
found = true;
break;
}
}
}
das würde bei mir so ausschauen:
float3 tmp_texcoord = IN.TexCoord;
float3 offset = view*my_delta;
float height = tex2D(DMapSampler, tmp_texcoord.xy).w;
bool found = false;
if (height < tmp_texcoord.z)
{
for (int i = 0; i <= my_sample_count; i++)
{
tmp_texcoord += offset;
height = tex2D(DMapSampler, tmp_texcoord.xy).w;
if (height >= tmp_texcoord.z)
{
found = true;
break;
}
}
}
Wenn ich das jetzt mit ps_3_0 kompiliere, schreit er, dass er "break" nicht mag. Kennt HLSL im ps_3_0 kein break? Gut, dann hab ich folgendes probiert:
float3 tmp_texcoord = IN.TexCoord;
float3 offset = view*my_delta;
float height = tex2D(DMapSampler, tmp_texcoord.xy).w;
bool found = false;
if (height < tmp_texcoord.z)
{
for (int i = 0; i <= my_sample_count; i++)
{
if (!found)
{
tmp_texcoord += offset;
height = tex2D(DMapSampler, tmp_texcoord.xy).w;
if (height >= tmp_texcoord.z)
{
found = true;
//break;
}
}
}
}
Alles andere als schön und es funktioniert auch nicht. Bei der for Schleife schreit er, dass es nicht gewährleistet ist, dass sie mit 1024 iterationen endet. Irgendwie kommt mir das sehr suspekt vor. Was kann ich da tun?