   Re-writing PS 2.0 code for PS 1.4?
  I'm a modder on a Battlefield 2 project working on some shader re-writes. BF2 was designed around shader model 2.0 but supports older video cards using Pixel Shader 1.4. For now I'm just using compile_ps_2 for simplicity's sake, but I will need to write a version for older compile targets eventually. Rendermonkey doesn't offer a 1.4 compile target, so what things do I need to change to get my shader to work under compile ps_1_4 ?For reference, here is the (rather simple) shader.struct APP2VS_Quad{    vec2Pos : POSITION0;    vec2TexCoord0 : TEXCOORD0;};struct VS2PS_Quad2{    vec4Pos : POSITION;    vec2TexCoord0: TEXCOORD0;    vec2TexCoord1: TEXCOORD1;};struct PS2FB_Combine{    vec4Col0 : COLOR0;};VS2PS_Quad2 vs_WaveDistortion( APP2VS_Quad indata ){   VS2PS_Quad2 output;   output.Pos = float4(indata.Pos.xy, 0, 1);   output.TexCoord0 = indata.TexCoord0;   output.TexCoord1 = indata.Pos.xy;   return output;}PS2FB_Combine ps_WaveDistortion(VS2PS_Quad2 indata){float tcx = indata.TexCoord0.x;float tcy = indata.TexCoord0.y;float xopacity = 4 * tcx * tcx - 4 * tcx + 1.5;float yopacity = 4 * tcy * tcy - 4 * tcy + 1.5;float opacity = xopacity * yopacity;PS2FB_Combine outdata;outdata.Col0 = dot(float3(0.3,0.6,0.1), tex2D(sampler0bilin, indata.TexCoord0));outdata.Col0.r += (opacity * 0.05);outdata.Col0.a = opacity;return outdata;}technique WaveDistortion{pass p0{ZEnable = FALSE;AlphaBlendEnable = TRUE;AlphaTestEnable = FALSE;StencilEnable = FALSE;SrcBlend = SRCALPHA;DestBlend = INVSRCALPHA;VertexShader = compile vs_1_1 vs_WaveDistortion();PixelShader = compile ps_2_0 ps_WaveDistortion();}}Thanks!   
  You code can at lease be compiled under ps_1_4, and I've tried this: "PixelShader = compile ps_1_4 ps_WaveDistortion(); ".There are warnings:PS2FB_Combine ps_WaveDistortion(VS2PS_Quad2 indata){float tcx = indata.TexCoord0.x;float tcy = indata.TexCoord0.y;float xopacity = 4 * tcx * tcx - 4 * tcx + 1.5; //warning x4704:literal values outside range -1 to 1 are all clamped to all ps_1_x shader models.float yopacity = 4 * tcy * tcy - 4 * tcy + 1.5; //The same warningfloat opacity = xopacity * yopacity;PS2FB_Combine outdata; outdata.Col0 = dot(float3(0.3,0.6,0.1), tex2D(g_samTiger, indata.TexCoord0));outdata.Col0.r += (opacity * 0.05);outdata.Col0.a = opacity;return outdata;}Maybe you should check your codes under NVidia's FX editor or DX Effect Edit.It's a solution that you just multiply values by 0.1, then divide them by 0.1 after operations. Moreover, float values with same operations should be operated at the same time. As follows:float2 tcxy = indata.TexCoord0;float2 opxy = tcxy*tcxy*0.4-tcxy*0.4+float2(0.15,0.15);float opacity = opxy.x*opxy.y / 0.1;PS2FB_Combine outdata; outdata.Col0 = dot(float3(0.3,0.6,0.1), tex2D(g_samTiger, indata.TexCoord0));outdata.Col0.r += (opacity * 0.05);outdata.Col0.a = opacity;return outdata;I am not sure whether it will generates the result you want, because alpha should be within 0 to 1, and that's not garanteed at "outdata.Col0.a = opacity";Good luck, BF is a good game.;  Ah, so FX Composer can compile 1.4 shaders? If so then I can just pick that up and experiment in there (I've only used Rendermonkey thus far.)Do you have a link to somewhere comparing the relative limitations of 1.4 compared to 2.0 (i.e. if there are certain functions unavailable and other similar caveats) ? If there's some sort of HLSL reference manual comparing versions (not just the most modern) then I can look up most of this myself.Thanks for the help and optimization advice! :)   ;  I don't know much about NVidia's FX editor. You can download all manuals and the editor itself for free at http://developer.nvidia.com/.For me , I just use Effect Edit which is included in the DirectX SDK, which can be downloaded on microsoft.com, no doubt.  If your game is based on DX, don't use NVidia's stuff anyway, because their standard is called CG, not HLSL. These two languages are most the same, but there are still some gaps between them. I don't think you want to write codes twice. DX SDK has fully discribed details about PS2.0 and what's incompatible in PS1.4. Maybe you should also refer to 《The Complete Effect and HLSL Guide》. If your game is based on OpenGl, the GPU language is so called GLSL, which is totally unfamilar for me. Generally, they are not different at all in the level of asm, and the language rules only depend on the SDK and the compiler itself. 3DMax is also HLSL compatible, and it is also very suitable for HLSL editing.   ;  Note that if you want to use PS1.4 with a recent SDK, you'd have to specify D3DXSHADER_USE_LEGACY_D3DX9_31_DLL as a flag to D3DXCreateEffectFromFile (or its friends).Differences of PS1.4 from PS2 can be found under the Asm Shader Reference in the DX docs (under DirectX Graphics \ Direct3D 9 \ Reference). A short list of differences:Only 6 textures vs. 16.Only one level of texture indirection.Only 8 arithmetic instructions per phase (2 phases) vs. 64 total.Fewer registers (constants, temporary).Integer math vs. floating point.This also means many missing math instructions -- reciprocal, square root, sine, etc.;  Great info, thanks a lot guys!   