Giter Club home page Giter Club logo

shadereditor's Introduction

Shader Editor

Create and edit GLSL shaders on your Android phone or tablet and use them as live wallpaper.

If you find this app useful and wish to support its continued development, you can buy me a coffee or send some Bitcoin decimals to bc1q2guk2rpll587aymrfadkdtpq32448x5khk5j8z.

Buy Me A Coffee

Screenshots

Screenshot Screenshot with soft keyboard

Download

Get it on F-Droid Get it on Google Play

Features

  • Live preview in background or on an extra screen
  • Syntax highlighting
  • Error highlighting
  • Use any shader as live wallpaper
  • Exposure of sensors (camera, accelerometer, gyroscope, magnetic field, light, pressure, proximity)
  • Exposure of battery level
  • Supports wallpaper offset
  • Supports multiple touches
  • Supports multiple render resolutions
  • Previous rendered frame in backbuffer texture
  • Import and use arbitrary textures
  • Create and use cube maps
  • Disables rendering when battery is low

See FAQ.md for frequently asked questions.

shadereditor's People

Contributors

antonpieper avatar cipold avatar eighthave avatar jfons avatar markusfisch avatar martysh12 avatar spider-pig34 avatar stuartpb avatar

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  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  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

shadereditor's Issues

Unresponsive editor

Any shader that increases in size gets really unresponsive, deleting/adding characters become really slow. Even scrolling will be laggy. I'm using it by turning off the compiling on editing but it isn't helping. Please increase responsiveness on the texteditor.

Edit: I think the ShaderEditor.hightlight() method is the bottleneck, it matches a lot of regular expressions. Maybe turning highlighting off on scrolling/selecting would decrease the time spent on highlighting.

Rendering issue

For some reason my phone renders only first frame, then on next frames shows only black screen. I'm not using this app for while now only because of this issue. (phone: motorola moto g 1st gen; android 5.0.2)

Suggestion โ€” New uniform: persistent runtime timer

USE CASE: Jane wrote a new shader that changes visibly with time, but in a slow and smooth manner based on one of the existing timer uniforms.
She then decided to set her shader as a home/lockscreen wallpaper.
The shader worked fine, but when she opened an app and later returned to the home screen, there was a discontinuity in the time uniform, between the time she left and then returned to the home screen.

This might've been easy to overlook, if not for one detail: the system cached an image of the last frame of the wallpaper as it left the home screen and displayed momentarily (a split second) before starting the shader again.

This caused the screen to visibly flicker from the cached image to a freshly rendered image, causing discomfort due to the jarring change.

Proposed way to fix it: a persistent timer uniform that stops when the shader isn't running.

Things to consider:

  • A system-dependent offset may need to be applied to a persisted value upon loading, to compensate system idiosyncrasies.
  • Precision issues if the uniform is to be a floating point number (in cases when it runs for too long).
  • Some people may want a version that oscillates between two numbers; others might prefer one that grows up to a maximum and then resets back to a starting value.
  • Different contexts should have different timers; hacking around in the shader code editor shouldn't change the state of the timer used for wallpapers.

Alternatively/additionally: persist the last frame of the last shader that ran as a wallpaper and provide it as an uniform so it can be used in a fading animation.

Time uniform accuracy.

Shouldn't time be an integer value? Float values have problems with accuracy after some time, specially 32 bit floats. I know that most times the effect is only visible for a few seconds and accuracy shouldn't be an issue, but this kind of wallpapers are used to show off, so it would be a good idea to make them work fine even if they are active more than a few seconds. Some effects i've tested (like this one: http://glslsandbox.com/e#26016.0) begin to show problems after 20 seconds or so... The problem is the accuracy, not the frame rate. The FPS meter shows the same FPS before and after the problems are noticeable.

Maybe it would be a better idea to add a "frame count" uniform.

I'm using a Motorola Moto G 2, Android 5.0.1

multipass ?

Hi Markus, do you plan to implement multipass rendering ? I don't know how difficult it would be to implement but it would allow a lot of new cool things like creating z-buffer for SSAO.

It has been implemented on shadertoy.com:

03/01/2016 - Release 0.8

  • Multipass rendering is here! Intermediate render targets are 16 bit (which means no hacky pack/unpack operations)
    Hello proper Depth of Field, SSAO, Motion Blur, HDR, gamma control, incremental monte carlo rendering, games...

