-- script.lua x = "" pos = nil pos1 = nil defpos = nil lastdefpos = nil dclpos = nil lastdclpos = nil c7pos = nil lastc7pos = nil rpos = nil xpos = nil SamplerPos = nil sr = "" sx = "" sw = "" sm = "" SamplerName="" CRatio = "" CeyePos = "" invviewname = "" ProjectionName="" isDone = false doSearch = true AddNextStr = true IsFirst = true GBufferDepth = nil RenderRatio=nil eyePositionWS=nil cameraFarMinusNear=nil invview=nil Projection=nil -- search for constants names it helps to determinate shader for i = 1, #SText do if invview == nil then invview = string.find(SText[i], "invview") else if (invview ~= nil) and (string.find(SText[i], "invview") ~= nil) then --CRatio = SText[i] if invviewname == "" then --CRatio = SText[i] SamplerPos = string.find(SText[i], "c", 1, true) if SamplerPos ~= nil then str = SText[i] len = 0 for idx = SamplerPos + 1, string.len(str) do units = string.byte(str, idx) - 48 if((units < 0) or (units > 9)) then break end len = len + 1 end invviewname = string.sub(SText[i], SamplerPos , SamplerPos + len) end end end end if Projection == nil then Projection = string.find(SText[i], "Projection") else if (Projection ~= nil) and (string.find(SText[i], "Projection") ~= nil) then --CRatio = SText[i] if ProjectionName == "" then --CRatio = SText[i] SamplerPos = string.find(SText[i], "c", Projection + 9, true) if SamplerPos ~= nil then str = SText[i] len = 0 for idx = SamplerPos + 1, string.len(str) do units = string.byte(str, idx) - 48 if((units < 0) or (units > 9)) then break end len = len + 1 end ProjectionName = string.sub(SText[i], SamplerPos , SamplerPos + len) end end end end if cameraFarMinusNear == nil then cameraFarMinusNear = string.find(SText[i], "cameraFarMinusNear") end if string.find(SText[i], "vs_3_0") ~= nil then break end x = x .. SText[i] .. "//" .. SamplerName .. " invviewname: " .. invviewname .. " ProjectionName: " .. ProjectionName .. string.char(10) end --if isDone == false then -- fix depth buffer if (Projection ~= nil) and (invview ~= nil) then isDone = true --x = " sgggggggggggggggffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff " for i = 1, #SText do AddNextStr = true if invview ~= nil then lastdefpos = string.find(SText[i], "def") if lastdefpos ~= nil then defpos = i + 1 end if (defpos == nil) and (string.find(SText[i], "dcl_") ~= nil) then defpos = i end if (lastdefpos == nil) and (defpos ~= nil) then if i == defpos then x = x .. " def c200, 0.0, 0.5, 0.0625, 0.5 " .. string.char(10) end lastdclpos = string.find(SText[i], "dcl_") if lastdclpos ~= nil then dclpos = i + 1 end if (lastdclpos == nil) and (dclpos ~= nil) then if i == dclpos then x = x .. " dcl_2d s0" .. string.char(10) end end end end rpos, rposEnd = string.find(SText[i], ProjectionName .. ".x",1, true) if (rpos ~= nil) and (string.find(SText[i], "rcp") ~= nil) and (string.find(SText[i - 1], "mul") ~= nil) then --mul r0.zw, r0, c17.x rpos = string.find(SText[i - 1], ",", 1, true) rposEnd = string.find(SText[i - 1], ",", rpos + 1, true) str = string.sub(SText[i - 1], rpos + 1, rposEnd - 1) str1 = string.sub(SText[i - 1], 1, rpos) str2 = string.sub(SText[i - 1], rposEnd, string.len(SText[i - 1])) AddNextStr = false SText[i - 1] = string.char(10) x = x .. SText[i - 2] .. string.char(10) x = x .. "mov r10," .. str .. string.char(10) x = x .. "texldl r14, c200.z, s0" .. string.char(10) x = x .. "add r14.y, r10.w, -r14.y" .. string.char(10) x = x .. "mul r14.x, r14.x, r14.y" .. string.char(10) --x = x .. "mul r14.x, r14.x, c200.w" .. string.char(10) x = x .. "add r10.x, r10.x, r14.x" .. string.char(10) x = x .. str1 .. "r10" .. str2 .. string.char(10) x = x .. SText[i] .. string.char(10) x = x .. string.char(10) end if AddNextStr then x = x .. SText[i] .. string.char(10) -- "//" .. SamplerName .. " CRatio: " .. CRatio .. " CeyePos: " .. CeyePos .. string.char(10) end end end --end if isDone then return x else return "" end;