comparison pytouhou/ui/opengl/shaders/eosd.py @ 604:aca9551ee8b4

Fix compiling issues with Cython 0.20 ; don't pretend to concat shader sources
author Thibaut Girka <thib@sitedethib.com>
date Tue, 11 Nov 2014 15:46:31 +0100
parents 1be60813f7cb
children
comparison
equal deleted inserted replaced
603:e9300aae4b24 604:aca9551ee8b4
16 from ..shader import Shader 16 from ..shader import Shader
17 17
18 18
19 class GameShader(Shader): 19 class GameShader(Shader):
20 def __init__(self): 20 def __init__(self):
21 Shader.__init__(self, [''' 21 Shader.__init__(self, '''
22 attribute vec3 in_position; 22 attribute vec3 in_position;
23 attribute vec2 in_texcoord; 23 attribute vec2 in_texcoord;
24 attribute vec4 in_color; 24 attribute vec4 in_color;
25 25
26 uniform mat4 mvp; 26 uniform mat4 mvp;
32 { 32 {
33 gl_Position = mvp * vec4(in_position, 1.0); 33 gl_Position = mvp * vec4(in_position, 1.0);
34 texcoord = in_texcoord; 34 texcoord = in_texcoord;
35 color = in_color; 35 color = in_color;
36 } 36 }
37 '''], [''' 37 ''', '''
38 varying vec2 texcoord; 38 varying vec2 texcoord;
39 varying vec4 color; 39 varying vec4 color;
40 40
41 uniform sampler2D color_map; 41 uniform sampler2D color_map;
42 42
43 void main() 43 void main()
44 { 44 {
45 gl_FragColor = texture2D(color_map, texcoord) * color; 45 gl_FragColor = texture2D(color_map, texcoord) * color;
46 } 46 }
47 ''']) 47 ''')
48 48
49 49
50 class BackgroundShader(Shader): 50 class BackgroundShader(Shader):
51 def __init__(self): 51 def __init__(self):
52 Shader.__init__(self, [''' 52 Shader.__init__(self, '''
53 attribute vec3 in_position; 53 attribute vec3 in_position;
54 attribute vec2 in_texcoord; 54 attribute vec2 in_texcoord;
55 attribute vec4 in_color; 55 attribute vec4 in_color;
56 56
57 uniform mat4 mvp; 57 uniform mat4 mvp;
63 { 63 {
64 gl_Position = mvp * vec4(in_position, 1.0); 64 gl_Position = mvp * vec4(in_position, 1.0);
65 texcoord = in_texcoord; 65 texcoord = in_texcoord;
66 color = in_color; 66 color = in_color;
67 } 67 }
68 '''], [''' 68 ''', '''
69 varying vec2 texcoord; 69 varying vec2 texcoord;
70 varying vec4 color; 70 varying vec4 color;
71 71
72 uniform sampler2D color_map; 72 uniform sampler2D color_map;
73 uniform float fog_scale; 73 uniform float fog_scale;
79 vec4 temp_color = texture2D(color_map, texcoord) * color; 79 vec4 temp_color = texture2D(color_map, texcoord) * color;
80 float depth = gl_FragCoord.z / gl_FragCoord.w; 80 float depth = gl_FragCoord.z / gl_FragCoord.w;
81 float fog_density = clamp((fog_end - depth) * fog_scale, 0.0, 1.0); 81 float fog_density = clamp((fog_end - depth) * fog_scale, 0.0, 1.0);
82 gl_FragColor = vec4(mix(fog_color, temp_color, fog_density).rgb, temp_color.a); 82 gl_FragColor = vec4(mix(fog_color, temp_color, fog_density).rgb, temp_color.a);
83 } 83 }
84 ''']) 84 ''')
85 85
86 86
87 class PassthroughShader(Shader): 87 class PassthroughShader(Shader):
88 def __init__(self): 88 def __init__(self):
89 Shader.__init__(self, [''' 89 Shader.__init__(self, '''
90 attribute vec2 in_position; 90 attribute vec2 in_position;
91 attribute vec2 in_texcoord; 91 attribute vec2 in_texcoord;
92 92
93 uniform mat4 mvp; 93 uniform mat4 mvp;
94 94
97 void main() 97 void main()
98 { 98 {
99 gl_Position = mvp * vec4(in_position, 0.0, 1.0); 99 gl_Position = mvp * vec4(in_position, 0.0, 1.0);
100 texcoord = in_texcoord; 100 texcoord = in_texcoord;
101 } 101 }
102 '''], [''' 102 ''', '''
103 varying vec2 texcoord; 103 varying vec2 texcoord;
104 104
105 uniform sampler2D color_map; 105 uniform sampler2D color_map;
106 106
107 void main() 107 void main()
108 { 108 {
109 gl_FragColor = texture2D(color_map, texcoord); 109 gl_FragColor = texture2D(color_map, texcoord);
110 } 110 }
111 ''']) 111 ''')