Rendering to file

It would be a nice feature to render the shader output to a file (only an image, or even a video).
It is possible to capture the output with screenshot or screen recording but with low-fps shaders the video will be lagging.

Add support for the magnetic sensor

Would be nice to have the magnetic sensor of the phone exposed on the phone. Mostly because the sensor detects a lot of magnetic activity while I'm on the subway, and I'd like to use that to make more dynamic shaders.

I don't know if there is a specific area for feature request. So I'm posting here, sorry if it is on the wrong place.

Live wallpaper: framerate drops over time

This is a behavior I've noticed on my Nexus 6, even when the phone is plugged in: the framerate of the live wallpaper reduces every 15 seconds or so, by about half each time. The framerate of the UI itself is not affected.

Discard is not working properly

According to the the OpenGL ES 1.00 specification the discard keyword will not update the buffer if called. Thus it should contain the last written pixel value in the buffer until overwritten.
In the ShaderEditor discard will cause the (not) written pixel to be black. I think this is caused by the clear command at the start of rendering. It would be nice to make use of the discard keyword!

Duplicate file

app/src/main/java/de/markusfisch/android/shadereditor/widget/TouchThruDrawerLayout.java

and

app/src/main/java/de/markusfisch/android/shadereditor/widget/TouchThruDrawerlayout.java

seem to be duplicated and the program can't be compiled without removing the second one.

Editing when an error is highlighted

Since some versions now when an error occured and you try to edit, the cursor ('|' character) isn't appearing in the text, making it really difficult to resolve the error. It seems as if the red highlight color is over the editing rendering.

Make compatible with Shadertoy.com?

I tried pasting in a shader from shadertoy.com but it doesn't look like the names are the same. Is there an easy way to do this?

Otherwise I can add some kind of alias system for each variable, so it checks both mouse (ShaderEditor) and iMouse (ShaderToy) and binds to whichever one the script is using. Does that sound like a good idea?

Tab alternates component focus rather than indenting code.

I'm using a bluetooth keyboard, I doesn't have the exact model number but it's a 7-color backlight manufactured by jellycomb with 3 button layouts - 'iOS', 'Android' and 'Windows'.

Pressing tab on all 3 layouts alternates focus between components, instead of indenting code as expected. Shift+tab works the same way but iterates backwards.

missing mod() and floor() functions

Hi I hope this is not an out of place question, I don't know almost anything about shaders, but the opengl docs says there is a floor() and a mod() function, that doesn't seem to be available in the app, I suppose many others functions would be missing too.

Why is that? Is there a way to use those functions?

License?

Hi. Would you please specify the license this great and cool app is released in? I hope it would be a free one ๐Ÿ˜Š It is needed for adding this app to F-Droid, more info. Thank you

Slow shaders

Hello.

Thanks for this app. I'm having too much fun with it.

I notice that when I make a "heavy" shader with low fps, the UI slows down to a point of become unusable. Shouldn't the rendering side be separated of the UI side, option menu, spinner etc ? I mean, is there a way to play with low fps shaders and still have an usable UI ?

Thanks

Exposing shader scripts in the filesystem?

This app looks pretty neat, but the lack of an easy way to manipulate and externally edit the shaders it uses is something of a dealbreaker. (On top of not being able to import a file I've typed up on my PC, it's kind of hard to develop shaders when I'm not even able to name them.)

What I'd like to see is an option somewhere in the UI to set a directory to use for shader files. This would let me do any fancy file importing / exporting / naming / versioning etc. using any file browser (along with other stuff like a Git client and/or an external text editor), while still making the elements of the UI such as the dropdown as usable as they currently are.

Shader gets jagged with time

Shader starts running just fine, but it gets losing definition, to get really pixelated and ugly. I don't know if its a problem with how my graphics chip deals with the repetitions, or my shader code is problematic. My phone is a Xperia Z3 Compact. And attached are the images of how its looking, less than 30 sec between one image and another.

screenshot_2015-12-07-16-38-01
screenshot_2015-12-07-16-38-28

"Set as wallpaper" option in overflow menu

This is possibly my most-used feature in the app, and having to go into Preferences to change it is a total pain. I'd rather just open my shader, then choose "Set as Wallpaper" in the overflow menu. (If I can figure out how, I might submit a PR for this - I'm pretty allergic to native Android/Java development.)

