mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 21:45:19 +00:00
Shader
This commit is contained in:
parent
609df3331f
commit
5ad827599b
@ -17,8 +17,19 @@ vertex Varyings wallpaperVertex(constant Vertex *verticies[[buffer(0)]], unsigne
|
||||
return out;
|
||||
}
|
||||
|
||||
fragment half4 wallpaperFragment(Varyings in[[stage_in]]) {
|
||||
fragment half4 wallpaperFragment1(Varyings in[[stage_in]]) {
|
||||
float4 out = float4(0.0, 1.0, 0.0, 1.0);
|
||||
|
||||
return half4(out);
|
||||
}
|
||||
|
||||
fragment half4 wallpaperFragment(Varyings in[[stage_in]], constant uint2 &resolution[[buffer(0)]], constant float &time[[buffer(1)]]) {
|
||||
half4 p = half4(in.position);
|
||||
p.y = -p.y;
|
||||
|
||||
p.y /= resolution.y;
|
||||
p.y += tan(time + tan(p.x) + sin(.2 * p.x));
|
||||
float4 out = float4(0.0, (0.3 + (p.y < 0.0 ? 0.0 : 1.0 - p.y * 3.0)) * 0.2, 0.0, 1.0);
|
||||
|
||||
return half4(out);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import TelegramAnimatedStickerNode
|
||||
import HierarchyTrackingLayer
|
||||
import MetalKit
|
||||
import HierarchyTrackingLayer
|
||||
import simd
|
||||
|
||||
private final class NullActionClass: NSObject, CAAction {
|
||||
static let shared = NullActionClass()
|
||||
@ -247,13 +248,19 @@ final class MetalWallpaperBackgroundNode: ASDisplayNode, WallpaperBackgroundNode
|
||||
var vertices: [Float] = [
|
||||
-1.0, -1.0,
|
||||
1.0, -1.0,
|
||||
-1.0, animationOffset * 1.0,
|
||||
1.0, animationOffset * 1.0
|
||||
-1.0, 1.0,
|
||||
1.0, 1.0
|
||||
]
|
||||
|
||||
renderEncoder.setRenderPipelineState(self.renderPipelineState)
|
||||
|
||||
renderEncoder.setVertexBytes(&vertices, length: 4 * vertices.count, index: 0)
|
||||
|
||||
var resolution = simd_uint2(UInt32(drawable.texture.width), UInt32(drawable.texture.height))
|
||||
renderEncoder.setFragmentBytes(&resolution, length: MemoryLayout<simd_uint2>.size * 2, index: 0)
|
||||
|
||||
var time = Float(timestamp) * 0.25
|
||||
renderEncoder.setFragmentBytes(&time, length: 4, index: 1)
|
||||
|
||||
renderEncoder.drawPrimitives(type: .triangleStrip, vertexStart: 0, vertexCount: 4, instanceCount: 1)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user