summaryrefslogtreecommitdiff
path: root/SavedPipeline.hs
blob: 053eb6b62d0bb2e9647d13a885bac825513e1ba2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
{-# LANGUAGE OverloadedLists #-}
module SavedPipeline where

import LambdaCube.IR
import LambdaCube.Linear
import Data.Vector (Vector)
import Data.Map (Map)
import GHC.Exts


savedPipeline :: Pipeline
savedPipeline = Pipeline
  { info = "Generated by lambdacube-compiler 0.6.1.0, edited to support TextureCube."
  , backend = OpenGL33
  , textures = []
  , samplers = []
  , targets =
      [ RenderTarget { renderTargets = [ TargetItem { targetSemantic = Depth , targetRef = Just (Framebuffer Depth) }
                                       , TargetItem { targetSemantic = Color , targetRef = Just (Framebuffer Color) }
                                       ]
                     }
      ]
  , programs =
      [ Program
          { programUniforms   = fromList [ ( "ViewProjection" , M44F ) ]
          , programStreams    = fromList [ ( "vi1" , Parameter { name = "position" , ty = V4F } ) ]
          , programInTextures = fromList []
          , programOutput     = [ Parameter { name = "f0" , ty = V4F } ]
          , vertexShader =
                "#version 330 core\nvec4 texture2D(sampler2D s,vec2 uv) {\n    return texture(s,uv);\n}\nuniform mat4 ViewProjection;\nin vec4 vi1;\nsmooth out vec2 vo1;\nvec4 coordmap(mat4 z0,vec4 z1) {\n    return (z0) * (z1);\n}\nvoid main() {\n    gl_Position = coordmap (ViewProjection,vi1);\n    vo1 = (vi1).xz;\n}"
          , geometryShader = Nothing
          , fragmentShader =
                "#version 330 core\nvec4 texture2D(sampler2D s,vec2 uv) {\n    return texture(s,uv);\n}\nsmooth in vec2 vo1;\nout vec4 f0;\nvoid main() {\n    f0 = ((vec4 (1.0,1.0,1.0,0.0)) * (max ((mix (vec2 (0.0,0.0)\n                                                ,vec2 (1.0,1.0)\n                                                ,greaterThanEqual (fract (vo1),(vec2 (1.0,1.0)) * (0.95)))).x\n                                          ,(mix (vec2 (0.0,0.0)\n                                                ,vec2 (1.0,1.0)\n                                                ,greaterThanEqual (fract (vo1),(vec2 (1.0,1.0)) * (0.95)))).y))) + (vec4 (0.0\n                                                                                                                         ,0.0\n                                                                                                                         ,0.0\n                                                                                                                         ,0.8));\n}"
          }
      , Program
          { programUniforms = fromList
                [ ( "ViewProjection" , M44F )
                , ( "diffuseColor"   , V4F )
                , ( "diffuseTexture" , FTexture2D )
                ]
          , programStreams = fromList
                [ ( "vi1" , Parameter { name = "position" , ty = V4F } )
                , ( "vi2" , Parameter { name = "normal" , ty = V3F } )
                , ( "vi3" , Parameter { name = "uvw" , ty = V3F } )
                ]
          , programInTextures = fromList [ ( "diffuseTexture" , FTexture2D ) ]
          , programOutput = [ Parameter { name = "f0" , ty = V4F } ]
          , vertexShader =
              "#version 330 core\nvec4 texture2D(sampler2D s,vec2 uv) {\n    return texture(s,uv);\n}\nuniform mat4 ViewProjection;\nin vec4 vi1;\nin vec3 vi2;\nin vec3 vi3;\nsmooth out vec2 vo1;\nvec4 coordmap(mat4 z0,vec4 z1) {\n    return (z0) * (z1);\n}\nvoid main() {\n    gl_Position = coordmap (ViewProjection,vi1);\n    vo1 = vec2 ((vi3).x,(1.0) - ((vi3).y));\n}"
          , geometryShader = Nothing
          , fragmentShader =
              "#version 330 core\nvec4 texture2D(sampler2D s,vec2 uv) {\n    return texture(s,uv);\n}\nuniform vec4 diffuseColor;\nuniform sampler2D diffuseTexture;\nsmooth in vec2 vo1;\nout vec4 f0;\nvoid main() {\n    f0 = (diffuseColor) * (texture2D (diffuseTexture,vo1));\n}"
          }
      , Program
          { programUniforms = fromList
                [ ( "CameraPosition" , V3F )
                , ( "CubeMap"        , FTextureCube )
                , ( "ViewProjection" , M44F )
                ]
          , programStreams    = fromList [ ( "vi1" , Parameter { name = "position" , ty = V3F } ) ]
          , programInTextures = fromList [ ( "CubeMap" , FTextureCube ) ]
          , programOutput     = [ Parameter { name = "f0" , ty = V4F } ]
          , vertexShader =
              "#version 330 core\nvec4 texture2D(sampler2D s,vec2 uv) {\n    return texture(s,uv);\n}\nuniform vec3 CameraPosition;\nuniform mat4 ViewProjection;\nin vec3 vi1;\nsmooth out vec3 vo1;\nvec4 point(vec3 z0) {\n    return vec4 ((z0).x,(z0).y,(z0).z,1.0);\n}\nvoid main() {\n    gl_Position = (ViewProjection) * (point ((vi1) + (CameraPosition)));\n    vo1 = vec3 ((vi1).x,(vi1).y,(vi1).z);\n}"
          , geometryShader = Nothing
          , fragmentShader =
              "#version 330 core\nvec4 texture2D(sampler2D s,vec2 uv) {\n    return texture(s,uv);\n}\nuniform samplerCube CubeMap;\nsmooth in vec3 vo1;\nout vec4 f0;\nvoid main() {\n    f0 = texture (CubeMap,vo1);\n}"
          }
      ]
  , slots =
      [ Slot { slotName      = "plane"
             , slotStreams   = fromList [ ( "position" , V4F ) ]
             , slotUniforms  = fromList [ ( "ViewProjection" , M44F ) ]
             , slotPrimitive = Triangles
             , slotPrograms  = [ 0 ]
             }
      , Slot { slotName     = "objects"
             , slotStreams  = fromList [ ( "normal" , V3F ) , ( "position" , V4F ) , ( "uvw" , V3F ) ]
             , slotUniforms = fromList [ ( "ViewProjection" , M44F )
                                       , ( "diffuseColor" , V4F )
                                       , ( "diffuseTexture" , FTexture2D )
                                       ]
             , slotPrimitive = Triangles
             , slotPrograms  = [ 1 ]
             }
      , Slot { slotName     = "SkyCube"
             , slotStreams  = fromList [ ( "position" , V3F ) ]
             , slotUniforms = fromList [ ( "CameraPosition" , V3F )
                                       , ( "CubeMap" , FTextureCube )
                                       , ( "ViewProjection" , M44F )
                                       ]
             , slotPrimitive = Triangles
             , slotPrograms  = [ 2 ]
             }
      ]
  , streams = []
  , commands =
      [ SetRenderTarget 0
      , ClearRenderTarget
          [ ClearImage { imageSemantic = Depth , clearValue = VFloat 1.0 }
          , ClearImage { imageSemantic = Color , clearValue = VV4F (V4 0.0 0.0 0.4 1.0) }
          ]
      , SetProgram 2
      -- This command is wrong.  It causes the diffuseTexture mapping to fail.
      -- , SetSamplerUniform "CubeMap" 1
      , SetRasterContext (TriangleCtx CullNone PolygonFill NoOffset LastVertex)
      , SetAccumulationContext
          AccumulationContext
            { accViewportName = Nothing
            , accOperations = [ DepthOp Always False
                              , ColorOp NoBlending (VV4B (V4 True True True True))
                              ]
            }
      , RenderSlot 2
      -- This doesn't help.
      -- , ClearRenderTarget [ ClearImage { imageSemantic = Depth , clearValue = VFloat 1.0 } ]
      , SetProgram 1
      , SetSamplerUniform "diffuseTexture" 2
      , SetRasterContext (TriangleCtx (CullBack CCW) PolygonFill NoOffset LastVertex)
      , SetAccumulationContext
          AccumulationContext
            { accViewportName = Nothing
            , accOperations = [ DepthOp Less True
                              , ColorOp NoBlending (VV4B (V4 True True True True))
                              ]
            }
      , RenderSlot 1
      , SetProgram 0
      , SetRasterContext (TriangleCtx CullNone PolygonFill NoOffset LastVertex)
      , SetAccumulationContext
          AccumulationContext
            { accViewportName = Nothing
            , accOperations =
                [ DepthOp Less True
                , ColorOp
                    Blend
                      { colorEqSrc = FuncAdd
                      , alphaEqSrc = FuncAdd
                      , colorFSrc = One
                      , colorFDst = SrcAlpha
                      , alphaFSrc = DstAlpha
                      , alphaFDst = DstAlpha
                      , color = V4 0.0 0.0 0.0 0.0
                      }
                    (VV4B (V4 True True True True))
                ]
            }
      , RenderSlot 0
      ]
  }