Highlight of items in the Game
- Ростислав Кейван
- Mar 8, 2024
- 1 min read
Hello everyone, fans of game creation, I found the time to write a short post about the highlight object shader in your projects.
If you create a game, you will need to meet the requirements of the gaming industry for your game to be accepted by players - this is the standard of success. One of the most important parts of gameplay aesthetics is its visual part. In this topic we will write a shader that highlights the player’s interactive object, this can be either an object that is located close to the player or levers on the level.
shader_type spatial;
render_mode unshaded, depth_draw_never;
uniform vec4 shine_color : source_color = vec4( 1.0, 1.0, 1.0, 1.0 );
uniform float cycle_interval : hint_range(0.5, 5.0) = 1.0;
uniform float shine_speed : hint_range(1.0, 5.0) = 3.0;
uniform float shine_width : hint_range(1.0, 100.0) = 3.0;
void fragment( )
{
vec3 vertex = ( INV_VIEW_MATRIX * vec4( VERTEX, 1.0 ) ).xyz;
float width = shine_width 0.001 cycle_interval;
float frequency = floor( sin( vertex.z cycle_interval + TIME shine_speed * cycle_interval ) + width );
ALBEDO = shine_color.rgb;
ALPHA = clamp( ( 1.0 - dot( NORMAL, VIEW ) ) frequency shine_color.a, 0.0, 1.0 );
}
That's it, in the end, you get this shader =)
Kommentarer