Touch pressure or similar.

The coordinates of the touch screen are available, but there is no way to tell if the user is pressing or not. Maybe the coordinates can be set to impossible values (-1.0,-1.0 for example) to know that.

EDIT: Never mind, it's already here: #9

Tutorial

I think we need small tutorial to pick up basic things

Renaming Shaders

A great addition would be the ability to rename shaders.
It would make it far easier to organize them.

Problem with loops

I am trying to alternate colors so I used this loop
float j;
do {
if(j==.8){
//b for blue
b = uv.y+j;
j -= .1;
} else if ( j== .4){
b = uv.y+j;
j -= .1;
} j=.4;
} while (j!=1.0);

It freezes and crashes on compile. I wanted to use
ctime for a delay but is there a better way I
should be doing this, I an Very new too OpenGL

Unable to open the menu

I love this application but it has two major flaws and a minor flaw that make using it difficult.

First, after I updated my phone to Android Lolipop I lost the ability to open the menu. I can still switch between shaders, but holding down the selector no longer opens the menu. This is not a bug in your application, but severely limits the application's usefulness in my case. I would like to see a more intuitive and universal menu activation, such as a sliding drawer from the left.

Second, the inability to disable the live preview from the text editor causes issues when editing bright, noisy, or slow shaders. I would like an option to disable live preview, please.

Finally, the text editor makes editing long lines of code difficult as touching nearby shorter lines scrolls back to the left side. I'm not sure if improving this experience is within your ability, but I thought I'd mention it away.

I wrote about my inability to open the menu in an app review, but I realized you did not check there regularly. I created this account to thank you for making this awesome app and request a few changes. Thank you.

Minor identation annoyance

I noticed a minor annoyance with the indenting code. The easiest way to reproduce the issue, is to delete all the code in a new shader and then type in:

void main( void ) {
float r = 0.2;
}

When typing the above code, the code indentation becomes:

void main( void ) {
  float r = 0.2;
  }

Instead of:

void main( void ) {
  float r = 0.2;
}

I had a look with the debugger https://github.com/markusfisch/ShaderEditor/blob/master/ShaderEditor/src/main/java/de/markusfisch/android/shadereditor/widget/ShaderEditor.java but couldn't really understand what was going on.

Accuracy problem with gl_FragCoord.y

I have found a problem with the accuracy of gl_FragCoord.y.

Here is a shader to visually see the problem:

#ifdef GL_FRAGMENT_PRECISION
precision highp float;
#else
precision mediump float;
#endif

uniform float time;
uniform vec2 resolution;

void main( void )
{
  if(floor(gl_FragCoord.y) == mod(floor(time*2.0), resolution.y))
    gl_FragColor = vec4(1.0);
}

This shader is suppose to simply light up one row at a time based on the timer.
On my device (Moto G 2015), the line sometime disappear or even, sometime two rows are light up.
This problem doesn't occur with gl_FragCoord.x, which is working correctly.
I tested on another device (Alcatel One Touch Fierce 2) and the problem still persists.

I tested an equivalent of the previous shader on http://editor.thebookofshaders.com/ and everything seems fine:

#ifdef GL_ES
precision mediump float;
#endif

uniform float u_time;
uniform vec2 u_resolution;

void main( void )
{
  if(floor(gl_FragCoord.y) == mod(floor(u_time*2.0), u_resolution.y))
    gl_FragColor = vec4(1.0);
}

There is definitely something wrong with gl_FragCoord.y in ShaderEditor and I guess it should be solved ASAP since it affect all shaders.

Add daydream support

I usually charge my phone on a dock. And it has the possibility to activate a selected daydream when it's there...

Would be awesome to use a shader as a Daydream, just like we add to live wallpaper.

Docs / examples for all exposed inputs

It would be useful if there were either documentation of the names and values of the inputs to shaders in the README, or a shader/shaders that used them out-of-the-box (or, ideally, both).

I guess they're implemented somewhere around here?

This is an awesome app, BTW - basically an open-source Android alternative to Shaderific. Found it through F-Droid. I'm becoming obsessed with creating shader-based wallpapers for my new Nexus 6.

Preview keeps open

Since the latest update running the shader in a seperate window causes that preview window to remain open when pressing the 'back' button on my xperia z1 compact. This wasn't happening until now.

Load Syntax Highlighting Colours from XML

