Page 1 of 1

[Solved] 1.1 draw_as_light, draw_as_glow, draw_as_sprite

Posted: Mon Nov 23, 2020 11:00 pm
by Deadlock989
Hi, would appreciate some pointers here pending wiki updates in time.

I am exploring some of the new rendering goodies in 1.1 and meeting with mixed success.

1. For vehicle lamps, there is a new light_animation prototype which contains a "draw_as_glow" parameter. What is draw_as_glow? I had pre-prepared some glowing lamp sprites for my vehicles but have only partial success with getting them working despite following the car prototype's example in entities.lua. Possibly I have messed something up but they work in the main animation as additive overlays. They barely appear in the light_animation for some reason. Some kind of premultiplication thing? Edited to add, in 1.1 it was a secondary layer order thing.

2. What is draw_as_sprite? I'm seeing it on the new furnace glows. It appears, if set to false in conjunction with draw_as_light, to stop the glow from appearing during the day. However I'm getting a significantly weaker result from draw_as_light = true with draw_as_sprite = false than I get with just draw_as_light. Not quite understanding this.

3. For the 1.0 working visualisations where you could set the draw_as_light property, I had a whole bunch of stuff which just ... worked. These were the kind of additive glows vanilla has used for some time in centrifuges and is now using on furnaces as well. For my labs, which don't have working_visualisations, I had prepared the same kind of additive glow and was just temporarily spamming them with a spotlight until 1.1 hit. Now I'm finding that these barely work at all as draw_as_light = true sprites in on_animation and off_animation. They do work exactly as expected if you "double draw" them - once as not a light and blend mode additive-soft, and again as a light. Looking at the vanilla's new lab sprites I can see that the lights are indeed drawn in the main non-light spritesheet as well as the extra glow overlay. But none of this doubling up is necessary for working_visualisations so I feel like there is some hole in my knowledge ...

Re: 1.1 draw_as_light, draw_as_glow, draw_as_sprite

Posted: Tue Nov 24, 2020 9:39 am
by Deadlock989
To illustrate what I'm talking about in question 3 above, see these four entities at midnight:

drawaslight.jpg
drawaslight.jpg (120.86 KiB) Viewed 4105 times

From left to right these are:

1. A lab, not switched on, for comparison - just the base layer (non-animated)
2. A lab, with an extra layer on top with draw_as_light = true and additive blend mode, defined last inside the Animation prototype
3. A lab, same as 2 above but additionally a draw_as_light = false additive-soft layer of exactly the same sprite, above the base layer but below the light layer
4. A furnace, same sprites as 2 above, except that the animation is inside a WorkingVisualisation with draw_as_light = true defined outside the Animation but inside the WorkingVisualisation table

3 and 4 are the effect I want and they are visually identical. But for entities with a WorkingVisualisation you can get there just by drawing the animated light layer once. For labs and generators and other stuff without a working vis I have to draw it twice, once as "something to light up" - a bit like how beams are currently. Presumably that's worse for FPS as well as additional faff.

Am I missing something / not understanding something?

Re: 1.1 draw_as_light, draw_as_glow, draw_as_sprite

Posted: Tue Nov 24, 2020 11:15 am
by Klonan
once as not a light and blend mode additive-soft, and again as a light.
In this case, you want to use 'draw_as_glow', which draws the animation first as a normal sprite, and again as a light layer

So for instance, the animation should be visible during the day, this is the normal sprite
However as night approaches, the animation should still be lit, this is the light layer

draw_as_glow is a shortcut for this use

Re: 1.1 draw_as_light, draw_as_glow, draw_as_sprite

Posted: Tue Nov 24, 2020 1:23 pm
by Deadlock989
Right, that works (in non-WV animations).

So the draw_as_light in WV is actually the same behaviour as draw_as_glow outside of it. And draw_as_glow outside of a WV is the same as draw_as_light + draw_as_sprite inside a WV. I mean, you can see why I got lost.

