Howdy, Stranger!

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

Shade to Codea

in Codea Craft Posts: 63

Hi,
How do you import shaders made in Shade into Codea? I saved some of the example shaders in the Codea folder. Although they are shown when picking a shader in Codea, it crashes once I run a Craft project with a shader applied to a model. In Shader Lab, the shaders are empty.
Thanks in advance

Comments

  • dave1707dave1707 Mod
    edited May 11 Posts: 7,553

    @Leon Here's an example that uses a Shade from Shader. Just copy the Shade from Shader into the Codea Dropbox folder. I used the Checker Shader in this example.

    function setup()
        -- uses a shader from Shade.
        assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")
        scene = craft.scene()
        skyMaterial=scene.sky.material
        skyMaterial.sky=color(0, 62, 255, 255)
        skyMaterial.horizon=color(99, 255, 0, 255)
        v=scene.camera:add(OrbitViewer, vec3(0,0,0), 100, 0, 200)
        v.rx,v.ry=20,20
        createRect1()
    end
    
    function draw()
        update(DeltaTime)
        scene:draw()    
    end
    
    function update(dt)
        scene:update(dt)
    end
    
    function createRect1() 
        local c1=scene:entity()
        c1.position=vec3(0,0,0)
        c1.model = craft.model.cube(vec3(10,10,10))
        c1.material = craft.material("Dropbox:Checkers")    
    end
    
  • Posts: 33

    Hey @dave1707 , Just checking out “Shade” for the first time... Very cool stuff! I was really happy to see your post here, as I have been trying to find a simple example of the “Shade” shaders in action within codea. All I’ve managed to do on my own with codea’s built in demo project “Shaders”, is crash codea a few times. Ok... a lot of times.

    However, when testing your code above, I get an error on line 7 ‘add’ (unknown component type)

    So unfortunately, I’m still a bit lost... even with your wonderfully simple example. Any advice on what I’m messing up would be awesome.

  • dave1707dave1707 Mod
    Posts: 7,553

    @Circuit You need to check Cameras as a dependency. If you're unsure how to do that, after you load my code, in the upper right of the screen is a plus sign. Tap on that and you'll see a list of programs. Scroll down until you find Cameras. Tap on that to check it. My code should run OK. Any code for Craft will probably need some of the programs checked.

  • Posts: 33

    Worked like a charm! Thanks for the speedy response my friend @dave1707

  • Posts: 1,202

    All - can anyone explain what the difference is in Shade when loading a Heightmap. I have been using grayscale textures for this but can not connect them to the heightmap node in Shade.

    Probably have to start from first principles and read each pixel value, correct for colour then build the colour texture for display with relevant heights in the vertex definitions.

    While I am posting one other thing - how do you group nodes in Shader? And is there a means of collapsing them into a super-node?

  • SimeonSimeon Admin Mod
    Posts: 4,927

    @Bri_G no group nodes (yet)

    When you say height map, do you mean the Offset input?

  • Posts: 1,202
    @Simeon - away from my iPad, I thought the top left input was UV which is an image - what I use for textures and heightmaps.

    On grouped nodes what are the grey areas with white rounded corners in some of the demo vids?
  • SimeonSimeon Admin Mod
    Posts: 4,927

    @Bri_G oh those are group nodes, they let you move a collection of nodes as a group. But they don't collapse into a single node, just let you visually segregate your graph.

  • Posts: 1,202
    @Simeon @John - noticed a funny with the group nodes in the rain demo. As expected selecting a group node by touching you can drag that node leaving the rest fixed. Seemed to work fine, but found with the large node at the left, when selected, the little node above it moved as well - but it left the internal nodes of the small group node fixed. Hadn't changed anything else in the shader.

    Are these group nodes a feature of an unreleased version?
  • Posts: 1,202

    Just found out how to generate groups. Touch screen until node query pops up then type in group —- dohhhhh. Think I need to go back to the abacus!!!

  • SimeonSimeon Admin Mod
    Posts: 4,927

    @Bri_G there's a lot of nodes so it can be tricky to know them all. You can also find it by scrolling through the library. Perhaps we should group them better

  • Posts: 1,202
    @Simeon - I was surprised at the extent of development that went into the latest version. Just think I need time and further playing to absorb everything and understand the scope of each node.
  • Posts: 63

    So sorry for not answering sooner. I was busy over the past couple of months. @dave1707 Thanks for the example. I will try it out as soon as I have the time.

Sign In or Register to comment.