twostraws / shaderkit Goto Github PK
View Code? Open in Web Editor NEWA library of fragment shaders you can use in any SpriteKit project.
License: MIT License
A library of fragment shaders you can use in any SpriteKit project.
License: MIT License
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
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?
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
^
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)?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.