Home Marmoset

Can you help me to make a scrolling emissive with a custom shader fragment?

polycounter lvl 2
Offline / Send Message
Hitsu San polycounter lvl 2
Hi guys,

I have no idea what i'm doing, let's be honest here. I've been looking for days for a way to make a scroll FX with a static mask in Toolbag3 but it's impossible with the base materials (i know i can use Main > Offset and keyframe it but that will move the transparency mask as well with horrible results).

I know my (visual editor) shaders but i've never learned how to code a simple glsl one so it's like i'm looking at an alien language right now ^^ any help will be extremely appreciated!

Replies

  • Defunct
    Offline / Send Message
    Defunct polycounter lvl 11
    I messed around a bit with example1.frag and I think I've got what you're looking for working.
    1. //provides FragmentState
    2. #include "../state.frag"
    3.  
    4. //provides misc params like 'uCustomTime'
    5. #include "../other/customExtras.sh"
    6.  
    7. uniform vec3 uColor; //color name "Color" default 1.0, 0.35, 0.2
    8. uniform float uSpeed; //name "Speed" default 0.25 min 0 max 1
    9. uniform float uBrightness; //name "Brightness" default 10 min 0 max 20
    10. USE_TEXTURE2D(tEmissiveMask); //name "Emissive Mask"
    11. USE_TEXTURE2D(tScrollMask); //name "Scrolling Mask"
    12.  
    13. void ShaderExample1( inout FragmentState s )
    14. {
    15. float mask = texture2D(tEmissiveMask, s.vertexTexCoord);
    16. vec2 scrolling_uv = vec2(uCustomTime*uSpeed, 0.0) + s.vertexTexCoord;
    17. float light = texture2D(tScrollMask, scrolling_uv);
    18. s.emissiveLight = uColor*light*uBrightness*mask;
    19. }
    20.  
    21. //Use our function in the emissive slot.
    22. #ifdef Emissive
    23. #undef Emissive
    24. #endif
    25. #define Emissive ShaderExample1

    change line 16 to "vec2 scrolling_uv = vec2(0.0, uCustomTime*uSpeed) + s.vertexTexCoord;" to scroll in the y axis instead of x
  • EarthQuake
  • Hitsu San
    Offline / Send Message
    Hitsu San polycounter lvl 2
    This is great ! Thank you very much!
    here's a little addition

    change :
    line 7 with "uniform vec2 scroll; //name "Scroll" default 0, 0 min -5 max 5"
    and
    line 16 with " vec2 scrolling_uv = vec2(uCustomTime*scroll.x, uCustomTime*scroll.y) + s.vertexTexCoord;"

    This way you can choose x,y direction and the amount you imput equals the speed ;)

Sign In or Register to comment.