Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Codea as shader editor

in Shaders Posts: 2

I'd like to know is it possible to use codea as shader editor?

Tagged:

Comments

  • dave1707dave1707 Mod
    Posts: 6,392

    What do you mean by a shader editor. You can create/edit/change/run a shader, but if you’re not familiar with the language or syntax then you might have trouble getting it to run. Codea isn’t like some of the other programs where you don’t need to know anything. Where you just change some parameters and a shader runs. With Codea, you need to write every line of code from scratch or from another shader example. There isn’t an easy way, but once you learn Codea and the shader language it gets easier. Once you know what you’re doing, you can probably write any shader to do anything you want. There’s some shader examples with Codea and there’s more examples in the forum. If you have more questions, just ask. Welcome to the forum.

  • Posts: 2

    Dave, Thanks for your answer, yeah I'm looking for a something similar to this (https://www.shadertoy.com/new). according to your answer. looks like codea will be suitable for my need. because currntly I'm learning shaders. and i want to write it line by line but thre is no cool shader editors for ios.

  • dave1707dave1707 Mod
    Posts: 6,392

    @noName Here’s a simple shader that’s similar to what shows in the link above. This one doesn’t vary the color over time, but that could be easily added.

    displayMode(FULLSCREEN)
    
    function setup()
        m=mesh()
        m:addRect(WIDTH/2,HEIGHT/2,WIDTH,HEIGHT)
        m.shader=shader(Shader.vert,Shader.frag)
    end
    
    function draw() 
        background(0) 
        m:draw()
    end
    
    Shader = 
        {   vert=
            [[
            uniform mat4 modelViewProjection;
            varying highp vec2 vTexCoord;
            attribute vec2 texCoord;
            attribute vec4 position; 
            void main() 
            {   gl_Position = modelViewProjection * position;
                vTexCoord=texCoord;
            }  
            ]],
    
            frag=
            [[
            highp float r=0.;
            highp float g=0.;
            highp float b=0.;
            varying highp vec2 vTexCoord;
            void main() 
            {   r=vTexCoord.x;
                g=(vTexCoord.x*vTexCoord.y);
                b=vTexCoord.y;
                gl_FragColor = vec4(r,g,b,1.); 
            }    
            ]]  
        }
    
  • dave1707dave1707 Mod
    Posts: 6,392

    Here’s a shader with varying color.


    displayMode(FULLSCREEN) function setup() m=mesh() m:addRect(WIDTH/2,HEIGHT/2,WIDTH,HEIGHT) m.shader=shader(Shader.vert,Shader.frag) end function draw() background(0) m.shader.tm=os.clock() m:draw() end Shader = { vert = [[ uniform mat4 modelViewProjection; varying highp vec2 vTexCoord; attribute vec2 texCoord; attribute vec4 position; void main() { gl_Position = modelViewProjection * position; vTexCoord=texCoord; } ]], frag = [[ uniform highp float tm; varying highp vec2 vTexCoord; void main() { highp float x=vTexCoord.x; highp float y=vTexCoord.y; gl_FragColor = vec4(sin(tm)-cos(tm),x*y+cos(tm),x*y+sin(tm),1.); } ]] }
Sign In or Register to comment.