… | |
… | |
71 | |
71 | |
72 | GLfloat nz_far, nz_near, nc_far; |
72 | GLfloat nz_far, nz_near, nc_far; |
73 | GLfloat diagfact; // bounding box border to depth factor |
73 | GLfloat diagfact; // bounding box border to depth factor |
74 | GLfloat perspfact; // perspfact * (1/depth)=> pixels |
74 | GLfloat perspfact; // perspfact * (1/depth)=> pixels |
75 | |
75 | |
76 | gl::matrix projection; |
|
|
77 | |
|
|
78 | struct { |
76 | struct { |
79 | plane l, r, t, b, n, f; |
77 | plane l, r, t, b, n, f; |
80 | cone c; |
78 | cone c; |
81 | sphere s; |
79 | sphere s; |
82 | } frustum; |
80 | } frustum; |
… | |
… | |
123 | |
121 | |
124 | struct light : view |
122 | struct light : view |
125 | { |
123 | { |
126 | // the following variables are valid in the fragment shader as well as in the vertex shader |
124 | // the following variables are valid in the fragment shader as well as in the vertex shader |
127 | bool has_lightvec; // is a light vector available? |
125 | bool has_lightvec; // is a light vector available? |
128 | shader::temp_3f sh_lightvec; // not defined unless has_lightvec is true |
126 | shader::temp_3f sh_lightvec; // not defined unless has_lightvec is true |
129 | shader::temp_3f sh_colour; // always available for any light |
127 | shader::temp_3f sh_colour; // always available for any light |
130 | |
128 | |
131 | // vertex shader |
129 | // vertex shader |
132 | virtual void vsh () = 0; |
130 | virtual void vsh () = 0; |
133 | // fragment shader |
131 | // fragment shader |
134 | virtual void fsh () = 0; |
132 | virtual void fsh () = 0; |
135 | |
133 | |
136 | virtual void enable (); |
134 | virtual void enable (view &ctx); |
137 | virtual void disable (); |
135 | virtual void disable (view &ctx); |
138 | |
136 | |
139 | protected: |
137 | protected: |
|
|
138 | shader::varying_3f lightvec; |
|
|
139 | shader::varying_1f camdist; |
140 | shader::uniform_3f lightpos; // or direction |
140 | shader::uniform_3f lightpos; // or direction |
141 | }; |
141 | }; |
142 | |
142 | |
143 | struct linear_light : light |
143 | struct linear_light : light |
144 | { |
144 | { |