Re: 1.1 draw_as_light, draw_as_glow, draw_as_sprite

Posted: Tue Nov 24, 2020 1:57 pm
by Klonan
Deadlock989 wrote: Tue Nov 24, 2020 1:23 pm Right, that works (in non-WV animations).

So the draw_as_light in WV is actually the same behaviour as draw_as_glow outside of it. And draw_as_glow outside of a WV is the same as draw_as_light + draw_as_sprite inside a WV. I mean, you can see why I got lost.
In the working visualisations, the draw_as_light is saying "additionally draw this as a light", and you can also turn off the 'draw_as_sprite' with the separate bool.

Re: 1.1 draw_as_light, draw_as_glow, draw_as_sprite

Posted: Tue Nov 24, 2020 2:24 pm
by posila
Deadlock989 wrote: Tue Nov 24, 2020 1:23 pmSo the draw_as_light in WV is actually the same behaviour as draw_as_glow outside of it. And draw_as_glow outside of a WV is the same as draw_as_light + draw_as_sprite inside a WV. I mean, you can see why I got lost.
Yeah. In sprite definition, draw_as_light is consistent with draw_as_shadow, which makes the sprite to be drawn ... not as normal sprite. Then we decided to add also draw_as_glow, as opposed to having to define two layers almost everywhere, one with draw_as_light and other without.
We might remove draw_as_light and draw_as_sprite from WV, as it is redundant now. Actually Klonan wanted me to do that, but I forgot about it.

Re: 1.1 draw_as_light, draw_as_glow, draw_as_sprite

Posted: Tue Nov 24, 2020 2:28 pm
by Deadlock989
posila wrote: Tue Nov 24, 2020 2:24 pm We might remove draw_as_light and draw_as_sprite from WV, as it is redundant now. Actually Klonan wanted me to do that, but I forgot about it.
Makes sense to me. Would be consistent across different kinds of prototype, and would not break anything too hard (speaking purely for myself).

Re: [Solved] 1.1 draw_as_light, draw_as_glow, draw_as_sprite

Posted: Tue Nov 24, 2020 10:28 pm
by Deadlock989
I went ahead and removed all the draw_as_light properties from all of my WVs - now everything uses draw_as_glow (or draw_as_light in a couple of cases) within the actual animation prototypes regardless of entity type or whether it supports a WV. Much more consistent/reusable.

Re: 1.1 draw_as_light, draw_as_glow, draw_as_sprite

Posted: Wed Nov 25, 2020 12:33 am
by kirazy
posila wrote: Tue Nov 24, 2020 2:24 pm
Deadlock989 wrote: Tue Nov 24, 2020 1:23 pmSo the draw_as_light in WV is actually the same behaviour as draw_as_glow outside of it. And draw_as_glow outside of a WV is the same as draw_as_light + draw_as_sprite inside a WV. I mean, you can see why I got lost.
Yeah. In sprite definition, draw_as_light is consistent with draw_as_shadow, which makes the sprite to be drawn ... not as normal sprite. Then we decided to add also draw_as_glow, as opposed to having to define two layers almost everywhere, one with draw_as_light and other without.
We might remove draw_as_light and draw_as_sprite from WV, as it is redundant now. Actually Klonan wanted me to do that, but I forgot about it.
Speaking for myself, I'm not sure I'd like this.

I have an entity where when the machine is running, it is illuminated at night (strand casted heated metal), and when the machine is off, there is no illumination, e.g.:

Code: Select all

