Add better shader for dirt
This commit is contained in:
parent
0d56de5957
commit
bba591c2fc
59
data/shaders/sp_advanced_terrain.frag
Normal file
59
data/shaders/sp_advanced_terrain.frag
Normal file
@ -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
|
||||||
|
}
|
@ -49,6 +49,7 @@ void main()
|
|||||||
dirtMask *= clamp(dirt_factor, 0.0, 1.0);
|
dirtMask *= clamp(dirt_factor, 0.0, 1.0);
|
||||||
nitroMask *= clamp(dirt_factor, 0.0, 1.0);
|
nitroMask *= clamp(dirt_factor, 0.0, 1.0);
|
||||||
vec3 final_color = col.xyz * color.xyz;
|
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, dirt, dirtMask);
|
||||||
|
|
||||||
final_color = mix(final_color, vec3(0, 0.415, 0.639), nitroMask);
|
final_color = mix(final_color, vec3(0, 0.415, 0.639), nitroMask);
|
||||||
|
13
data/shaders/sps_13_advancedTerrain.xml
Normal file
13
data/shaders/sps_13_advancedTerrain.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<spshader>
|
||||||
|
<shader-info name="advancedTerrain" fallback-shader="solid" use-tangents="Y" srgb="Y Y N N Y N"/>
|
||||||
|
<first-pass vertex-shader="sp_pass.vert"
|
||||||
|
fragment-shader="sp_advanced_terrain.frag">
|
||||||
|
</first-pass>
|
||||||
|
<shadow-pass vertex-shader="sp_shadow.vert"
|
||||||
|
fragment-shader="white.frag">
|
||||||
|
</shadow-pass>
|
||||||
|
<uniform-assigners>
|
||||||
|
<uniform-assigner name="layer"
|
||||||
|
function="shadowCascadeUniformAssigner"/>
|
||||||
|
</uniform-assigners>
|
||||||
|
</spshader>
|
@ -46,8 +46,8 @@ SkidMarks::SkidMarks(const AbstractKart& kart, float width) : m_kart(kart)
|
|||||||
{
|
{
|
||||||
m_width = width;
|
m_width = width;
|
||||||
m_material = material_manager->getMaterialSPM("skidmarks.png", "",
|
m_material = material_manager->getMaterialSPM("skidmarks.png", "",
|
||||||
"alphablend");
|
"alphatest");
|
||||||
m_shader = SP::SPShaderManager::get()->getSPShader("alphablend");
|
m_shader = SP::SPShaderManager::get()->getSPShader("alphatest");
|
||||||
assert(m_shader);
|
assert(m_shader);
|
||||||
auto texture = SP::SPTextureManager::get()->getTexture(
|
auto texture = SP::SPTextureManager::get()->getTexture(
|
||||||
m_material->getSamplerPath(0), m_material,
|
m_material->getSamplerPath(0), m_material,
|
||||||
|
Loading…
Reference in New Issue
Block a user