Mercurial > touhou
comparison pytouhou/ui/shaders/eosd.py @ 370:74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 27 Jul 2012 18:43:48 +0200 |
parents | |
children | 346614f788f1 |
comparison
equal
deleted
inserted
replaced
369:f305cdd6f6c5 | 370:74471afbac37 |
---|---|
1 # -*- encoding: utf-8 -*- | |
2 ## | |
3 ## Copyright (C) 2012 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | |
4 ## | |
5 ## This program is free software; you can redistribute it and/or modify | |
6 ## it under the terms of the GNU General Public License as published | |
7 ## by the Free Software Foundation; version 3 only. | |
8 ## | |
9 ## This program is distributed in the hope that it will be useful, | |
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 ## GNU General Public License for more details. | |
13 ## | |
14 | |
15 | |
16 from pytouhou.ui.shader import Shader | |
17 | |
18 | |
19 class GameShader(Shader): | |
20 def __init__(self): | |
21 Shader.__init__(self, [''' | |
22 #version 120 | |
23 | |
24 uniform mat4 mvp; | |
25 | |
26 void main() | |
27 { | |
28 gl_Position = mvp * gl_Vertex; | |
29 gl_FrontColor = gl_Color; | |
30 gl_TexCoord[0] = gl_MultiTexCoord0; | |
31 } | |
32 '''], [ ''' | |
33 #version 120 | |
34 | |
35 uniform sampler2D color_map; | |
36 | |
37 void main() | |
38 { | |
39 gl_FragColor = texture2D(color_map, gl_TexCoord[0].st) * gl_Color; | |
40 } | |
41 ''']) | |
42 | |
43 | |
44 class BackgroundShader(Shader): | |
45 def __init__(self): | |
46 Shader.__init__(self, [''' | |
47 #version 120 | |
48 | |
49 uniform mat4 model_view; | |
50 uniform mat4 projection; | |
51 | |
52 varying float fog_density; | |
53 | |
54 void main() | |
55 { | |
56 gl_Position = model_view * gl_Vertex; | |
57 gl_FrontColor = gl_Color; | |
58 gl_TexCoord[0] = gl_MultiTexCoord0; | |
59 | |
60 float fog_position = -gl_Position.z / gl_Position.w; | |
61 fog_density = clamp((gl_Fog.end - fog_position) * gl_Fog.scale, 0.0f, 1.0f); | |
62 | |
63 gl_Position = projection * gl_Position; | |
64 } | |
65 '''], [ ''' | |
66 #version 120 | |
67 | |
68 uniform sampler2D color_map; | |
69 | |
70 varying float fog_density; | |
71 | |
72 void main() | |
73 { | |
74 vec4 color = texture2D(color_map, gl_TexCoord[0].st) * gl_Color; | |
75 gl_FragColor = mix(gl_Fog.color, color, fog_density); | |
76 gl_FragColor.w = color.w; | |
77 } | |
78 ''']) |