This page looks best with JavaScript enabled

Sending Array's To Shaders - Lets Make an Energy Shield - Part 1

 ·   ·  ☕ 1 min read

    Lets start building a cool energy shield shader that can dynamically react to collisions and more. To begin we’ll be looking at how to pass collision information to our shield by sending an array of positions to our shader.

    In order to get this whole thing working we’ll send over object space positions that represent points on our object that have been hit. Then we will send that information to our shader. Once there our shader will transform its own world space coordinates to match the object space coordinates of our points. Then we’ll can identify if a collision occurred near the point. If so we’ll shade it red and if not we’ll do nothing. This allows us a simple way to add points to our sphere where we want.

    Want to learn more about passing arrays to shaders? Alan Zucconi goes into more depth and uses them to build a heatmap on top of a map with simple shaders:

    More about Homogeneous Coordinates and what they are used for:


    Sam Wronski
    Sam Wronski
    Maker of things, currently helping build cloud things @ Google. World of Zero is a personal project disconnected from my professional work. Lets make something awesome together!