{
          draw_as_sprite = false,
          draw_as_light = true,
          animation = {
            filename = "__angelssmelting__/graphics/entity/strand-casting-machine/strand-casting-machine-light.png",
            priority = "high",
            width = 167,
            height = 197,
            shift = util.by_pixel(0, -16.5),
            hr_version = angelsmods.trigger.enable_hq_graphics and {
              filename = "__angelssmelting__/graphics/entity/strand-casting-machine/hr-strand-casting-machine-light.png",
              priority = "high",
              width = 329,
              height = 392,
              shift = util.by_pixel(0, -16.5),
              scale = 0.5
            } or nil
          }
It was necessary to do this because idle_animation for the assembling-machine prototype was not behaving as expected for machines with fluid boxes. If draw_as_light/draw_as_sprite are removed from WV, I don't know how to replicate current behavior.

Why not instead just unify behavior, so that draw_as_light/draw_as_glow have the same behavior in sprites and in wv?

Edit: Actually, you'd just move them into the animation definition instead, wouldn't you. Nevermind, I get it.

Re: [Solved] 1.1 draw_as_light, draw_as_glow, draw_as_sprite

Posted: Mon Sep 27, 2021 4:18 pm
by demongo
is there a simple way with the new system to have a static entity(no-animations like a pole) to emit a soft glow/light? tring to make a building emit a small glow/light but im not getting any results:

Code: Select all

  {
    type = "electric-pole",
    name = "pylon1",
    icon = "__Pylons__/icons/SP1.png",
	icon_size = 128,
    flags = {"placeable-neutral", "player-creation"},
	minable = {hardness = 0.2, mining_time = 1, result = "pylon1"},
    max_health = 200,
    corpse = "medium-remnants",
	track_coverage_during_build_by_moving = true,
    resistances = 
    {
      {
        type = "fire",
        percent = 100
      }
    },
    collision_box = {{-.45, -.9}, {.45, .9}},
    selection_box = {{-.45,-.9}, {.45,.9}},
    drawing_box = {{-0.45, -0.8}, {0.45, 0.8}},
    draw_as_glow = {intensity = 3, size = 3, color = {r=0.4, g=0.8, b=1.2}},
    maximum_wire_distance = 10.5,
    supply_area_distance = 5,
    fast_replaceable_group = "SP",
    pictures =
	{
      filename = "__Pylons__/graphics/SP1.png",
      priority = "high",
      width = 256,
      height = 256,
	  scale = 0.2,
      axially_symmetrical = true,
      direction_count = 1,
	  shift = {0, -0}
    },
    connection_points =
    {
      {
        shadow =
        {
          copper = {0, 0},
          green = {0, 0},
          red = {0, 0}
        },
        wire =
        {
          copper = {0, 0},
          green = {0, 0},
          red = {0, 0}
        }
      }
    },
    copper_wire_picture =
    {
      filename = "__Pylons__/graphics/nothing.png",
      priority = "extra-high-no-scale",
      width = 4,
      height = 4
    },
    green_wire_picture =
    {
      filename = "__Pylons__/graphics/nothing.png",
      priority = "extra-high-no-scale",
      width = 4,
      height = 4
    },
    radius_visualisation_picture =
    {
      filename = "__base__/graphics/entity/small-electric-pole/electric-pole-radius-visualization.png",
      width = 12,
      height = 12,
      priority = "extra-high-no-scale"
    },
    red_wire_picture =
    {
      filename = "__Pylons__/graphics/nothing.png",
      priority = "extra-high-no-scale",
      width = 4,
      height = 4
    },
    wire_shadow_picture =
    {
      filename = "__Pylons__/graphics/nothing.png",
      priority = "extra-high-no-scale",
      width = 4,
      height = 4
    }
  },

Re: [Solved] 1.1 draw_as_light, draw_as_glow, draw_as_sprite

Posted: Mon Sep 27, 2021 4:19 pm
by demongo
ive tried draw as light and glow and got no difference...

Re: [Solved] 1.1 draw_as_light, draw_as_glow, draw_as_sprite

Posted: Mon Sep 27, 2021 5:11 pm
by Silari
draw_as_glow/light isn't a property of entities, so adding it there does nothing. It only works as a property to the pictures layer.

Not having used the property at all myself, from the documentation it looks like you'd need to add a layer to pictures with that property and a png for the glow you want to add. Accumulators and boilers do it that way for their animations.