How to make a Highlight effect on Car headlamp

I have achieved the same effect as shown in this video

and this is the code

traverse_RightLeft_Effect = (count: number, texture: Texture) => {
texture.vOffset = 1.3;
texture.vScale = 12.0;
let speed = 0.008;
let currentCount: number = 0;

const PBRMat = new PBRMaterial('pbrMat', this.graphicsInstance.activeScene);
PBRMat.unlit = true;
PBRMat.albedoTexture = texture;

let glowMesh =

if (glowMesh) {
  glowMesh.material = PBRMat;

this.graphicsInstance.activeScene.onAfterRenderObservable.add(() => {
  while (currentCount < count) {
    texture.vOffset = texture.vOffset - speed;
    if (texture.vOffset < 0.8) {
      currentCount += 1;
      texture.vOffset = 1.3;
    if (currentCount === count) {
      texture.vOffset = 0.8;


Now my question is I want to achieve the below effect

the small glow ball which moves , how can I achieve this?

I think you can clone this mesh, new mesh set visible before glow render and set hidden after glow render (it only render to glow RTT, not render to the screen texture).

How can i make movement with the 2nd mesh?

you can create uv3 in blender, uv3’s X is from center side to outer side. you can create a customPBRMaterial instead of pbrmaterial then add an uniform vec2 showArea. in fragment_Main, if uv3 is in range of showArea discard pixel. or gl_FragColor*=step(showArea.x,uv3.x)*step(uv3.x,showArea) in fragment_mainEnd

you could use a custom texture for the emissive texture and use a glow layer. adding a uv offsets should help moving a brighter dot like around

Thanks will try this also, Right now I am just using the orange and black texture is there a way i can dynamically change the colour , so it can be white , red , orange etc

Got it just needed to change the texture to white and and add albedo colour(found out be tweaking in editor) as I had used albedo texture.

1 Like