diff options
author | Joe Crayne <joe@jerkface.net> | 2019-04-30 22:59:13 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-04-30 22:59:13 -0400 |
commit | fce8237d59397054ea467fd9b5357877342dc34b (patch) | |
tree | 8ce3ff02c5ad8edec01f54aa396005e54c1c1a98 /SavedPipeline.hs | |
parent | 3a959223200961dedef69a28146662077aa0e093 (diff) |
This seems to work to use skycube and object texturing together.
Diffstat (limited to 'SavedPipeline.hs')
-rw-r--r-- | SavedPipeline.hs | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/SavedPipeline.hs b/SavedPipeline.hs new file mode 100644 index 0000000..053eb6b --- /dev/null +++ b/SavedPipeline.hs | |||
@@ -0,0 +1,151 @@ | |||
1 | {-# LANGUAGE OverloadedLists #-} | ||
2 | module SavedPipeline where | ||
3 | |||
4 | import LambdaCube.IR | ||
5 | import LambdaCube.Linear | ||
6 | import Data.Vector (Vector) | ||
7 | import Data.Map (Map) | ||
8 | import GHC.Exts | ||
9 | |||
10 | |||
11 | savedPipeline :: Pipeline | ||
12 | savedPipeline = Pipeline | ||
13 | { info = "Generated by lambdacube-compiler 0.6.1.0, edited to support TextureCube." | ||
14 | , backend = OpenGL33 | ||
15 | , textures = [] | ||
16 | , samplers = [] | ||
17 | , targets = | ||
18 | [ RenderTarget { renderTargets = [ TargetItem { targetSemantic = Depth , targetRef = Just (Framebuffer Depth) } | ||
19 | , TargetItem { targetSemantic = Color , targetRef = Just (Framebuffer Color) } | ||
20 | ] | ||
21 | } | ||
22 | ] | ||
23 | , programs = | ||
24 | [ Program | ||
25 | { programUniforms = fromList [ ( "ViewProjection" , M44F ) ] | ||
26 | , programStreams = fromList [ ( "vi1" , Parameter { name = "position" , ty = V4F } ) ] | ||
27 | , programInTextures = fromList [] | ||
28 | , programOutput = [ Parameter { name = "f0" , ty = V4F } ] | ||
29 | , vertexShader = | ||
30 | "#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}" | ||
31 | , geometryShader = Nothing | ||
32 | , fragmentShader = | ||
33 | "#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}" | ||
34 | } | ||
35 | , Program | ||
36 | { programUniforms = fromList | ||
37 | [ ( "ViewProjection" , M44F ) | ||
38 | , ( "diffuseColor" , V4F ) | ||
39 | , ( "diffuseTexture" , FTexture2D ) | ||
40 | ] | ||
41 | , programStreams = fromList | ||
42 | [ ( "vi1" , Parameter { name = "position" , ty = V4F } ) | ||
43 | , ( "vi2" , Parameter { name = "normal" , ty = V3F } ) | ||
44 | , ( "vi3" , Parameter { name = "uvw" , ty = V3F } ) | ||
45 | ] | ||
46 | , programInTextures = fromList [ ( "diffuseTexture" , FTexture2D ) ] | ||
47 | , programOutput = [ Parameter { name = "f0" , ty = V4F } ] | ||
48 | , vertexShader = | ||
49 | "#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}" | ||
50 | , geometryShader = Nothing | ||
51 | , fragmentShader = | ||
52 | "#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}" | ||
53 | } | ||
54 | , Program | ||
55 | { programUniforms = fromList | ||
56 | [ ( "CameraPosition" , V3F ) | ||
57 | , ( "CubeMap" , FTextureCube ) | ||
58 | , ( "ViewProjection" , M44F ) | ||
59 | ] | ||
60 | , programStreams = fromList [ ( "vi1" , Parameter { name = "position" , ty = V3F } ) ] | ||
61 | , programInTextures = fromList [ ( "CubeMap" , FTextureCube ) ] | ||
62 | , programOutput = [ Parameter { name = "f0" , ty = V4F } ] | ||
63 | , vertexShader = | ||
64 | "#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}" | ||
65 | , geometryShader = Nothing | ||
66 | , fragmentShader = | ||
67 | "#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}" | ||
68 | } | ||
69 | ] | ||
70 | , slots = | ||
71 | [ Slot { slotName = "plane" | ||
72 | , slotStreams = fromList [ ( "position" , V4F ) ] | ||
73 | , slotUniforms = fromList [ ( "ViewProjection" , M44F ) ] | ||
74 | , slotPrimitive = Triangles | ||
75 | , slotPrograms = [ 0 ] | ||
76 | } | ||
77 | , Slot { slotName = "objects" | ||
78 | , slotStreams = fromList [ ( "normal" , V3F ) , ( "position" , V4F ) , ( "uvw" , V3F ) ] | ||
79 | , slotUniforms = fromList [ ( "ViewProjection" , M44F ) | ||
80 | , ( "diffuseColor" , V4F ) | ||
81 | , ( "diffuseTexture" , FTexture2D ) | ||
82 | ] | ||
83 | , slotPrimitive = Triangles | ||
84 | , slotPrograms = [ 1 ] | ||
85 | } | ||
86 | , Slot { slotName = "SkyCube" | ||
87 | , slotStreams = fromList [ ( "position" , V3F ) ] | ||
88 | , slotUniforms = fromList [ ( "CameraPosition" , V3F ) | ||
89 | , ( "CubeMap" , FTextureCube ) | ||
90 | , ( "ViewProjection" , M44F ) | ||
91 | ] | ||
92 | , slotPrimitive = Triangles | ||
93 | , slotPrograms = [ 2 ] | ||
94 | } | ||
95 | ] | ||
96 | , streams = [] | ||
97 | , commands = | ||
98 | [ SetRenderTarget 0 | ||
99 | , ClearRenderTarget | ||
100 | [ ClearImage { imageSemantic = Depth , clearValue = VFloat 1.0 } | ||
101 | , ClearImage { imageSemantic = Color , clearValue = VV4F (V4 0.0 0.0 0.4 1.0) } | ||
102 | ] | ||
103 | , SetProgram 2 | ||
104 | -- This command is wrong. It causes the diffuseTexture mapping to fail. | ||
105 | -- , SetSamplerUniform "CubeMap" 1 | ||
106 | , SetRasterContext (TriangleCtx CullNone PolygonFill NoOffset LastVertex) | ||
107 | , SetAccumulationContext | ||
108 | AccumulationContext | ||
109 | { accViewportName = Nothing | ||
110 | , accOperations = [ DepthOp Always False | ||
111 | , ColorOp NoBlending (VV4B (V4 True True True True)) | ||
112 | ] | ||
113 | } | ||
114 | , RenderSlot 2 | ||
115 | -- This doesn't help. | ||
116 | -- , ClearRenderTarget [ ClearImage { imageSemantic = Depth , clearValue = VFloat 1.0 } ] | ||
117 | , SetProgram 1 | ||
118 | , SetSamplerUniform "diffuseTexture" 2 | ||
119 | , SetRasterContext (TriangleCtx (CullBack CCW) PolygonFill NoOffset LastVertex) | ||
120 | , SetAccumulationContext | ||
121 | AccumulationContext | ||
122 | { accViewportName = Nothing | ||
123 | , accOperations = [ DepthOp Less True | ||
124 | , ColorOp NoBlending (VV4B (V4 True True True True)) | ||
125 | ] | ||
126 | } | ||
127 | , RenderSlot 1 | ||
128 | , SetProgram 0 | ||
129 | , SetRasterContext (TriangleCtx CullNone PolygonFill NoOffset LastVertex) | ||
130 | , SetAccumulationContext | ||
131 | AccumulationContext | ||
132 | { accViewportName = Nothing | ||
133 | , accOperations = | ||
134 | [ DepthOp Less True | ||
135 | , ColorOp | ||
136 | Blend | ||
137 | { colorEqSrc = FuncAdd | ||
138 | , alphaEqSrc = FuncAdd | ||
139 | , colorFSrc = One | ||
140 | , colorFDst = SrcAlpha | ||
141 | , alphaFSrc = DstAlpha | ||
142 | , alphaFDst = DstAlpha | ||
143 | , color = V4 0.0 0.0 0.0 0.0 | ||
144 | } | ||
145 | (VV4B (V4 True True True True)) | ||
146 | ] | ||
147 | } | ||
148 | , RenderSlot 0 | ||
149 | ] | ||
150 | } | ||
151 | |||