create Unnity URP HLSL shader, that can show pulsing effect over spatial mapping mesh
- User
create Unnity URP HLSL shader, that can show pulsing effect over spatial mapping mesh
- Assistant
Here is an example of a Unity URP HLSL shader that can create a pulsing effect over a spatial mapping mesh:
codeShader "Custom/Pulse" { Properties { _MainTex ("Albedo (RGB)", 2D) = "white" {} _PulseSpeed ("Pulse Speed", Float) = 1.0 } SubShader { Tags {"Queue"="Transparent" "RenderType"="Transparent"} LOD 200 CGPROGRAM #pragma surface surf Lambert sampler2D _MainTex; float _PulseSpeed; struct Input { float2 uv_MainTex; }; void surf (Input IN, inout SurfaceOutput o) { fixed4 col = tex2D(_MainTex, IN.uv_MainTex); o.Albedo = col.rgb; o.Alpha = col.a * (0.5 + 0.5 * sin(_Time.y * _PulseSpeed)); } ENDCG } FallBack "Diffuse" }This shader uses the
sin()function to create a pulsing effect on the object's transparency. The_PulseSpeedproperty can be adjusted in the Unity editor to control the speed of the pulse.You can apply this shader to the spatial mapping mesh and adjust the properties to get the desired effect.
- User
add origin point in world space
- Assistant
Here is an updated version of the HLSL shader that allows you to specify an origin point in world space for the pulsing effect:
codeShader "Custom/Pulse" { Properties { _MainTex ("Albedo (RGB)", 2D) = "white" {} _PulseSpeed ("Pulse Speed", Float) = 1.0 _Origin ("Origin", Vector) = (0,0,0,0) } SubShader { Tags {"Queue"="Transparent" "RenderType"="Transparent"} LOD 200 CGPROGRAM #pragma surface surf Lambert sampler2D _MainTex; float _PulseSpeed; float4 _Origin; struct Input { float2 uv_MainTex; float4 worldPos; }; void surf (Input IN, inout SurfaceOutput o) { fixed4 col = tex2D(_MainTex, IN.uv_MainTex); o.Albedo = col.rgb; float dist = distance(IN.worldPos, _Origin); o.Alpha = col.a * (0.5 + 0.5 * sin((_Time.y + dist) * _PulseSpeed)); } ENDCG } FallBack "Diffuse" } - User
add pulse color and ability to control where pulse in located in world space
- Assistant
Here is an updated version of the HLSL shader that allows you to specify a pulse color and control where the pulse is located in world space:
code
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.