0
\$\begingroup\$

I have an effect where a character has a small tool that emit a sort of scanning effect to detect some property of an object. My FX is simple as it uses a pyramidal mesh whose top is positioned where the object emit the scan and there is a simple horizontal rotation. The scanning effect itself is made using an animated texture (uv displacement) with an alpha channel. I'm not fully happy with the smoothness of the visual result.

Screen shot of the scan effect

All the scan demo I found are apparently post process (defered shaders I guess) and are simulating a "foggy wave" of some color like this one. I would like to find an effect that emit a conic volume representing the scan effect instead of showing a scan wave on the enivronment itself, and possibly for forward rendering. I can increase the number of faces on my "squared cone" if required to have a better looking cone.

\$\endgroup\$
2
  • \$\begingroup\$ "Where to find examples" is generally a question for a search engine. What we can help you with here is "how to MAKE a scanning effect". Try explaining in more detail how you want your effect to work/look, maybe with mock-ups or reference images from sci-fi scanners you like. Then folks here can suggest how to make an effect that matches your target, rather than just pointing you at the closest existing match they can find. \$\endgroup\$ Commented Oct 14 at 11:39
  • \$\begingroup\$ You may also be interested in "chroma-depth shader in Unity" \$\endgroup\$ Commented Oct 14 at 11:43

1 Answer 1

1
\$\begingroup\$

You can increase the roundness by doing path tracing in the fragment shader by stepping deeper into the volume until you hit the actual cone and then using that distance of the found point from the point of the cone to adjust the aplha/animation.

In psuedocode the shader would look like:

vec3 position = ...; //the position of the fragment vec3 direction = normalized(position - cameraPos); float lastDist = 1000; for(int i = 0; i < PATH_TRACE_LIMIT && dist>0.01; i++){ float dist = sdfCone(conePoint, ConeDirection, ConeAngle, position); if(dist > lastDist) discard(); // we missed the cone position+=direction*dist; lastDist = dist; } float distFromConePoint = length(conePoint, position); // assign new depth to fragment.z //use distFromConePoint to map the animation. 

position, cameraPos, conePoint, ConeDirection must all be in the same space.

sdfCone is a function that returns a positive result when the position is outside the cone and negative when it's inside the cone based on how far the position is to the cone.

\$\endgroup\$
2
  • \$\begingroup\$ maybe using the cone parameterized equation should be simpler and to avoid the loop? Which could be similar to a spotlight equation? \$\endgroup\$ Commented Oct 15 at 15:28
  • \$\begingroup\$ At the end using a more well-defined circular cone and a texture similar to the one pointed by DMGregory gives me something satisfying. \$\endgroup\$ Commented Oct 24 at 9:38

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.