Last active
November 26, 2016 16:39
-
-
Save edom18/275cbefd53a7d5d311fb to your computer and use it in GitHub Desktop.
[Metal] iOS Metalのちょっとしたメモ ref: http://qiita.com/edo_m18/items/5e03f7fa317b922b5a42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float4x4 mat = float4x4(float4( 1, 2, 3, 4), | |
float4( 5, 6, 7, 8), | |
float4( 9, 10, 11, 12), | |
float4(13, 14, 15, 16)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static const float mat[4][4] = { | |
{ 1, 2, 3, 4}, | |
{ 5, 6, 7, 8}, | |
{ 9, 10, 11, 12}, | |
{13, 14, 15, 16}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fragment half4 frag(VertexOut input [[stage_in]]) { | |
half4 color = half4(input.color); | |
// なにがしかの条件を判定する | |
if (anyCondition) { | |
discard_fragment(); | |
} | |
return color; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct VertexOut { | |
float4 position [[position]]; | |
}; | |
struct Uniforms { | |
float2 resolution; | |
}; | |
fragment half4 frag(VertexOut input [[stage_in]], | |
constant Uniforms &uniforms [[buffer(0)]]) { | |
float2 position = (input.position.xy * 2.0 - uniforms.resolution) / min(uniforms.resolution.x, uniforms.resolution.y); | |
// ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fragment half4 frag(VertexOut input [[stage_in]], constant Uniforms &uniforms [[buufer(0)]]) { | |
float2 resolution = float2(uniforms.resolution[0], uniforms.resolution[1]); | |
float2 position = (input.position.xy * 2.0 - resolution) / min(resolution.x, resolution.y); | |
return half4(position.x, position.y, 0.0, 1.0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef GL_ES | |
precision mediump float; | |
#endif | |
uniform float time; | |
uniform vec2 mouse; | |
uniform vec2 resolution; | |
void main( void ) { | |
vec2 position = ( gl_FragCoord.xy * 2.0 - resolution ) / min(resolution.x, resolution.y); | |
gl_FragColor = vec4(position, 0.0, 1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment