diff --git a/data/shaders/sp_advanced_terrain.frag b/data/shaders/sp_advanced_terrain.frag new file mode 100644 index 000000000..4065f80fc --- /dev/null +++ b/data/shaders/sp_advanced_terrain.frag @@ -0,0 +1,59 @@ +in vec3 bitangent; +in vec4 color; +in float hue_change; +in vec3 normal; +in vec3 tangent; +in vec2 uv; +in float camdist; +in vec4 world_position; +in vec3 world_normal; + +layout(location = 0) out vec4 o_diffuse_color; +layout(location = 1) out vec4 o_normal_color; + +#stk_include "utils/encode_normal.frag" +#stk_include "utils/rgb_conversion.frag" +#stk_include "utils/sp_texture_sampling.frag" + +float overlay(float bg, float fg) +{ + return bg < 0.5 ? (2.0 * bg * fg) : (1.0 - 2.0 * (1.0 - bg) * (1.0 - fg)); +} + +void main() +{ + vec4 col = multi_sampleTextureLayer0(uv, camdist); + vec4 rock = multi_sampleTextureLayer4(uv, camdist); + + vec2 uuv = vec2(world_position.x, world_position.z); + + + float mask_2 = multi_sampleTextureLayer5(uv, camdist).r; + mask_2 = pow(mask_2, 1.5); + + float up_mask = dot(vec3(0., 1., 0.), world_normal); + up_mask = pow(up_mask + (up_mask * 0.1), 2); + up_mask = clamp(up_mask, 0.0, 1.0); + //vec3 final_color = mix(col.rgb, rock.rgb, overlay(color.r, mask_2)); + vec3 final_color = mix(rock.rgb, col.rgb, overlay(up_mask, mask_2)); + //vec3 final_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), overlay(color.r, mask_2)); + +#if defined(Advanced_Lighting_Enabled) + vec4 layer_2 = multi_sampleTextureLayer2(uv, camdist); + vec4 layer_3 = multi_sampleTextureLayer3(uv, camdist); + o_diffuse_color = vec4(final_color, layer_2.z); + + vec3 tangent_space_normal = 2.0 * layer_3.xyz - 1.0; + vec3 frag_tangent = normalize(tangent); + vec3 frag_bitangent = normalize(bitangent); + vec3 frag_normal = normalize(normal); + mat3 t_b_n = mat3(frag_tangent, frag_bitangent, frag_normal); + + vec3 world_normal = t_b_n * tangent_space_normal; + + o_normal_color.xy = 0.5 * EncodeNormal(normalize(world_normal)) + 0.5; + o_normal_color.zw = layer_2.xy; +#else + o_diffuse_color = vec4(final_color, 1.0); +#endif +} diff --git a/data/shaders/sp_kart_dirt.frag b/data/shaders/sp_kart_dirt.frag index f22805bad..a713c494f 100644 --- a/data/shaders/sp_kart_dirt.frag +++ b/data/shaders/sp_kart_dirt.frag @@ -49,6 +49,7 @@ void main() dirtMask *= clamp(dirt_factor, 0.0, 1.0); nitroMask *= clamp(dirt_factor, 0.0, 1.0); vec3 final_color = col.xyz * color.xyz; + //dirtMask = step(dirtMask,dirt_factor - 0.5); final_color = mix(final_color, dirt, dirtMask); final_color = mix(final_color, vec3(0, 0.415, 0.639), nitroMask); diff --git a/data/shaders/sps_13_advancedTerrain.xml b/data/shaders/sps_13_advancedTerrain.xml new file mode 100644 index 000000000..a7180d688 --- /dev/null +++ b/data/shaders/sps_13_advancedTerrain.xml @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/src/graphics/skid_marks.cpp b/src/graphics/skid_marks.cpp index 94bddaefd..f2b5c2821 100644 --- a/src/graphics/skid_marks.cpp +++ b/src/graphics/skid_marks.cpp @@ -46,8 +46,8 @@ SkidMarks::SkidMarks(const AbstractKart& kart, float width) : m_kart(kart) { m_width = width; m_material = material_manager->getMaterialSPM("skidmarks.png", "", - "alphablend"); - m_shader = SP::SPShaderManager::get()->getSPShader("alphablend"); + "alphatest"); + m_shader = SP::SPShaderManager::get()->getSPShader("alphatest"); assert(m_shader); auto texture = SP::SPTextureManager::get()->getTexture( m_material->getSamplerPath(0), m_material,