1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

support for 2D shadow casters

Added support for 2D shadow casters.

*DANGER* Shaders in CanvasItem CHANGED, if you are using shader in a
CanvasItem and pull this, you will lose them. Shaders now work through a
2D material system similar to 3D. If you don't want to lose the 2D
shader code, save the shader as a .shd, then create a material in
CanvasItem and re-assign the shader.
This commit is contained in:
Juan Linietsky
2015-03-02 00:54:10 -03:00
parent 0e732637d0
commit a1f715a4da
43 changed files with 2586 additions and 271 deletions

View File

@@ -121,7 +121,7 @@ void CameraMatrix::set_orthogonal(float p_size, float p_aspect, float p_znear, f
void CameraMatrix::set_frustum(float p_left, float p_right, float p_bottom, float p_top, float p_near, float p_far) {
#if 0
///@TODO, give a check to this. I'm not sure if it's working.
set_identity();
@@ -133,10 +133,27 @@ void CameraMatrix::set_frustum(float p_left, float p_right, float p_bottom, floa
matrix[2][3]=-(2*p_far*p_near) / (p_far-p_near);
matrix[3][2]=-1;
matrix[3][3]=0;
#else
float *te = &matrix[0][0];
float x = 2 * p_near / ( p_right - p_left );
float y = 2 * p_near / ( p_top - p_bottom );
float a = ( p_right + p_left ) / ( p_right - p_left );
float b = ( p_top + p_bottom ) / ( p_top - p_bottom );
float c = - ( p_far + p_near ) / ( p_far - p_near );
float d = - 2 * p_far * p_near / ( p_far - p_near );
te[0] = x; te[4] = 0; te[8] = a; te[12] = 0;
te[1] = 0; te[5] = y; te[9] = b; te[13] = 0;
te[2] = 0; te[6] = 0; te[10] = c; te[14] = d;
te[3] = 0; te[7] = 0; te[11] = - 1; te[15] = 0;
#endif
}
float CameraMatrix::get_z_far() const {
const float * matrix = (const float*)this->matrix;