X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=builtin_data%2F_envmap_specular.glsl;fp=builtin_data%2F_envmap_specular.glsl;h=d39cc61f300f071c40bc7c359456ae5cec967002;hb=6b9338845dfee441cd18ad6c633e4feef8ad14e1;hp=0000000000000000000000000000000000000000;hpb=87b74b1263710b0acb9e0b72283e972fd54ee91b;p=libs%2Fgl.git diff --git a/builtin_data/_envmap_specular.glsl b/builtin_data/_envmap_specular.glsl new file mode 100644 index 00000000..d39cc61f --- /dev/null +++ b/builtin_data/_envmap_specular.glsl @@ -0,0 +1,29 @@ +import cubemap_effect; +import _pbr_prefilter; + +#pragma MSP stage(fragment) +layout(location=0) out vec3 frag_color; +void main() +{ + vec3 normal = normalize(texcoord); + vec3 tangent = normalize(abs(normal.x)>abs(normal.y) ? vec3(-normal.z, 0.0, normal.x) : vec3(0.0, -normal.z, normal.y)); + mat3 orientation = mat3(tangent, cross(normal, tangent), normal); + + vec3 sum = vec3(0.0); + float weight = 0.0; + for(int i=0; i0) + { + sum += textureLod(environment_map, light_dir, 0).rgb*n_dot_light; + weight += n_dot_light; + } + } + + frag_color = sum/weight; +}