Code Monkey home page Code Monkey logo

shaderkit's Issues

SKShader to apply to a video in spritekit

Hi! I'm working on trying to display a video with alpha. Which is the best approach to achieve this in a shader? I'm creating a sprite kit scene and adding an effect node which has a shader. This is working but I think that the shader is not well defined.

return SKShader(source: """
                                void main() {
                                vec2 texCoords = v_tex_coord;
                                vec2 colorCoords = vec2(texCoords.x, texCoords.y);
                                vec2 alphaCoords = vec2(texCoords.x, texCoords.y);
                                vec4 color = texture2D(u_texture, colorCoords);
                                //float alpha = texture2D(u_texture, alphaCoords).r;
                                    
                                float squared_threshold = (0.01 * 0.01);
                                float squared_distance = dot(color.rgb, color.rgb);

                                if (squared_distance < squared_threshold)
                                {
                                    gl_FragColor = vec4(color.rgb, 0);
                                }
                                else
                                {
                                    gl_FragColor = vec4(color.rgb, 1);
                                }
                                }
                        """)

Any hints? Thanks in advance!

Color Alpha Descriptions

Color Alpha
Colors all clear pixels in the node.

Color Non-Alpha
Colors all clear pixels in the node.

Shouldn't the description of these two be opposite?

Issue While Using shader file

Jet: Error Domain=MTLLibraryErrorDomain Code=3 "Compilation failed:

program_source:33:1: error: unknown type name 'SHKWater'
SHKWater
^
program_source:33:9: error: expected unqualified-id
SHKWater
^
" UserInfo={NSLocalizedDescription=Compilation failed:

program_source:33:1: error: unknown type name 'SHKWater'
SHKWater
^
program_source:33:9: error: expected unqualified-id
SHKWater
^
}
2020-01-20 15:30:49.461672+0530 paperboat[7746:150969] SKShader failed to compile:
Compilation failed:

program_source:33:1: error: unknown type name 'SHKWater'
SHKWater
^
program_source:33:9: error: expected unqualified-id
SHKWater
^

Including this code in other projects

Thanks for these! I mean to use some of this code in my own open-source game engine.

Do I need to do anything besides including the full header and license in each relevant file?

Will I have to modify my own license (the default Apache-2.0)?

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.