[ad_1]
Here’s an instance of how we are able to mimic this look in a Unity scene:
My technique is:
-
First, compose the picture that the POV show is attempting to venture.
-
Render that picture, with a shader filter that provides artifacts that appear like a POV show.
On the left is step 1. I’ve positioned some sprites representing my clock face and fingers. That approach it is simple to replace the displayed picture: I can simply rotate the sport objects representing the fingers.
I created a brand new RenderTexture in my property folder, referred to as “Clock Face”. Because the POV show is kind of low-res, you may get away with a tiny texture right here.
Next I made a Camera that appears at these sprites, and outputs the mixed picture to the RenderTexture. You can put the sprites in a layer that solely that digital camera sees, in order that they’re invisible to your primary scene digital camera.
Lastly I made a quad to show the POV model. I gave that quad a brand new materials, with a customized shader, utilizing the RenderTexture as its Main Texture enter.
Here’s the shader I cooked up:
Shader "Unlit/POVDisplay"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
// Render with clear objects, after the opaque go.
Tags { "RenderSort"="Transparent" "Queue"="Transparent"}
LOD 100
// Don't write to the depth buffer.
ZWrite Off
// Additive mixing (add gentle/glow).
Blend One One
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#embody "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
// Shift our texture coordinates so 0 is within the middle,
// and we go to -1 ... +1 on the edges.
o.uv = (v.uv - 0.5f) * 2.0f;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
// Vary this parameter to regulate what number of rings of sunshine you get.
const float ledCount = 32;
// Simulate the strip of LEDs spinning round very quick.
float headAngle = _Time.y * 7.0f;
// Compute the angle of the pixel we're rendering.
float angle = atan2(i.uv.y, i.uv.x);
// Compute how not too long ago we have been illuminated.
// 0 = head is about to succeed in us (1 full cycle behind).
// 1 = head simply reached us.
float distinction = frac(headAngle + angle / (2.0f * 3.141592653589f));
// The approaching LED head shines gentle on the light components close by,
// so brighten them again as much as 1.
if (distinction < 0.1f)
distinction = 1.0f - 9.0f * distinction;
// Small timing errors make the show appear to twist/wobble,
// so we'll distort our angle a bit to imitate this.
angle += 0.01f * sin(_Time.y * 2.0f + distinction * 1.0f);
// Compute our radius in "LED area"
float radius = size(i.uv) * ledCount;
// Round to the closest LED.
float rounded = spherical(radius);
// Compute a pattern level in our texture, utilizing our distorted angle
// and rounded radius.
float2 samplePoint = float2(cos(angle), sin(angle))*rounded/ledCount;
// Sample the RenderTexture at this place.
fixed4 col = tex2D(_MainTex, samplePoint / (2.0f) + 0.5f);
// Square the color to extend saturation, like a pure LED gentle.
col *= col;
// The middle of the LED is brighter. Fade it within the gaps between rings.
float brightness = (radius - rounded) * 2.0f;
brightness = 1.0f - brightness * brightness;
// Brighten/darken the color primarily based on proximity to the ring,
// and lag behind the spinning head.
return col * brightness * lerp(9.0f, 1.0f, distinction);
}
ENDCG
}
}
}
If we scale down our _Time.y enter, we are able to see what this seems to be like in slow-mo:
Advancing our digital “LED Head” quicker than the show framerate makes the brightest a part of the sweep bounce round nearly randomly, giving that particular flickering look.
[ad_2]

