X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=shaderlib%2Fshadow.glsl;h=2fa1fd81686c832f3ce78463467500966c092a8e;hb=bace0b24414abc7b3ba46df3a9fd7408d7479a5e;hp=c26a1ca3782039cbb3ba1e6261abeace13c78859;hpb=a2b0d155023ca23afe7848ae5d17e0f7bc328525;p=libs%2Fgl.git diff --git a/shaderlib/shadow.glsl b/shaderlib/shadow.glsl index c26a1ca3..2fa1fd81 100644 --- a/shaderlib/shadow.glsl +++ b/shaderlib/shadow.glsl @@ -2,15 +2,16 @@ import msp_interface; struct ShadowParameters { - int enabled; + int type; float darkness; - mat4 shd_world_matrix; + int matrix_index; vec4 region; }; uniform ShadowMap { ShadowParameters shadows[max_lights]; + mat4 shd_world_matrix[max_lights]; }; uniform sampler2DShadow shadow_map; @@ -18,14 +19,17 @@ uniform sampler2DShadow shadow_map; layout(constant_id=auto) const bool use_shadow_map = false; #pragma MSP stage(fragment) -virtual float get_shadow_factor(int index) +virtual float get_shadow_factor(int index, vec4 world_pos) { if(use_shadow_map) { - if(shadows[index].enabled==0) + int type = shadows[index].type; + vec3 shadow_coord; + if(type==1) + shadow_coord = (shd_world_matrix[shadows[index].matrix_index]*world_pos).xyz; + else return 1.0; - vec3 shadow_coord = (shadows[index].shd_world_matrix*world_vertex).xyz; if(shadow_coord.x<0 || shadow_coord.x>1 || shadow_coord.y<0 || shadow_coord.y>1) return 1.0;