diff options
| author | andromeda <andromeda@lenovo> | 2026-08-20 03:52:49 +0200 |
|---|---|---|
| committer | andromeda <andromeda@lenovo> | 2026-08-20 03:52:49 +0200 |
| commit | 85eaba320ed26b811af6df72c8e151a45d9a3f92 (patch) | |
| tree | 30a6f8a74fed659e43728fa44fd71987a9e47738 /Shaders.hs | |
| parent | 2c025b3b32a255d32c521e917f7a3583971a2e63 (diff) | |
draw, nothing on screen
Diffstat (limited to 'Shaders.hs')
| -rw-r--r-- | Shaders.hs | 41 |
1 files changed, 31 insertions, 10 deletions
@@ -1,5 +1,6 @@ {-# LANGUAGE BlockArguments #-} {-# LANGUAGE DataKinds #-} +{-# LANGUAGE PartialTypeSignatures #-} {-# LANGUAGE RebindableSyntax #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-} @@ -10,14 +11,34 @@ module Shaders where import FIR import Math.Linear -type FragmentDefs = '[ "in_pos" ':-> Input '[ Location 0 ] (V 2 Float) - , "out_col" ':-> Output '[ Location 0 ] (V 4 Float) - , "image" ':-> Texture2D '[ DescriptorSet 0, Binding 0 ] (RGBA8 UNorm) - , "main" ':-> EntryPoint '[ OriginLowerLeft ] Fragment - ] +vertices = Vec3 (Vec2 0 (-0.5)) + (Vec2 0.5 0.5) + (Vec2 (-0.5) 0.5) -fragment :: Module FragmentDefs -fragment = Module $ entryPoint @"main" @Fragment do - pos <- get @"in_pos" - col <- use @(ImageTexel "image") NilOps pos - put @"out_col" col
\ No newline at end of file +vertPath = "assets/shaders/vert.spv" +fragPath = "assets/shaders/frag.spv" + +type VertexDefs = + '[ "main" ':-> EntryPoint '[] Vertex ] + +vertex :: ShaderModule "main" VertexShader VertexDefs _ +vertex = shader do + i <- get @"gl_VertexIndex" + let (Vec2 x y) = atv3v2f vertices i (Vec2 0 0) + put @"gl_Position" (Vec4 x y 0.0 1.0) + +type FragmentDefs = + '[ "main" ':-> EntryPoint '[ OriginUpperLeft ] Fragment + , "out_color" ':-> Output '[ Location 0 ] (V 4 Float) + ] + +fragment :: ShaderModule "main" FragmentShader FragmentDefs _ +fragment = shader do + put @"out_color" (Vec4 1.0 1.0 0.0 1.0) + +atv3v2f :: Code (V 3 (V 2 Float)) -> Code Word32 -> Code (V 2 Float) -> Code (V 2 Float) +atv3v2f (Vec3 x y z) i d = + if i == 0 then x + else if i == 1 then y + else if i == 2 then z + else d
\ No newline at end of file |
