Fish fillets remake https://glitchapp.codeberg.page/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
fish-fillets-remake/shaders.lua

498 lines
19 KiB

--shadertoy code implement
--modify shaderFileName to the code file you copied.
--if the shader has any channel file, for example channel0 then shaderChannel[1]=love.graphics.newImage(path to the file)
local resolution={8,6,1} --low resolution for better performance
local files = love.filesystem.getDirectoryItems("shaders")
local currentShader = 0
local shaderFileName="shaders/"..files[currentShader+1]
local shaderChannel={
--[0]=love.graphics.newImage("channel/tex10.png"),
--[1]=love.graphics.newImage("channel/tex14.png"),
--[3]=love.graphics.newImage("channel/tex15.png"),
}
local function loadShader(path)
local iSystem={}
local header="\n"
local ender=[[
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords){
vec2 fragCoord = texture_coords * iResolution.xy;
mainImage( color, fragCoord );
return color;
}]]
local file = love.filesystem.newFile(path)
file:open("r")
local shaderData = file:read()
shaderData = string.gsub(shaderData,"texture2D","Texel")
shaderData = string.gsub(shaderData,"iTime","iGlobalTime")
shaderData = string.gsub(shaderData,"precision highp float;","")
if string.find(shaderData,"iGlobalTime") then
iSystem.iGlobalTime=0
if not string.find(shaderData,"number iGlobalTime") then
header="\nextern number iGlobalTime;"..header
end
end
if string.find(shaderData,"iChannel") then
iSystem.iChannel={}
if not string.find(shaderData,"Image iChannel") then
for k,v in pairs(shaderChannel) do
header="\nextern Image iChannel"..k..";"..header
end
end
end
if string.find(shaderData,"iMouse") then
iSystem.iMouse = {0,0,-1,-1}
if not string.find(shaderData,"vec4 iMouse") then
header="\nextern vec4 iMouse;"..header
end
end
if string.find(shaderData,"iResolution") then
iSystem.iResolution = {resolution[1],resolution[2],1}
if not string.find(shaderData,"vec3 iResolution") then
header="\nextern vec3 iResolution;"..header
end
end
shaderData=header..shaderData
if not string.find(shaderData,"vec4 effect") then
shaderData=shaderData.."\n"..ender
end
return shaderData,iSystem
end
local shaderData
local iSystem
local shader
local canvas
function nextShader(i)
currentShader = (currentShader+i)%#files
shaderFileName="shader/"..files[currentShader+1]
setShader(i)
end
function setShader(i)
i = i or 1
shaderData,iSystem = loadShader(shaderFileName)
--shaderData,iSystem = loadShader("shader/balls.glsl")
local OK
OK, shader = pcall(love.graphics.newShader,shaderData)
if not OK then
--[[--
print("-------SHADER---------")
print(shaderFileName)
print("--------ERROR---------")
print(shader)
print("------------------------------------")
--]]--
nextShader(i)
setShader(i)
end
canvas = love.graphics.newCanvas(resolution[1],resolution[2])
if iSystem.iResolution then
shader:send("iResolution",iSystem.iResolution)
end
if iSystem.iChannel then
for k,v in pairs(shaderChannel) do
shader:send("iChannel"..k,v)
end
end
end
setShader(1)
function selectshadertoy(select)
i = i or 1
--shaderData,iSystem = loadShader(shaderFileName)
shaderData,iSystem = loadShader(select)
local OK
OK, shader = pcall(love.graphics.newShader,shaderData)
if not OK then
--[[--
print("-------SHADER---------")
print(shaderFileName)
print("--------ERROR---------")
print(shader)
print("------------------------------------")
--]]--
nextShader(i)
setShader(i)
end
canvas = love.graphics.newCanvas(resolution[1],resolution[2])
if iSystem.iResolution then
shader:send("iResolution",iSystem.iResolution)
end
if iSystem.iChannel then
for k,v in pairs(shaderChannel) do
shader:send("iChannel"..k,v)
end
end
end
--function love.keypressed(key)
-- if key == "right" then
--nextShader(1)
--elseif key == "left" then
-- nextShader(-1)
-- end
--if key == 's' then
-- selectshadertoy("shader/balls.glsl")
--end
--end
function love.resize(w,h)
if iSystem.iResolution then
resolution={love.graphics.getWidth(),love.graphics.getHeight(),1}
iSystem.iResolution = {resolution[1],resolution[2],1}
shader:send("iResolution",iSystem.iResolution)
canvas = love.graphics.newCanvas(resolution[1],resolution[2])
end
end
function love.update(dt)
--if not (gamestatus=="music") then lovebpmupdate(dt) end
if gamestatus=="levelselection" then myshadowsupdate()
timer2 = timer2 + dt
if isloading==true then loadingupdate(dt) fadeloadingprocess(dt) end -- rotate loading icon if loading
if loadingprocess==true then
changelevel()
gamestatus="game"
timer=0
stepdone=0
loadingprocess=false
--love.audio.play( sharpechosound )
end
elseif gamestatus=="credits" then creditsupdate(dt)
elseif gamestatus=="music" then --musicupdate(dt) --update music
if timer>10 then lovebpmupdate(dt) end
elseif gamestatus=="extras" then extrasupdate(dt) --update extras
if advertising1playing==true then
timer = timer + dt
Talkies.update(dt)
subtitle21advertising1()
elseif advertising2playing==true then
timer = timer + dt
Talkies.update(dt)
subtitle21advertising2()
end
--elseif gamestatus=="leditor" then leditorupdate(dt) --update extras
elseif gamestatus=="instructions" then instructionsupdate(dt)
elseif gamestatus=="intro" then introupdate(dt)
elseif gamestatus=="briefcasemessage" then
briefcaseupdate(dt)
Talkies.update(dt)
if screenshake==true then
if timer2>0.5 then screenshake=false end
end
timer = timer + dt -- timer update
timer2=timer2 +dt
subtitle2FDTOmessage()
--elseif gamestatus=="endmenu" then
elseif gamestatus=="fishhouseend" then
timer = timer + dt -- timer update
fishhouseendupdate(dt)
subtitl8end()
elseif gamestatus=="shipwrecksend" then
timer = timer + dt -- timer update
shipwrecksendupdate(dt)
subtitle19end()
elseif gamestatus=="silversshipend" then
timer = timer + dt -- timer update
silversshipendupdate(dt)
subtitle51end()
elseif gamestatus=="cityinthedeepend" then
timer = timer + dt -- timer update
cityinthedeependupdate(dt)
subtitle29end()
elseif gamestatus=="ufoend" then
timer = timer + dt -- timer update
ufoendupdate(dt)
subtitle58end()
lovebpmupdate(dt)
elseif gamestatus=="barrelend" then
timer = timer + dt -- timer update
barrelendupdate(dt)
subtitle44end()
elseif gamestatus=="coralreefend" then
timer = timer + dt -- timer update
coralreefendupdate(dt)
subtitle37end()
elseif gamestatus=="treasurecaveend" then
timer = timer + dt -- timer update
treasurecaveendupdate(dt)
subtitle64end()
elseif gamestatus=="secretcomputerend" then
timer = timer + dt -- timer update
secretcomputerendupdate(dt)
subtitle70end()
elseif gamestatus=="linuxend" then
timer = timer + dt -- timer update
linuxendupdate(dt)
subtitle77end()
elseif gamestatus=="gameend" then
timer = timer + dt -- timer update
gameendupdate(dt)
subtitle79end()
elseif gamestatus=="gameover" then
timer=timer +dt
timer2=timer2 +dt
if screenshake==true then
if timer2>0.5 then screenshake=false end
end
if fish1status=="dead" and aleatorygameoversentence==2 then subtitlegameoverdarn()
elseif fish1status=="dead" and aleatorygameoversentence==14 then subtitlesgameoverparrot()
elseif fish2status=="dead" and aleatorygameoversentence==12 then subtitlegameoverhereafter()
end
elseif gamestatus=="levelcompleted" then timer = timer + dt
elseif gamestatus=="game" then
if tetris==true then
blocksupdate(dt) -- update tetris
animatewhale()
end
if screensaver==true then timer = timer +dt end
--if screenshakes time moves
if screenshake==false and talkies==true then timer = timer + dt
elseif screenshake==true then
if timer2>0.5 then screenshake=false
end
end
if isloading==true then loadingupdate(dt) fadeloadingprocess(dt) end -- rotate loading icon if loading
if loadingprocess==true then triggerloadingprocess(dt) end
lovebpmupdate(dt) Talkies.update(dt) -- timer for the water warp shader
timer2=timer2 +dt
smallfishupdate(dt) -- update frames for the small fish animation
bigfishupdate(dt) -- update frames for the big fish animation
--bore scripts
inputtime=inputtime +dt
if inputtime>180 and boresentencestriggered==false and boresentencesinterrupted==false then boresentencestriggered=true
-- trigger subtitles
timer=0
stepdone=0
if talkies==true then Talkies.clearMessages() Obey.borescript() end
end
if boresentencestriggered==true and boresentencesinterrupted==false then subtitlesborescript() end -- subtitlesborescript
if nLevel==1 or nLevel==34 or nLevel==36 then whaleupdate(dt) end
if nLevel==3 or nLevel==16 or nLevel==32 or nLevel==35 or nLevel==101 then ffish1update(dt) fishsupdate(dt) end
if nLevel==4 then strangecreatureupdate(dt) end
if nLevel==5 then snailupdate(dt) crabupdate(dt) end
if nLevel==6 then broomupdate(dt) end
if nLevel==7 then crabupdate(dt) snailupdate(dt) dolphinupdate(dt) end
if nLevel==9 then periscopeupdate(dt) end
if nLevel==10 or nLevel==18 then boatwindowupdate(dt) boatglassupdate(dt) glastimer=glastimer+dt end
if nLevel==11 then snailupdate(dt) end
if nLevel==12 then medusaupdate(dt) rybickaupdate(dt) end
if nLevel==14 then eyeupdate(dt) end
if nLevel==15 then sharkupdate(dt) end
if nLevel==16 then snailupdate(dt) end
if nLevel==11 then deadparrotupdate(dt) elkupdate(dt) end
if nLevel==13 then vikingupdate(dt) snailupdate(dt) end
if nLevel==15 then dalekohledupdate(dt) budikupdate(dt) snailupdate(dt) mikroskopupdate(dt) end
if nLevel==17 then vikingupdate(dt) end
if nLevel==19 then neptunupdate(dt) poseidonupdate(dt) end
if nLevel==20 or nLevel==28 then crossupdate(dt) faceupdate(dt) end --animate face and cross level 20
if nLevel==21 then statueupdate(dt) end --animate talking sculpture level 21
if nLevel==22 then faceupdate(dt) end --animate face sculpture level 22
if nLevel==7 or nLevel==14 or nLevel==19 or nLevel==20 or nLevel==21 or nLevel==28 or nLevel==29 or nLevel==30 or nLevel==31 or nLevel==34 or nLevel==36 or nLevel==102 then fishsupdate(dt) end
if nLevel==29 then crabupdatelong(dt) snailupdate(dt) faceupdate(dt) end
if nLevel==32 then sasankaupdate(dt) seahorseupdate(dt) end
if nLevel==33 then crabupdate(dt) seahorseupdate(dt) end
if nLevel==34 then sasankaupdate(dt) crabupdatemiddle(dt) sepieupdate(dt) snaillongupdate(dt) balalupdate(dt) end
if nLevel==35 then mantarayupdate(dt) sasankaupdate(dt) sepieupdate(dt) crabupdatemiddle(dt) klavirupdate(dt) rejnokupdate(dt) end
if nLevel==37 then zupdate(dt) end
if nLevel==40 then washmachineupdate(dt) end
if nLevel==43 then medusaupdate(dt) mnohonozkaupdate(dt) budikupdate(dt) medusaupdate(dt) meduzaupdate(dt) strangecreatureupdate(dt) uhorupdate(dt) balonekupdate(dt) end
if nLevel==44 then pinkmonsterupdate(dt) barelupdate(dt) bagetupdate(dt) doubleupdate(dt) hadupdate(dt) hlubinnaupdate(dt) kachnaupdate(dt) mutantkrabupdate(dt) kukajdaupdate(dt) killerupdate(dt) mutantsharkupdate(dt) nohaupdate(dt) mutanteyeupdate(dt) end
if nLevel==45 or nLevel==49 then chobotniceupdate(dt) papouchaupdate(dt) end
if nLevel==46 then snehulakupdate(dt) end
if nLevel==47 then deloupdate(dt) end
if nLevel==50 then krystalcupdate(dt) drahokamupdate(dt) lebzaupdate(dt) okoupdate(dt) end
if nLevel==57 then thinjarupdate(dt) porganismupdate(dt) qorganismupdate(dt) okaupdate(dt) malaupdate(dt) mutantupdate(dt) sklenaupdate(dt) horni_tvorupdate(dt) lahvacupdate(dt) lahvaccrashupdate(dt) lahvaccrashedupdate(dt) end
if nLevel==58 then pohonupdate(dt) ufoupdate(dt) hadiceupdate(dt) plutonium4update(dt) podstavecupdate(dt) end
if nLevel==59 then totemupdate(dt) seahorseupdate(dt) end
if nLevel==60 then krystalupdate(dt) end
if nLevel==62 or nLevel==61 then korunaupdate(dt) krystalupdate(dt) end
if nLevel==66 and timer2>2 then timer2=0 end -- second timer to animate objects
if nLevel==77 then linuxakupdate(dt) end
if nLevel==103 or nLevel==103 then love.graphics.setColor(1,1,1,0.85) love.graphics.setColor(1,1,1,0.85) whaleupdate(dt) fishsupdate(dt) end
if boresentencestriggered==false and boresentencesinterrupted==false then
--update subtitles
if talkies==true then
if nLevel==1 then -- sync subtitles for level 1
if chairtouched==false then
if pipetouched==false and pipepushed==false and pipefalled==true then subtitles1()
elseif pipetouched==true and pipepushed==false then subtitles1Icantgetthrough()
elseif pipepushed==true and wowsaidonce==false then subtitles1wowyoumovedit()
end
elseif chairtouched==true then subtitles1damnit()
end
elseif nLevel==2 and briefcaseclosed==true then subtitlessync2() -- sync subtitles for level 2
elseif nLevel==2 and briefcaseclosed==false then subtitle2thedisk() -- sync subtitles for level 2 after briefcase
elseif nLevel==3 and uarestanding==false and booklvl3pushed==false and shortpipepushed==false then subtitle3()
elseif nLevel==3 and uarestanding==true and booklvl3pushed==false then subtitle3youarestanding()
elseif nLevel==3 and booklvl3pushed==true then subtitle3wewillgiveyouahint()
elseif nLevel==3 and savingpositions==true then subtitle3savingpositions()
elseif nLevel==3 and aproachaxe==true then subtitle3aproachaxe()
elseif nLevel==4 then subtitle4()
elseif nLevel==5 then subtitle5()
elseif nLevel==6 then subtitle6()
elseif nLevel==7 and matresspushed==false then subtitle7()
elseif nLevel==7 and matresspushed==true then subtitle7part2()
elseif nLevel==8 then subtitle8()
elseif nLevel==9 then subtitle9()
elseif nLevel==10 then subtitle10()
elseif nLevel==11 then subtitle11()
elseif nLevel==12 then subtitle12()
elseif nLevel==13 then subtitle13()
elseif nLevel==14 then subtitle14()
elseif nLevel==13 and skullpushed==true then subtitle13skull()
elseif nLevel==15 then subtitle15()
elseif nLevel==16 then subtitle16()
elseif nLevel==17 then subtitle17()
elseif nLevel==18 then subtitle18()
elseif nLevel==19 then subtitle19()
elseif nLevel==20 and skullpushed==false then subtitle20()
elseif nLevel==20 and skullpushed==true then subtitle20skull()
elseif nLevel==21 then subtitle21()
elseif nLevel==22 then subtitle22()
elseif nLevel==23 and zeusfalled==false then subtitle23()
elseif nLevel==23 and zeusfalled==true then subtitle23zeus()
elseif nLevel==24 then subtitle24()
elseif nLevel==25 then subtitle25()
elseif nLevel==26 then subtitle26() lovebpmupdate(dt)
elseif nLevel==27 and dooropened==false then subtitle27()
elseif nLevel==27 and dooropened==true then subtitle27door()
elseif nLevel==28 and skullpushed==false then subtitle28()
elseif nLevel==28 and skullpushed==true then subtitle28skull()
elseif nLevel==29 then subtitle29()
elseif nLevel==30 and crabtouched==true and not (crabfalled) then subtitle30crab()
elseif nLevel==30 and crabfalled==true then subtitle30crabups()
elseif nLevel==30 then subtitle30()
elseif nLevel==31 then subtitle31()
elseif nLevel==32 then subtitle32()
elseif nLevel==33 then subtitle33()
elseif nLevel==34 then subtitle34()
elseif nLevel==35 then subtitle35()
elseif nLevel==36 then subtitle36()
elseif nLevel==37 then subtitle37()
elseif nLevel==38 then subtitle38()
elseif nLevel==39 then subtitle39()
elseif nLevel==40 then subtitle40()
elseif nLevel==41 then subtitle41()
elseif nLevel==42 then subtitle42()
elseif nLevel==43 then subtitle43()
elseif nLevel==44 then subtitle44()
elseif nLevel==45 then subtitle45()
elseif nLevel==45 and skullpushed==false then subtitle45()
elseif nLevel==45 and skullpushed==true then subtitle45skull()
elseif nLevel==46 then subtitle46()
elseif nLevel==47 then subtitle47()
elseif nLevel==48 then subtitle48()
elseif nLevel==49 then subtitle49()
elseif nLevel==50 then subtitle50()
elseif nLevel==51 then subtitle51()
elseif nLevel==52 then subtitle52() pinkmonsterupdate(dt) -- animate pink monster
elseif nLevel==53 then subtitle53()
elseif nLevel==54 and enginepushed==false and engineononce==false and aproachengineonce==false then subtitle54()
elseif nLevel==54 and enginepushed==true then subtitle54engineon() alienenginekeyupdate(dt) -- animate key
elseif nLevel==54 and enginepushed==false and engineononce==true then subtitle54engineoff()
elseif nLevel==54 and enginepushed==false and aproachengineonce==true then subtitle54aproachengine()
elseif nLevel==55 then subtitle55()
elseif nLevel==56 and lightswitchon==true and lightswitchpushedafterfalling==true and aproachrobodog==false then subtitle56lightswitchon()
elseif nLevel==56 and lightswitchon==false then subtitle56lightswitchoff()
elseif nLevel==56 and aproachrobodog==true and lightswitchon==true then subtitle56aproachrobodog()
elseif nLevel==57 then subtitle57()
elseif nLevel==58 then subtitle58()
elseif nLevel==59 and skullbottom_pushed==true then subtitle59skull()
elseif nLevel==59 and skullupleft_pushed==true then subtitle59skull2()
elseif nLevel==59 and skullupright_pushed==true then subtitle59skull3()
elseif nLevel==59 and skullmidright_pushed==true then subtitle59skull4()
elseif nLevel==59 and skullbottom_pushed==false and skullupleft_pushed==false and skullupright_pushed==false and skullmidright_pushed==false then subtitle59()
elseif nLevel==60 then subtitle60()
elseif nLevel==61 then subtitle61()
elseif nLevel==62 then subtitle62()
elseif nLevel==63 then subtitle63()
elseif nLevel==64 then subtitle64()
elseif nLevel==65 then subtitle65()
elseif nLevel==66 then subtitle66()
elseif nLevel==67 then subtitle67()
elseif nLevel==68 then subtitle68()
elseif nLevel==69 then subtitle69()
elseif nLevel==70 then subtitle70()
elseif nLevel==71 then subtitle71()
elseif nLevel==72 then subtitle72()
elseif nLevel==73 then subtitle73()
elseif nLevel==74 then subtitle74()
elseif nLevel==75 then subtitle75()
elseif nLevel==76 then subtitle76()
elseif nLevel==77 then subtitle77()
--elseif nLevel==78 then subtitle78()
elseif nLevel==79 then subtitle79()
end
end
end
end
if shader2==true then
if iSystem.iGlobalTime then
if screenshake==false then
iSystem.iGlobalTime=iSystem.iGlobalTime+dt
elseif screenshake==true then --slow down shader when impact
iSystem.iGlobalTime=iSystem.iGlobalTime+0.0002
end
shader:send("iGlobalTime", iSystem.iGlobalTime)
end
if iSystem.iMouse then
iSystem.iMouse[1],iSystem.iMouse[2] = love.mouse.getPosition()
iSystem.iMouse[1],iSystem.iMouse[2] = resolution[1]-iSystem.iMouse[1],resolution[2]-iSystem.iMouse[2]
if love.mouse.isDown(1) then
if iSystem.iMouse[3]<0 then
iSystem.iMouse[3],iSystem.iMouse[4] = love.mouse.getPosition()
end
shader:send("iMouse", iSystem.iMouse)
else
iSystem.iMouse[3],iSystem.iMouse[4] = -1, -1
end
end
--love.window.setTitle(shaderFileName.."; FPS: "..love.timer.getFPS())
--love.window.setTitle("Fish Fillets remake")
love.graphics.setShader(shader)
love.graphics.draw(canvas)
end
end
--function love.draw()
--love.graphics.draw(canvas,0,0,math.pi,1,1,resolution[1],resolution[2])
--end