diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-07-08 12:34:05 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-07-08 12:36:15 -0300 |
commit | f4c8c552f956094e1bb8787de79476f57dd6a7b6 (patch) | |
tree | 4ed1eb9e7d0a9401db6eaaadf257d8e73e03b499 /drivers/gles3/shaders | |
parent | 0067982f5ece3145c00e2f4c0bc092d1ec28c8b3 (diff) |
Added triplanar mapping, toon mode, and more specular modes for materials. Added multipass support for materials.
Diffstat (limited to 'drivers/gles3/shaders')
-rw-r--r-- | drivers/gles3/shaders/cubemap_filter.glsl | 4 | ||||
-rw-r--r-- | drivers/gles3/shaders/scene.glsl | 36 |
2 files changed, 37 insertions, 3 deletions
diff --git a/drivers/gles3/shaders/cubemap_filter.glsl b/drivers/gles3/shaders/cubemap_filter.glsl index 10a803cafe..393ef2892a 100644 --- a/drivers/gles3/shaders/cubemap_filter.glsl +++ b/drivers/gles3/shaders/cubemap_filter.glsl @@ -204,7 +204,9 @@ vec4 textureDualParaboloidArray(vec3 normal) { vec3 norm = normalize(normal); norm.xy/=1.0+abs(norm.z); norm.xy=norm.xy * vec2(0.5,0.25) + vec2(0.5,0.25); - norm.y+=max(0.0,sign(-norm.z))*0.5; + if (norm.z<0) { + norm.y=0.5-norm.y+0.5; + } return textureLod(source_dual_paraboloid_array, vec3(norm.xy, float(source_array_index) ), 0.0); } diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index cea963503f..545c7b2605 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -775,6 +775,10 @@ LIGHT_SHADER_CODE diffuse += diffuse_color * max(0.0, NdotL) * (A + vec3(B) * s / t) / M_PI; } +#elif defined(DIFFUSE_TOON) + + diffuse += smoothstep(-roughness,roughness,dot(N,L)) * light_color * diffuse_color; + #elif defined(DIFFUSE_BURLEY) { @@ -805,6 +809,34 @@ LIGHT_SHADER_CODE if (roughness > 0.0) { + + // D + +#if defined(SPECULAR_BLINN) + + vec3 H = normalize(V + L); + float dotNH = max(dot(N,H), 0.0 ); + float intensity = pow( dotNH, (1.0-roughness) * 256.0); + specular += light_color * intensity; + +#elif defined(SPECULAR_PHONG) + + vec3 R = normalize(-reflect(L,N)); + float dotNV = max(0.0,dot(R,V)); + float intensity = pow( dotNV, (1.0-roughness) * 256.0); + specular += light_color * intensity; + +#elif defined(SPECULAR_TOON) + + vec3 R = normalize(-reflect(L,N)); + float dotNV = dot(R,V); + float mid = 1.0-roughness; + float intensity = smoothstep(mid-roughness*0.5,mid+roughness*0.5,dotNV); + diffuse += light_color * intensity; //write to diffuse, as in toon shading you generally want no reflection + + +#else + // shlick+ggx as default float alpha = roughness * roughness; vec3 H = normalize(V + L); @@ -812,7 +844,6 @@ LIGHT_SHADER_CODE float dotNH = max(dot(N,H), 0.0 ); float dotLH = max(dot(L,H), 0.0 ); - // D #if defined(LIGHT_USE_ANISOTROPY) float aspect = sqrt(1.0-anisotropy*0.9); @@ -844,6 +875,7 @@ LIGHT_SHADER_CODE float speci = dotNL * D * F * vis; specular += speci * light_color * specular_blob_intensity; +#endif #if defined(LIGHT_USE_CLEARCOAT) float Dr = GTR1(dotNH, mix(.1,.001,clearcoat_gloss)); @@ -1686,7 +1718,7 @@ FRAGMENT_SHADER_CODE float ndotv = clamp(dot(normal,eye_vec),0.0,1.0); //energy conservation - vec3 dielectric = vec3(0.034) * 0.5 * 2.0; + vec3 dielectric = vec3(0.034) * specular * 2.0; vec3 f0 = mix(dielectric, albedo, metallic); const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022); const vec4 c1 = vec4( 1.0, 0.0425, 1.04, -0.04); |