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 10
    I messed around a bit with example1.frag and I think I've got what you're looking for working.
    //provides FragmentState
    #include "../state.frag"
    
    //provides misc params like 'uCustomTime'
    #include "../other/customExtras.sh"
    
    uniform vec3 uColor;		//color  name "Color"  default 1.0, 0.35, 0.2
    uniform float uSpeed;		//name "Speed"  default 0.25  min 0  max 1
    uniform float uBrightness;		//name "Brightness"  default 10  min 0  max 20
    USE_TEXTURE2D(tEmissiveMask);		//name "Emissive Mask"
    USE_TEXTURE2D(tScrollMask);		//name "Scrolling Mask"
    
    void    ShaderExample1( inout FragmentState s )
    {
    	float mask = texture2D(tEmissiveMask, s.vertexTexCoord);
    	vec2 scrolling_uv = vec2(uCustomTime*uSpeed, 0.0) + s.vertexTexCoord;
    	float light = texture2D(tScrollMask, scrolling_uv);
        s.emissiveLight = uColor*light*uBrightness*mask;
    }
    
    //Use our function in the emissive slot.
    #ifdef Emissive
        #undef Emissive
    #endif
    #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.