-- script.lua -- Receives a table, returns the sum of its components. -- io.write("The table the script received has:\n"); x = "" pos = nil pos1 = nil defpos = nil lastdefpos = nil dclpos = nil lastdclpos = nil lastconstpos = nil constpos = nil TempTab = {} samppos = nil lastsamppos = nil respos = nil lastrespos = nil skiplines = 0 c7pos = nil lastc7pos = nil rpos = nil xpos = nil sr = "" srw = "" sx = "" sy = "" sz = "" sw = "" rx = "x" ry = "x" rz = "x" rw = "x" r1x = "x" r1y = "x" r1z = "x" r1w = "x" c1x = "x" c1y = "x" c1z = "x" c1w = "x" c2x = "z" c2y = "z" c2z = "z" c2w = "z" vi = "v0" isDone = false DoSecondPass = false doSearch = true AddNextStr = true IsFirst = true ScreenToLS = nil SceneColorTexture = nil SceneColorTexture2 = nil SamplerPos = nil ReqPos = nil SamplerName = "" MulEnd = nil rposEnd = nil; DiffuseLightingTexture = nil textcordpos = nil textcordreg = "" FixSceneColorTexture = true FixShadowsHalo = true SpecularLightingTexture = nil MinZ_MaxZRatio = nil MaterialBufferTexture = nil VPreg = "" VPPos = nil LstIdx = 0; LightMapTextures = nil UniformPixelScalars = nil ScreenPositionScaleBias = nil ScreenPositionScaleBiasUsed = nil Texture2D_2 = nil regcnt = 0 temps = nil usedtemp1 = "r0" usedtemp2 = "r1" usedtemp3 = "r2" usedtemp4 = "r3" NvStereoFixTexture = nil v1pos = nil v2pos = nil ShadowDepthTexture = nil TranslatedWorldToShadowMatrix = nil LightAttenuationTexture = nil ScreenToLight = nil ScreenToLightUsed = nil LightEnvironmentTexture=nil fTmp = "" ftx = "" fty = "" p1 = nil p2 = nil -- search for constants names it helps to determinate shader for i = 1, #SText do if LightAttenuationTexture == nil then LightAttenuationTexture = string.find(SText[i], "LightAttenuationTexture") end if LightEnvironmentTexture == nil then LightEnvironmentTexture = string.find(SText[i], "LightEnvironmentTexture") end if ScreenToLight == nil then ScreenToLight = string.find(SText[i], "ScreenToLight") if ScreenToLight ~= nil then ScreenToLightUsed = string.find(SText[i], "unused") end end if MaterialBufferTexture == nil then MaterialBufferTexture = string.find(SText[i], "MaterialBufferTexture") end if TranslatedWorldToShadowMatrix == nil then TranslatedWorldToShadowMatrix = string.find(SText[i], "TranslatedWorldToShadowMatrix") end if ShadowDepthTexture == nil then ShadowDepthTexture = string.find(SText[i], "ShadowDepthTexture") end if SpecularLightingTexture == nil then SpecularLightingTexture = string.find(SText[i], "SpecularLightingTexture") end if ScreenPositionScaleBias == nil then ScreenPositionScaleBias = string.find(SText[i], "ScreenPositionScaleBias") if ScreenPositionScaleBias ~= nil then ScreenPositionScaleBiasUsed = string.find(SText[i], "unused") end end if DiffuseLightingTexture == nil then DiffuseLightingTexture = string.find(SText[i], "DiffuseLightingTexture") end if SceneColorTexture == nil then SceneColorTexture = string.find(SText[i], "SceneDepthTexture") end if SceneColorTexture2 == nil then SceneColorTexture2 = string.find(SText[i], "SceneColorTexture") end --x = x .. SText[i] .. string.char(13) if string.find(SText[i], "ps_5_0") ~= nil then break end end if (ScreenToLight ~= nil) and ((LightAttenuationTexture ~= nil) or (ScreenToLightUsed == nil)) and (SceneColorTexture ~= nil) and (ScreenPositionScaleBias ~= nil) then for i = 1, #SText do AddNextStr = true if skiplines > 0 then skiplines = skiplines - 1 end if doSearch then lastconstpos = string.find(SText[i], "dcl_constantbuffer") if lastconstpos ~= nil then constpos = i + 1 end if (lastconstpos == nil) and (constpos ~= nil) then if i == constpos then x = x .. "dcl_constantbuffer cb9[32], immediateIndexed" .. string.char(10) end end lastsamppos = string.find(SText[i], "dcl_sampler") if lastsamppos ~= nil then samppos = i + 1 end if (lastsamppos == nil) and (samppos ~= nil) then if i == samppos then x = x .. "dcl_sampler s15, mode_default" .. string.char(10) end end lastrespos = string.find(SText[i], "dcl_resource_") if lastrespos ~= nil then respos = i + 1 end if (lastrespos == nil) and (respos ~= nil) then if i == respos then x = x .. "dcl_resource_texture2d (float,float,float,float) t125" .. string.char(10) end end temps = string.find(SText[i], "dcl_temps ") if temps ~= nil then str = SText[i] units = 0 for idx = temps + 10, string.len(str) do units = units * 10 units = units + string.byte(str, idx) - 48 if((units < 0) or (units > 9)) then break end end AddNextStr = false usedtemp1 = "r" .. string.format('%d', units) x = x .. "dcl_temps " .. string.format('%d', units + 1) .. string.char(10) end ReqPos = string.find(SText[i], "cb2[1]", 1, true) --end if ReqPos ~= nil then --x = x .. "\\\\dddddd" .. string.char(10) rpos, MulEnd = string.find(SText[i], "mad ") if rpos == nil then rpos, MulEnd = string.find(SText[i], "mad_sat ") end if rpos ~= nil then rpos, MulEnd = string.find(SText[i + 1], "div ") if rpos == nil then rpos, MulEnd = string.find(SText[i + 1], "div_sat ") end if rpos ~= nil then xpos = string.find(SText[i + 1], ".", MulEnd, true) srw = string.sub(SText[i + 1], MulEnd, xpos - 1) sw = string.sub(SText[i + 1], xpos + 1, xpos + 1) rpos, MulEnd = string.find(SText[i + 2], "mul ") if rpos == nil then rpos, MulEnd = string.find(SText[i + 2], "mul_sat ") end if rpos ~= nil then xpos = string.find(SText[i + 2], ".", MulEnd, true) sr = string.sub(SText[i + 2], MulEnd, xpos - 1) sx = string.sub(SText[i + 2], xpos + 1, xpos + 1) sy = string.sub(SText[i + 2], xpos + 2, xpos + 2) x = x .. SText[i] .. string.char(10) x = x .. SText[i + 1] .. string.char(10) x = x .. SText[i + 2] .. string.char(10) x = x .. "sample(texture2d)(float,float,float,float) " .. usedtemp1 .. ".xyzw, l(0.0625, 0.0625, 0.0625, 0.0625), t125.xyzw, s15" .. string.char(10) x = x .. "add " .. usedtemp1 .. ".y, " .. srw .. "." .. sw .. ", -" .. usedtemp1 .. ".y" .. string.char(10) x = x .. "mul " .. usedtemp1 .. ".x, " .. usedtemp1 .. ".x, " .. usedtemp1 .. ".y" .. string.char(10) x = x .. "add ".. sr .. "." .. sx .. ", " .. sr .. "." .. sx .. ", -" .. usedtemp1 .. ".x" .. string.char(10) AddNextStr = false skiplines = 3 doSearch = false isDone = true DoSecondPass = true end end end end end if skiplines > 0 then AddNextStr = false end if AddNextStr then x = x .. SText[i] .. string.char(10) end end if isDone then x = x .. string.char(10) .. "//usepres" end end if isDone == false then -- it's probably dynamic shadows/lights -- will try to inject out fixing code after retriving value from W buffer if ((MaterialBufferTexture ~= nil) or (SpecularLightingTexture ~= nil) or (DiffuseLightingTexture ~= nil) or (SceneColorTexture ~= nil) or (((LightEnvironmentTexture ~= nil) or (ScreenPositionScaleBiasUsed == nil)) and (SceneColorTexture2 ~= nil))) and (ScreenPositionScaleBias ~= nil) then for i = 1, #SText do AddNextStr = true if skiplines > 0 then skiplines = skiplines - 1 end if doSearch then temps = string.find(SText[i], "dcl_temps ") if temps ~= nil then str = SText[i] units = 0 for idx = temps + 10, string.len(str) do units = units * 10 units = units + string.byte(str, idx) - 48 if((units < 0) or (units > 9)) then break end end AddNextStr = false usedtemp1 = "r" .. string.format('%d', units) usedtemp2 = "r" .. string.format('%d', units + 1) usedtemp3 = "r" .. string.format('%d', units + 2) usedtemp4 = "r" .. string.format('%d', units + 3) x = x .. "dcl_temps " .. string.format('%d', units + 4) .. string.char(10) end --if(fTmp ~= "") and (ftx ~= "") and (fty ~= "") then -- rpos = string.find(SText[i], ".", 1, true) --p1, p2 = string.find(SText[i], fTmp, 1, true) --tmpstr = "" --if(rpos ~= nil) and (p1 ~= nil) then --if(rpos > p1) then --p1, p2 = string.find(SText[i], fTmp, rpos + 1, true) --fTmp = "" --end --if (rpos ~= nil) and (p1 ~= nil) and (rpos < p1) then --rpos = string.find(SText[i], "max ") --if rpos == nil then --rpos, MulEnd = string.find(SText[i], "mad ") --end --if rpos ~= nil then --tmpstr = string.sub(SText[i], p2 + 1, p2 + 6) --rpos = string.find(tmpstr, ftx, 1 , true) --if rpos ~= nil then -- rpos = string.find(tmpstr, fty, 1 , true) -- end -- end -- if rpos ~= nil then --x = x .. "\\\\marked code" .. string.char(10) -- x = x .. string.sub(SText[i], 1, p1 - 1) .. usedtemp4 .. string.sub(SText[i], p2 + 1, string.len(SText[i])) .. string.char(10) -- AddNextStr = false --end --end --if(fTmp == "") then --ftx = "" --fty = "" --end --end --end if (ShadowDepthTexture ~= nil) and (TranslatedWorldToShadowMatrix ~= nil) then lastsamppos = string.find(SText[i], "dcl_sampler") if lastsamppos ~= nil then samppos = i + 1 end if (lastsamppos == nil) and (samppos ~= nil) then if i == samppos then x = x .. "dcl_sampler s15, mode_default" .. string.char(10) end end lastrespos = string.find(SText[i], "dcl_resource_") if lastrespos ~= nil then respos = i + 1 end if (lastrespos == nil) and (respos ~= nil) then if i == respos then x = x .. "dcl_resource_texture2d (float,float,float,float) t125" .. string.char(10) end end --if ReqPos == nil then ReqPos = string.find(SText[i], "cb2[1]", 1, true) --end if ReqPos ~= nil then --x = x .. "\\\\dddddd" .. string.char(10) rpos, MulEnd = string.find(SText[i], "mad ") if rpos == nil then rpos, MulEnd = string.find(SText[i], "mad_sat ") end if rpos ~= nil then rpos, MulEnd = string.find(SText[i + 1], "div ") if rpos == nil then rpos, MulEnd = string.find(SText[i + 1], "div_sat ") end if rpos ~= nil then xpos = string.find(SText[i + 1], ".", MulEnd, true) sr = string.sub(SText[i + 1], MulEnd, xpos - 1) sx = string.sub(SText[i + 1], xpos + 1, xpos + 1) AddNextStr = false skiplines = 2 --v1.wwww x = x .. SText[i] .. string.char(10) x = x .. SText[i + 1] .. string.char(10) x = x .. "mov " .. usedtemp1 .. ".xyzw, v0.xyww" .. string.char(10) x = x .. "div " .. usedtemp2 ..".x, l(0x3F800000, 0x3F800000, 0x3F800000, 0x3F800000), ".. sr .."." .. sx .. string.char(10) x = x .. "sample(texture2d)(float,float,float,float) " .. usedtemp3 .. ".xyzw, l(0.0625, 0.0625, 0.0625, 0.0625), t125.xyzw, s15" .. string.char(10) x = x .. "add " .. usedtemp3 .. ".y, " .. sr .. "." .. sx .. ", -" .. usedtemp3 .. ".y" .. string.char(10) x = x .. "mul " .. usedtemp3 .. ".x, " .. usedtemp3 .. ".x, " .. usedtemp3 .. ".y" .. string.char(10) x = x .. "mul " .. usedtemp3 .. ".x, " .. usedtemp3 .. ".x, " .. usedtemp2 .. ".x" .. string.char(10) x = x .. "mul " .. usedtemp3 .. ".x, " .. usedtemp3 .. ".x, v0.w" .. string.char(10) x = x .. "add " .. usedtemp1 .. ".x, " .. usedtemp1 .. ".x, -" .. usedtemp3 .. ".x" .. string.char(10) x = x .. "mov " .. usedtemp2 .. ".xyzw, v7.xyzw" .. string.char(10) x = x .. "mul " .. usedtemp3 .. ".xyz, " .. usedtemp1 .. ".yyyy, " .. usedtemp2 .. ".xyzx" .. string.char(10) x = x .. "mov " .. usedtemp2 .. ".xyzw, v6.xyzw" .. string.char(10) x = x .. "mad " .. usedtemp3 .. ".xyz, " .. usedtemp2 .. ".xyzx, " .. usedtemp1 .. ".xxxx, " .. usedtemp3 .. ".xyzx" .. string.char(10) x = x .. "mov " .. usedtemp2 .. ".xyzw, v8.xyzw" .. string.char(10) x = x .. "mad " .. usedtemp3 .. ".xyz, " .. usedtemp2 .. ".xyzx, " .. usedtemp1 .. ".wwww, " .. usedtemp3 .. ".xyzx" .. string.char(10) end end end --if ReqPos == nil then ReqPos = string.find(SText[i], "v1.wwww", 1, true) --end if ReqPos ~= nil then rpos, MulEnd = string.find(SText[i], "div ") if rpos == nil then rpos, MulEnd = string.find(SText[i], "div_sat ") end if rpos ~= nil then xpos = string.find(SText[i], ".", MulEnd, true) sr = string.sub(SText[i], MulEnd, xpos - 1) sx = string.sub(SText[i], xpos + 1, xpos + 1) sy = string.sub(SText[i], xpos + 2, xpos + 2) sz = string.sub(SText[i], xpos + 3, xpos + 3) if sx == "x" then r1x = "x" r1y = "y" r1z = "z" r1w = "x" end if sx == "y" then r1x = "x" r1y = "x" r1z = "y" r1w = "z" end x = x .. "div " .. sr .. "." .. sx .. sy .. sz ..", " .. usedtemp3 .. "." .. r1x .. r1y .. r1z .. r1w .. ", v1.wwww" .. string.char(10) AddNextStr = false doSearch = false end end end lastconstpos = string.find(SText[i], "dcl_constantbuffer") if lastconstpos ~= nil then constpos = i + 1 end if (lastconstpos == nil) and (constpos ~= nil) then if i == constpos then x = x .. "dcl_constantbuffer cb9[32], immediateIndexed" .. string.char(10) end end lastdclpos = string.find(SText[i], "dcl_input_ps") if lastdclpos ~= nil then dclpos = i + 1 end if (lastdclpos == nil) and (dclpos ~= nil) then if i == dclpos then xpos = string.find(SText[i - 1], ".", 1, true) vi = "v9" --string.sub(SText[i], MulEnd, xpos - 1) if (ShadowDepthTexture ~= nil) and (TranslatedWorldToShadowMatrix ~= nil) then x = x .. "dcl_input_ps linear v6.xyzw" .. string.char(10) x = x .. "dcl_input_ps linear v7.xyzw" .. string.char(10) x = x .. "dcl_input_ps linear v8.xyzw" .. string.char(10) end x = x .. "dcl_input_ps_siv linear noperspective v9.xy, position" .. string.char(10) end end --if SamplerPos == nil then SamplerPos = string.find(SText[i], "cb2[0]", 1, true) --end if SamplerPos ~= nil then rpos, MulEnd = string.find(SText[i], "mad ") if rpos == nil then rpos, MulEnd = string.find(SText[i], "mad_sat ") end if rpos ~= nil then --rpos = rpos + 4 xpos = string.find(SText[i], ".", MulEnd, true) sr = string.sub(SText[i], MulEnd, xpos - 1) sx = string.sub(SText[i], xpos + 1, xpos + 1) sy = string.sub(SText[i], xpos + 2, xpos + 2) r1x = sx r1y = sx r1z = sx r1w = sx if sx == "x" then --c1x = "1920" --c2x = "0.000260416667" c1x = "x" c2x = "z" end if sx == "y" then --c1y = "1920" --c2y = "0.000260416667" c1y = "x" c2y = "z" end if sx == "z" then --c1z = "1920" --c2z = "0.000260416667" c1z = "x" c2z = "z" end if sy == "y" then ry = "y" r1y = "y" --c1y = "1080" --c2y = "0.000462962962" c1y = "y" c2y = "w" end if sy == "z" then rz = "y" r1z = "z" --c1z = "1080" --c2z = "0.000462962962" c1z = "y" c2z = "w" end if sy == "w" then rw = "y" r1w = "w" c1w = "y" c2w = "w" --c1w = "1080" --c2w = "0.000462962962" end --xpos, rposEnd = string.find(SText[c7pos], sr, xpos + 1) --sw = string.sub(SText[c7pos], rposEnd + 2, rposEnd + 2) x = x .. SText[i] .. string.char(10) --x = x .. "div " .. sr .. "." .. sx .. sy .. ", " .. vi .. "." .. rx .. ry .. rz .. rw .. ", l(" .. c1x .. ", " .. c1y .. ", " .. c1z .. ", " .. c1w .. ")" .. string.char(10) x = x .. "mov " .. usedtemp4 .. "." .. sx .. sy .. ", " .. sr .. "." .. r1x .. r1y .. r1z .. r1w .. string.char(10) x = x .. "div " .. sr .. "." .. sx .. sy .. ", " .. vi .. "." .. rx .. ry .. rz .. rw .. ", cb9[23]." .. c1x .. c1y .. c1z .. c1w .. string.char(10) x = x .. "add " .. sr .. "." .. sx .. sy .. ", " .. sr .. "." .. r1x .. r1y .. r1z .. r1w .. ", cb9[23]." .. c2x .. c2y .. c2z .. c2w .. string.char(10) --x = x .. "add " .. sr .. "." .. sx .. sy .. ", " .. sr .. "." .. r1x .. r1y .. r1z .. r1w .. ", l(" .. c2x .. ", " .. c2y .. ", " .. c2z .. ", " .. c2w .. ")" .. string.char(10) fTmp = sr ftx = sx fty = sy --if (ShadowDepthTexture == nil) or (TranslatedWorldToShadowMatrix == nil) then -- doSearch = false --end isDone = true AddNextStr = false end end end if skiplines > 0 then AddNextStr = false end if AddNextStr then x = x .. SText[i] .. string.char(10) end end end end if (isDone == false) or (DoSecondPass) then -- it's probably dynamic shadows/lights -- will try to inject out fixing code after retriving value from W buffer --TempTab = SText if (DoSecondPass) then srlen = string.len(x) idx = 1 startIdx = 1 index1 = 1 while (srlen + 1 >= idx) do if (string.byte(x, idx) == 10) or (srlen == idx) then --table.setn(TempTab,index1 + 1) TempTab[index1] = string.sub(x, startIdx, idx - 1) startIdx = idx + 1 index1 = index1 + 1 end if (srlen == idx) then break end idx = idx + 1 end doSearch = true --isDone = false --TempTab = aTab else for i = 1, #SText do --table.setn(TempTab,i + 1) TempTab[i] = SText[i] end end if (SceneColorTexture ~= nil) and (ScreenPositionScaleBias ~= nil) then x = "" for i = 1, #TempTab do AddNextStr = true if skiplines > 0 then skiplines = skiplines - 1 end if doSearch then if v1pos == nil then v1pos = string.find(TempTab[i], "dcl_input_ps linear v0.xy") end if v2pos == nil then v2pos = string.find(TempTab[i], "dcl_input_ps linear v1.xyz") end lastsamppos = string.find(TempTab[i], "dcl_sampler") if lastsamppos ~= nil then samppos = i + 1 end if (lastsamppos == nil) and (samppos ~= nil) and (DoSecondPass == false) then if i == samppos then x = x .. "dcl_sampler s15, mode_default" .. string.char(10) end end lastrespos = string.find(TempTab[i], "dcl_resource_") if lastrespos ~= nil then respos = i + 1 end if (lastrespos == nil) and (respos ~= nil) and (DoSecondPass == false) then if i == respos then x = x .. "dcl_resource_texture2d (float,float,float,float) t125" .. string.char(10) end end temps = string.find(TempTab[i], "dcl_temps ") if temps ~= nil then str = TempTab[i] units = 0 for idx = temps + 10, string.len(str) do units = units * 10 units = units + string.byte(str, idx) - 48 if((units < 0) or (units > 9)) then break end end AddNextStr = false usedtemp1 = "r" .. string.format('%d', units) usedtemp2 = "r" .. string.format('%d', units + 1) usedtemp3 = "r" .. string.format('%d', units + 2) x = x .. "dcl_temps " .. string.format('%d', units + 3) .. string.char(10) end --if ReqPos == nil then ReqPos = string.find(TempTab[i], "cb2[1]", 1, true) --end if ReqPos ~= nil then --x = x .. "\\\\dddddd" .. string.char(10) rpos, MulEnd = string.find(TempTab[i], "mad ") if rpos == nil then rpos, MulEnd = string.find(TempTab[i], "mad_sat ") end if rpos ~= nil then rpos, MulEnd = string.find(TempTab[i + 1], "div ") if rpos == nil then rpos, MulEnd = string.find(TempTab[i + 1], "div_sat ") end if rpos ~= nil then xpos = string.find(TempTab[i + 1], ".", MulEnd, true) sr = string.sub(TempTab[i + 1], MulEnd, xpos - 1) sx = string.sub(TempTab[i + 1], xpos + 1, xpos + 1) AddNextStr = false skiplines = 2 --v1.wwww x = x .. TempTab[i] .. string.char(10) x = x .. TempTab[i + 1] .. string.char(10) x = x .. "mov " .. usedtemp1 .. ".xyzw, v5.xyww" .. string.char(10) x = x .. "div " .. usedtemp2 ..".x, l(0x3F800000, 0x3F800000, 0x3F800000, 0x3F800000), ".. sr .."." .. sx .. string.char(10) x = x .. "sample(texture2d)(float,float,float,float) " .. usedtemp3 .. ".xyzw, l(0.0625, 0.0625, 0.0625, 0.0625), t125.xyzw, s15" .. string.char(10) x = x .. "add " .. usedtemp3 .. ".y, " .. sr .. "." .. sx .. ", -" .. usedtemp3 .. ".y" .. string.char(10) x = x .. "mul " .. usedtemp3 .. ".x, " .. usedtemp3 .. ".x, " .. usedtemp3 .. ".y" .. string.char(10) x = x .. "mul " .. usedtemp3 .. ".x, " .. usedtemp3 .. ".x, " .. usedtemp2 .. ".x" .. string.char(10) --x = x .. "mul " .. usedtemp3 .. ".x, " .. usedtemp3 .. ".x, v0.w" .. string.char(10) x = x .. "add " .. usedtemp1 .. ".x, " .. usedtemp1 .. ".x, -" .. usedtemp3 .. ".x" .. string.char(10) x = x .. "mov " .. usedtemp2 .. ".xyzw, v7.xyzw" .. string.char(10) x = x .. "mul " .. usedtemp3 .. ".xyz, " .. usedtemp1 .. ".yyyy, " .. usedtemp2 .. ".xyzx" .. string.char(10) x = x .. "mov " .. usedtemp2 .. ".xyzw, v6.xyzw" .. string.char(10) x = x .. "mad " .. usedtemp3 .. ".xyz, " .. usedtemp2 .. ".xyzx, " .. usedtemp1 .. ".xxxx, " .. usedtemp3 .. ".xyzx" .. string.char(10) x = x .. "mov " .. usedtemp2 .. ".xyzw, v8.xyzw" .. string.char(10) --x = x .. "mad " .. usedtemp3 .. ".xyz, " .. usedtemp2 .. ".xyzx, " .. usedtemp1 .. ".wwww, " .. usedtemp3 .. ".xyzx" .. string.char(10) x = x .. "add " .. usedtemp3 .. ".xyz, " .. usedtemp3 .. ".xyzx, " .. usedtemp2 .. ".xyzx" .. string.char(10) end end end --if ReqPos == nil then ReqPos = string.find(TempTab[i], "-v1.xyzx", 1, true) --end if (ReqPos ~= nil) and (v2pos ~= nil) and (v1pos ~= nil) then rpos, MulEnd = string.find(TempTab[i], "mad ") if rpos == nil then rpos, MulEnd = string.find(TempTab[i], "mad_sat ") end if rpos ~= nil then --mad r0.xyz, -v1.xyzx, r0.xxxx, cb0[1].xyzx x = x .. string.sub(TempTab[i], 1, ReqPos - 1) .. "-".. usedtemp3 .. ".xyzx" .. string.sub(TempTab[i], ReqPos + 8, string.len(TempTab[i])) .. string.char(10) AddNextStr = false --doSearch = false isDone = true end end if ReqPos == nil then ReqPos = string.find(TempTab[i], "v1.xyzx", 1, true) if (ReqPos ~= nil) and (v2pos ~= nil) and (v1pos ~= nil) then rpos, MulEnd = string.find(TempTab[i], "dp3 ") if rpos == nil then rpos, MulEnd = string.find(TempTab[i], "dp3_sat ") end if rpos ~= nil then x = x .. string.sub(TempTab[i], 1, ReqPos - 1) .. usedtemp3 .. ".xyzx, " .. usedtemp3 .. ".xyzx" .. string.char(10) AddNextStr = false --doSearch = false isDone = true else ReqPos = nil end end end if ReqPos == nil then ReqPos = string.find(TempTab[i], "v1.xyzx", 1, true) if (ReqPos ~= nil) and (v2pos ~= nil) and (v1pos ~= nil) then rpos, MulEnd = string.find(TempTab[i], "mul ") if rpos == nil then rpos, MulEnd = string.find(TempTab[i], "mul_sat ") end if rpos ~= nil then x = x .. string.sub(TempTab[i], 1, ReqPos - 1) .. usedtemp3 .. ".xyzx" .. string.sub(TempTab[i], ReqPos + 7, string.len(TempTab[i])) .. string.char(10) AddNextStr = false --doSearch = false isDone = true end end end lastdclpos = string.find(TempTab[i], "dcl_input_ps") if lastdclpos ~= nil then dclpos = i + 1 end if (lastdclpos == nil) and (dclpos ~= nil) then if i == dclpos then xpos = string.find(TempTab[i - 1], ".", 1, true) vi = "v9" --string.sub(SText[i], MulEnd, xpos - 1) x = x .. "dcl_input_ps linear v5.xyzw" .. string.char(10) x = x .. "dcl_input_ps linear v6.xyzw" .. string.char(10) x = x .. "dcl_input_ps linear v7.xyzw" .. string.char(10) x = x .. "dcl_input_ps linear v8.xyzw" .. string.char(10) ---x = x .. "dcl_input_ps_siv linear noperspective v9.xy, position" .. string.char(10) end end end if skiplines > 0 then AddNextStr = false end if AddNextStr then x = x .. TempTab[i] .. string.char(10) end end if (isDone) and (DoSecondPass) then x = x .. string.char(10) .. "//usepres" end end end if isDone then return x else return "" end;