Wow, what a great app!

I am making an IDE and i have used your syntax highlighting code but modified it quite alot. Some changes i've made that you could incorporate into ShaderEditor:

  • Loading words to highlight and the colours to highlight them
    As you can see in this java file i have loaded an xml file.
    Now here's where the magic happens. No additional libraries needed. This also allows for custom themes.

  • Scrapping the runnable
    Im not sure if this is possible in your case, but i scrapped the runnable and update handler for a simple setHighlighted method in the onDraw method. Its super fast.


I hope you take my ideas into consideration! <3

"time" uniform loses accuracy

As some time goes by, the "time" uniform becomes increasingly inaccurate for me. This makes animations appear very jerky pretty quickly.

One way this could be resolved would be by providing an "animation length" in the settings, and then passing time as a fraction of that length. For example, if "animation length" was 5 seconds, then "time" might be 0.4 after 2 seconds, and then 0.4 again after 7 seconds.

Backbuffer inverted problem

Hi!

I know this project was updated about a year ago but I wanted to inform you about the issue with the backbuffer variable. The result texture in the shader gets flipped on the x-axis.

Rotation values

The explanation of the rotation values (vec3 rotation) is rather unhelpful. Also, I'm not sure if they work correctly on my device.

After some quick testing, it seems that:

  1. They are angles.
  2. If you want them to be in a sensible range, (e.g. 0 to 1) you have to use mod(). (Because those angles apparently range from -infinity to +infinity)
  3. y = tilting my device right and left
  4. z = turning around
  5. x is a weirdo. I have no clue what it represents. (It might seem like it should be: tilting my device forwards and backwards, but that doesn't seem to be the case?)

My code:
This code works perfectly fine with y and z.
mod(rotation.x / 6.2831, 1.0)

P.S. Awesome app! :)

Lowering framerate when in battery saver mode

It's kind of disconcerting that in Battery Saver, where all animations are disabled, Android does nothing to limit live wallpapers, so my Shader Editor live wallpaper keeps scrolling at a buttery-smooth 60fps.

It'd be better if, when in Battery Saver, Shader Editor lowered the framerate to at most 1 FPS.

still the backbuffer

Hi again!

I tried some little code out that uses the backbuffer and the result image started "swimming" away to the top right direction. So I tried to compensate the movement by adding values to the 2nd parameter of texture2D. It seems the value of +vec2(0.001) solved this.
I hope I'm using the function correctly, by writing:
texture2D(backbuffer,gl_FragCoord.xy/resolution.xy+vec2(0.001))

samplerCube

Hi, I tried to play with samplerCube and textureCube() but it seems to stop the rendering. Is it possible to use that type of samplers ? (I'd like to import shaders I made on Shadertoy)

Multitouch

It would be cool if touch were changed to be an array of (up to 10)? touches on-screen, for recognizing multi-touch. Each touch could be a vec2, with touches that aren't down set to (-1, -1).

(I had some crazier ideas about representing touch state, including the vec3 pattern Shadertoy uses for mouse input where z acts as an up/down boolean, but ultimately the best ideas I had were just awkward gestures at an incomplete persistence model.)

Chromecast compatibility?

Hi,

The README states "Live preview in background or on an extra screen", but I suppose the extra screen is a physically connected screen?

It would be quite cool if this app had support for cast on secondary screens, so it could adapt to the native resolution of the display and output better quality than the basic Android mirroring.

Is it something you have thought about? If not, I may give it a try to see whether this is worth doing.

Infinite loop protection

This app appears to have no protection against infinite loops. My device crashed when I accidentally typed:

for (int i; i < x; i = i) { // Was to become i = i + 1
  ...
}

It crashed because it ran the code before I was able to type + 1. Luckily it didn't autosave...

I'm using a OnePlus One with Android 6.0.1 and Cyanogen OS 13.1.2-ZNH2KAS3P0-bacon. App version is 2.4.1.

PS: I know i++ is a thing but I was just experimenting.

Crashing shader, uneditable

I foolishly had 'save on run' active on this shader which crashes the app whenever it is run, and now I can no longer even open it.

I can't even find the shader on the sdcard. Are they stored somewhere I can access without a rooted phone?

Option "set as wallpaper"

I very much like your work, a way to donate something would be great!

An option to set the shader one is currently editing or viewing as wallpaper would be great.

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.