Simple Parallax Material Scrolling

How to use:

Convert the material with texture albedo to a shader, then copy and paste the code below and add to the code you just created. 

Shader code
uniform vec2 scroll_speed = vec2(0.2, 0.0); // Default scroll to the **left** at 0.5 units/sec

void vertex() {
    // Apply initial UV scaling and offset
    vec2 scaled_uv = UV * uv1_scale.xy + uv1_offset.xy;

    // **Apply scrolling based on TIME and scroll_speed**
    scaled_uv += scroll_speed * TIME;

    // Assign the modified UV to be used in fragment shader
    UV = scaled_uv;
}

void fragment() {
    vec2 base_uv = UV;

    vec4 albedo_tex = texture(texture_albedo, base_uv);
    ALBEDO = albedo.rgb * albedo_tex.rgb;

    float metallic_tex = dot(texture(texture_metallic, base_uv), metallic_texture_channel);
    METALLIC = metallic_tex * metallic;
    SPECULAR = specular;

    vec4 roughness_texture_channel = vec4(1.0, 0.0, 0.0, 0.0);
    float roughness_tex = dot(texture(texture_roughness, base_uv), roughness_texture_channel);
    ROUGHNESS = roughness_tex * roughness;

    // Emission: Enabled
    vec3 emission_tex = texture(texture_emission, base_uv).rgb;
    // Emission Operator: Add
    EMISSION = (emission.rgb + emission_tex) * emission_energy;
    ALPHA *= albedo.a * albedo_tex.a;
}
Tags
4.3
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

Parallax Mapping

Cheap parallax planes array

Iterative parallax mapping

Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
mossflwer
5 days ago

Pretty sure this is broken or missing something? Pasting just this into the shader field results in error. And the description makes it seem like theres a part 1 we are missing