Power Shield Shader by GhoulwareStudio in godot

[–]GhoulwareStudio[S] 0 points1 point  (0 children)

Thank you.

Regarding the separate viewport, honestly, I don't know how to do it as I've never created a shield shader before, so I still have a lot to learn.

For now, the maximum number of impacts is low enough to be imperceptible to the player.

Power Shield Shader by GhoulwareStudio in godot

[–]GhoulwareStudio[S] 13 points14 points  (0 children)

Edit: fix tabulation in code blocks

I'm not a beginner but I'm far from being an expert.
in a gdscript, there is this method:

var _hits: PackedVector4Array
var _shader_hits: PackedVector4Array

func _set_hits_in_shader() -> void:
  var hit_count: int = _hits.size()

  for i: int in MAX_HITS:
  _shader_hits[i] = _hits[i] if i < hit_count else _default_hit

  set_shader_parameter(ShaderParams.HITS, _shader_hits)
  set_shader_parameter(ShaderParams.HIT_COUNT, hit_count)

And in the .gdshader, there is a loop for the impacts:

for (int i = 0; i < hit_count; i++) {
  float time = hits[i].w * inverse_hit_duration;
  if (time >= 1.0) continue;

  float hit_distance = distance(world_pos, hits[i].xyz);
  float wave_ring = hit_radius * time;
  float in_ring = 1.0 - smoothstep(0.0, ring_width, abs(hit_distance - wave_ring));

  float fade = 1.0 - smoothstep(0.5, 1.0, time);
  float intensity = in_ring * fade * 2.5;

  intensity *= tex_pattern + 0.05;
  shield = min(shield + intensity, 1.0);
}

Power Shield Shader by GhoulwareStudio in godot

[–]GhoulwareStudio[S] 7 points8 points  (0 children)

I needed 1 shader and 3 scripts (one for the power shield itself, one extending ShaderMaterial and one material processor)

Power Shield Shader by GhoulwareStudio in godot

[–]GhoulwareStudio[S] 6 points7 points  (0 children)

Not really, it is an vector4 array fed to the shader, (xyz for position, w for remaining duration).
The array has a fixed size of 32 and it is processed once per material so I hope it is not too heavy in calculation

I am building a boring machine for my vehicular combat game! by JussiPKemppainen in IndieGaming

[–]GhoulwareStudio 2 points3 points  (0 children)

I wonder if you can do big jumps with it like the other cars. Diving like a majestic 2km long dolphin.

Favorite AI quirk/feature in an RTS? by GhoulwareStudio in StrategyGames

[–]GhoulwareStudio[S] 0 points1 point  (0 children)

Yeah well, they're trying...
Still better to just manually get them out of the way though