Please help to convert instruction from ps 2.0 to ps1.4
Hello, I have a hlsl shader that works fine with ps2.0 compile, however I want
a fallback for cards that only support ps1.4. The problem is a line that
divides texture coordinates. "In.tex0.xy / temp". I understand that ps1.4
dosent support division and ps2.0 does? Is there any workaround?
Thanks much for any help!
Can you pull 1/temp out to the CPU or vertex shader? If not then you can use tex2Dproj, which divides by the last component before lookup.
Thanks James, I appreciate your help, it may not be immediately apparent that I
am clueless!
I should have included the type of the variable "temp" is. The line can be
better written as "float2 temp2 = In.tex0.xy/In.tex.z". I looked at the
tex2Dproj function, but couldnt get it to work with these variable types.
If I could just convert this line for ps1.4 I would be done.
Perhaps I could include this line as Assembly?
Thanks again.
am clueless!
I should have included the type of the variable "temp" is. The line can be
better written as "float2 temp2 = In.tex0.xy/In.tex.z". I looked at the
tex2Dproj function, but couldnt get it to work with these variable types.
If I could just convert this line for ps1.4 I would be done.
Perhaps I could include this line as Assembly?
Thanks again.
I'm not an expert, but I remember something about these .xy, .xz and other extractors might have been introduced with shader model 2.0. Maybe you can just replace that line with the following:
-Markus-
float2 temp2;temp2.x = In.tex0.x / In.tex.z;temp2.y = In.tex0.y / In.tex.z;
-Markus-
Thank you Markus, but I get a "cannot map expression to pixel shader instruction set" error with that. It is the "/" (division) that is giving the problem. if I replace "/" with "*", then it compiles under ps1.4. But I need to divide and not multiply. It seems ps1.4 dosent support division :(
Unless you need to divide for the purposes of projective texturing (in which case you should look at tex2Dproj) you're out of luck - the ps_1_4 instruction set doesn't support floating inversion (or, equivalently, division by variables). On the off-chance that temp is a constant, if you mark it const, the HLSL assembler will hard-code it in as multiplication by the reciprocal, and everything will be tickedy-boo.
Is it possible for you to perform the division in the vertex shader? This would result in the values being interpolated in reciprocal-space, which may not work out, but if the modulus of continuity of the parameter over adjacent vertices is small, the error may not be noticeable.
Admiral
Is it possible for you to perform the division in the vertex shader? This would result in the values being interpolated in reciprocal-space, which may not work out, but if the modulus of continuity of the parameter over adjacent vertices is small, the error may not be noticeable.
Admiral
how about:
you just need to keep the instructions to a minimum, and the number of texture reads should be less than 4.
/*float dx = 1 / x_value;float dy = 1 / y_value;*/float2 texcoords;texcoords.x = IN.texcoords.x * dx;texcoords.y = IN.texcoords.y * dy;col = tex2D( texSampler, texcoords );
you just need to keep the instructions to a minimum, and the number of texture reads should be less than 4.
Quote:Original post by josiah7
Thanks James, I appreciate your help, it may not be immediately apparent that I
am clueless!
I should have included the type of the variable "temp" is. The line can be
better written as "float2 temp2 = In.tex0.xy/In.tex.z". I looked at the
tex2Dproj function, but couldnt get it to work with these variable types.
If I could just convert this line for ps1.4 I would be done.
Perhaps I could include this line as Assembly?
Thanks again.
I would suggest you change your vertex shader so that tex0 is in homogeneous coordinates and then use the tex2Dproj instruction in your pixel shader.
[Edited by - Mastaba on May 13, 2007 2:25:01 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement