Giter Site home page Giter Site logo

tsteinholz / loveshaderconverter Goto Github PK

View Code? Open in Web Editor NEW
73.0 6.0 10.0 3.43 MB

Shadertoy :arrow_right: LÖVE GLSL || Converter

Home Page: https://www.shadertoy.com/

License: MIT License

CMake 2.96% C++ 88.32% C 3.69% Batchfile 2.50% Shell 2.53%
shadertoy shaders glsl love2d lua demo

loveshaderconverter's Introduction

🔰 Löve 2D Shader Cönverter

This is a pretty straight forrward program that simpily converts the GLSL used in the Shader Toy which is based on ES; to a version of GLSL that can be used by LÖVE , which is based on GLSL 1.2 with custom calls for lua.

Releases

So far we only have builds for Windows (x32 & x64) and Linux, but none for Mac. So if you're on a mac and you want to use this application you will have to compile it yourself unfortunatly. If you are on a Windows or Linux system, you can check out our releases for the latest binaries.

Legal

This Program is under the M.I.T License, but all the shaders you convert with this program are entitled to their own licenses with their own terms. Please do your best to not infringe upon any of their terms because you will be held accountable for it.

Commands and Arguments Usage

To call the program you have to be using a command line (bat or shell script works)

LoveShaderConverter <FileName>

This creates <FileName>.bak which contains the original code you copied from Shader Toy and changes to contents of <FileName> to have the GLSL that can be easily used by LÖVE .

On Windows, run the file LoveShaderConverter.bat, this will give you a working interface to the program.

Quick Guide

Here is a quick guid / demo using the software and how to implent it in love.

Step 1 : Go Shopping 👜

Go to Shader Toys and pick out a shader you would like to implement. For this demo, I chose This Shader.

alt text

Step 2 : Copy the Source 📋

Of coure keep in mind licenses and do-not steal code. Only when a license permits you to, copy-and-paste the entirety of the code.

alt text

Step 3 : Paste ✏️

Simply paste your clipboard to a file and save it as something.

alt text

Step 4: Convert 🔩

Here's the fun part. Make sure you have a download of this project somewhere you can use it, in the command line, in a shell script, in a bat file, somewhere put down this command.

LoveShaderConverter <FileName>

Of course replace with the atcual file name in the correct directory etc. If you mess something up, the application will notify you.

alt text

Step 5 : Integrate with Love 2D 💡

This is where the tutorial stops for you if you plan to implement anything diffrently, for this demo I am making a window for the sole purpose of rendering this shader and nothing else. So on that note, you need to set up a new Love2D project, make a conf.lua and main.lua and give the files the according methods.

alt text

Lets start with our local variables. We are loading a shader so lets add

local shader

We are going to render the shader to a canvas

local canvas

The output from the conversion told us we need the time

local time = 0

Now lets implement the load function!

function love.load(arg)
    -- Load the shader from the file we generated
    shader = love.graphics.newShader('MetaHexaBalls.glsl')
    -- Create a new Canvas to draw to
    canvas = love.graphics.newCanvas(800, 600)
end

Next the Update Function

function love.update(dt)
    -- increment our pseudo time variable
    time = dt + time;
    -- When converting, the following variables were requested from the shader...
    shader:send('iResolution', { love.window.getWidth(), love.window.getHeight(), 1 })
    shader:send('iGlobalTime', time)
    shader:send('iMouse', { love.mouse.getX(), love.mouse.getY(), 0, 0 })
end

Last and definatly not least, the draw function

function love.draw()
    love.graphics.setCanvas(canvas)
    love.graphics.setShader(shader)
    love.graphics.draw(canvas)
    love.graphics.setShader()
    love.graphics.setCanvas()

    love.graphics.draw(canvas,0,0,0,1,1,0,0)
end

Full main.lua file can be found here.

Step 6 : Hit that run button 🎱

The moment you have been waiting for, a beautiful shader rendered by love2d. Have fun ;)

alt text

TODO :

  • Multi-channel support
  • Remove boost?
  • Official Builds on Mac
  • Add license terms and a modified change list in the header
  • Flags? For example...
  • Generate Love Project that renders shader with [-g:--generate] flag?

loveshaderconverter's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

loveshaderconverter's Issues

Please update your documentation to new versions of Löve

Hello!

I am opening this issue because I think my struggle with my first use of the plugin could help you update the doc and make new users use your very nice converter a lot more easily!

Your demo example (and the associated documentation) are made for Löve 0.9.2, and the new version of Löve is 11.4!
Therefore, several things need to be changed accordingly:

  • change the version number in "conf.lua" to avoid warnings every run;
  • still in the "conf.lua", t.window.fullscreen() cannot be normal, but needs to be set as desktop or exclusive instead;
  • in the main.lua, love.graphics.getWidth must be changed as love.graphics.getWidth();
  • still in this file, love.graphics.setCanvas(canvas) must be set after love.graphics.draw(canvas) (else you'll get an error like "the canvot cannot refer to itself");
  • if you use an up-to-date ShaderToy, the function texture() in your shader must be changed to Texel() with a caps T. Else, you cannot load and modify images in shaders.

Please consider these to update your documentation, I think it helps lots of other people!

Seeya!

Getting error

Im following the tutorial,error in the terminal :

./LoveShaderConverter: No such file or directory

Im using linux, xubuntu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.