-- 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 = "" isDone = false doSearch = true AddNextStr = true IsFirst = true GBufferDepth = nil RenderRatio=nil eyePositionWS=nil cameraFarMinusNear=nil -- search for constants names it helps to determinate shader for i = 1, #SText do if GBufferDepth == nil then GBufferDepth = string.find(SText[i], "g_GBufferDepth") else if (GBufferDepth ~= nil) and (string.find(SText[i], "g_GBufferDepth") ~= nil) then if SamplerName == "" then SamplerPos = string.find(SText[i], "s", GBufferDepth + 12) 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 SamplerName = string.sub(SText[i], SamplerPos, SamplerPos + len) end end end end if RenderRatio == nil then RenderRatio = string.find(SText[i], "g_RenderRatio") else if (RenderRatio ~= nil) and (string.find(SText[i], "g_RenderRatio") ~= nil) then --CRatio = SText[i] if CRatio == "" 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 CRatio = string.sub(SText[i], SamplerPos , SamplerPos + len) end end end end if eyePositionWS == nil then eyePositionWS = string.find(SText[i], "eyePositionWS") else if (eyePositionWS ~= nil) and (string.find(SText[i], "eyePositionWS") ~= nil) then --CeyePos = SText[i] if CeyePos == "" then SamplerPos = string.find(SText[i], "c", eyePositionWS + 12) 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 CeyePos = 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], "ps_3_0") ~= nil then break end x = x .. SText[i] .. "//" .. SamplerName .. " CRatio: " .. CRatio .. " CeyePos: " .. CeyePos .. string.char(10) end --if isDone == false then -- fix depth buffer if (GBufferDepth ~= nil) and (RenderRatio ~= nil) then isDone = true --x = " sgggggggggggggggffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff " for i = 1, #SText do AddNextStr = true if GBufferDepth ~= nil then lastdefpos = string.find(SText[i], "def") if lastdefpos ~= nil then defpos = i + 1 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_2") if lastdclpos == nil then lastdclpos = string.find(SText[i], "dcl_cube") end if lastdclpos ~= nil then dclpos = i + 1 end if (lastdclpos == nil) and (dclpos ~= nil) then if i == dclpos then x = x .. " dcl_2d s14" .. string.char(10) x = x .. " dcl vPos.xy" .. string.char(10) end end end end rpos, rposEnd = string.find(SText[i], CRatio.. ".x",1, true) if (rpos ~= nil) and (string.find(SText[i], "mul") ~= nil) then --mul r0.zw, r0, c17.x rpos = string.find(SText[i], "r") rposEnd = string.find(SText[i], ",", rpos, true) str = string.sub(SText[i], rpos, rposEnd - 1) AddNextStr = false x = x .. SText[i] .. string.char(10) x = x .. string.char(10) x = x .. " mov r11.xy, vPos.xy" .. string.char(10) x = x .. " rcp r11.z, c210.x" .. string.char(10) x = x .. " rcp r11.w, c210.y" .. string.char(10) x = x .. " mul r11.xy, r11.xy, r11.zw" .. string.char(10) x = x .. " mul r11.zw, r11.zw, c200.ww" .. string.char(10) --add r16.x, r16.x, r11.x if string.find(str, "xy") ~= nil then x = x .. " add ".. str ..", r11.xy, r11.zw" .. string.char(10) else x = x .. " add " .. str ..", r11.xyxy, r11.zwzw" .. string.char(10) end x = x .. string.char(10) end if (cameraFarMinusNear ~= nil) and (CeyePos ~= "") then rpos, rposEnd = string.find(SText[i], CeyePos) if (rpos ~= nil) and (string.find(SText[i], "mad") ~= nil) then rpos = string.find(SText[i], "r") rposEnd = string.find(SText[i], ",", rpos, true) str = string.sub(SText[i], rpos, rposEnd - 1) AddNextStr = false x = x .. SText[i] .. string.char(10) x = x .. string.char(10) x = x .. "mov r11.xyz, " .. str .. string.char(10) x = x .. "mul r10, c101, r11.y" .. string.char(10) x = x .. "mad r10, c100, r11.x, r10" .. string.char(10) x = x .. "mad r10, c102, r11.z, r10" .. string.char(10) x = x .. "add r10, r10, c103" .. string.char(10) x = x .. "texldl r14, c200.z, s14" .. 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 .. "rcp r10.w, r10.w" .. string.char(10) x = x .. "mul r10.xyz, r10.xyz, r10.w" .. string.char(10) x = x .. "mul r12, c105, r10.y" .. string.char(10) x = x .. "mad r12, c104, r10.x, r12" .. string.char(10) x = x .. "mad r12, c106, r10.z, r12" .. string.char(10) x = x .. "add r12, r12, c107" .. string.char(10) x = x .. "rcp r12.w, r12.w" .. string.char(10) x = x .. "mul r12.xyz, r12.xyz, r12.w" .. string.char(10) x = x .. "mov " .. str ..", r12.xyz" .. string.char(10) end end if AddNextStr then x = x .. SText[i] .. string.char(10) -- "//" .. SamplerName .. " CRatio: " .. CRatio .. " CeyePos: " .. CeyePos .. string.char(10) end end if isDone then x = x .. string.char(10) .. "//usepres" end end --end if isDone then return x else return "" end;