| 1 |
/* Gouraud shading GLSL fragment shader. */ |
| 2 |
|
| 3 |
/* PLUG-DECLARATIONS */ |
| 4 |
|
| 5 |
#ifdef HAS_GEOMETRY_SHADER |
| 6 |
#define castle_vertex_eye castle_vertex_eye_geoshader |
| 7 |
#define castle_normal_eye castle_normal_eye_geoshader |
| 8 |
#define castle_Color castle_Color_geoshader |
| 9 |
#endif |
| 10 |
|
| 11 |
varying vec4 castle_vertex_eye; |
| 12 |
varying vec3 castle_normal_eye; |
| 13 |
varying vec4 castle_Color; |
| 14 |
|
| 15 |
/* Include fragment shader utilities used by both Gouraud and Phong shading. */ |
| 16 |
/* CASTLE-COMMON-CODE */ |
| 17 |
|
| 18 |
void main(void) |
| 19 |
{ |
| 20 |
vec4 fragment_color = castle_Color; |
| 21 |
|
| 22 |
/* Fragment shader in Gouraud doesn't get a normal vector, for speed. */ |
| 23 |
#define normal_eye_fragment vec3(0.0) |
| 24 |
|
| 25 |
/* PLUG: main_texture_apply (fragment_color, normal_eye_fragment) */ |
| 26 |
/* PLUG: texture_apply (fragment_color, normal_eye_fragment) */ // deprecated |
| 27 |
/* PLUG: steep_parallax_shadow_apply (fragment_color) */ |
| 28 |
|
| 29 |
/* PLUG: fragment_modify (fragment_color) */ |
| 30 |
|
| 31 |
#ifdef CASTLE_GAMMA_CORRECTION |
| 32 |
fragment_color.rgb = castle_linear_to_screen(fragment_color.rgb); |
| 33 |
#else |
| 34 |
#ifdef CASTLE_TONE_MAPPING |
| 35 |
fragment_color.rgb = castle_linear_to_screen(fragment_color.rgb); |
| 36 |
#endif |
| 37 |
/* Optimization to not call castle_linear_to_screen always: |
| 38 |
it does nothing when neither CASTLE_GAMMA_CORRECTION nor CASTLE_TONE_MAPPING */ |
| 39 |
#endif |
| 40 |
|
| 41 |
/* PLUG: fog_apply (fragment_color, normal_eye_fragment) */ |
| 42 |
|
| 43 |
#undef normal_eye_fragment |
| 44 |
|
| 45 |
gl_FragColor = fragment_color; |
| 46 |
|
| 47 |
/* PLUG: fragment_end (gl_FragColor) */ |
| 48 |
} |