Ask a simple question, get a simple answer

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
vanblam
Posts: 243
Joined: Sun Nov 09, 2014 12:15 am

Re: Ask a simple question, get a simple answer

Post by vanblam »

I guess I could just add another texture. My resource pack as is with out doing more optimization is around 200 MB. So I think I should be ok.
User avatar
vanblam
Posts: 243
Joined: Sun Nov 09, 2014 12:15 am

Re: Ask a simple question, get a simple answer

Post by vanblam »

Well I just found some textures I'm not using at all lol. Now its down to 159 MB :P
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

vanblam wrote: Sun May 12, 2019 1:32 am
minmay wrote: Sun May 12, 2019 1:24 am No, though again, you can try to fake it by using emissive color.
I was thinking about that, but it wont receive lighting correctly right?
The fragment will still be lit as normal, but the emissive color will be added to the fragment's color at the end. So it's somewhat unfriendly with lighting but not necessarily unusable, depending on how much emissive color you're using and how heavily you expect the model to be lit.
Remember that emissive color values can be negative; vec(0,-0.04,-0.04) will make the model appear redder without brightening it. Unfortunately, both negative and positive values will look silly when the lighting is low enough - positive values make the model appear to glow, and an emissive color of vec(0, -0.04, -0.04) will make the model's hue completely red in low lighting.

So in other words, yeah, you probably want to just use a new texture.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

vanblam wrote: Sun May 12, 2019 1:20 am Silly question, is there a way to change the tint on a materials diffuse in the definition? example: I want to add a little red to the "mine_pressure_plate" material in my own material definition with out adding a new texture, is that possible?
While imperfect, it is possible to use negative emissive color values. It comes with visual side effects, but you can decide if it's a good trade-off, and you have precise control over the color values... to balance the tint effect with the off lighting. In the video, as you'll see, the trees in the center clearing are tinted red, blue, and green. The negative values [for the most part] don't cause them to glow in the dark.
Image

The effect is better suited to simple objects rather than complex ones (like sets of trees), as the color will tint the entire object equally, everywhere.
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Ask a simple question, get a simple answer

Post by kelly1111 »

Isaac: could you please share the script for this?
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

kelly1111 wrote: Sun May 12, 2019 7:49 am Isaac: could you please share the script for this?
It's not really a script per se—I mean technically it is. minmay shows it above.

You just call the object's model component, and use the setEmissiveColor() function with negative values.

The values that I used for the trees are these:

Code: Select all

	forest_oak_cluster_1.model:setEmissiveColor(vec(-.025))
	forest_oak_cluster_2.model:setEmissiveColor(vec(-.01,-.005,-.05))
	forest_oak_cluster_3.model:setEmissiveColor(vec(0,0,-.01))
	forest_oak_cluster_4.model:setEmissiveColor(vec(-.025,-.01))
	forest_oak_cluster_5.model:setEmissiveColor(vec(-.01,-.025,-.06))
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

You can also include it directly in the component definition, which is particularly useful for minimalSaveState objects:

Code: Select all

{
	class = "Model",
	model = "mod_assets/models/env/goat_statue.fbx",
	emissiveColor = vec(0.04, -0.02, 0),
}
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: Ask a simple question, get a simple answer

Post by bongobeat »

I wonder how the "onInit" hook work?
Is it triggered on every loading or just once at the first loading and never used again?

per example on this object, it spawns another object:
I'm asking, because I want to add to it minimalSavestate = true , but I don't know if it is ok for that kind of object.

(the under_lava_effects is a tile damager, who has minimal... = true, the lava_volcano_eruption_ground is a particle that stays for a few seconds)
SpoilerShow

Code: Select all

    defineObject{
      name = "lava_effects",
      components = {
        { class = "Light",
          offset = vec(0, -0.5, 0),
          range = 6,
          color = vec(2.8, 1.2, 0.7),
          brightness = 10,
          castShadow = true,
          shadowMapSize = 64,
          staticShadows = true,
          staticShadowDistance = 0,   -- use static shadows always
        },
        { class = "Particle",
          particleSystem = "lava_effects",
          offset = vec(0, -0.4, 0),
        },
        {
          class = "TileDamager",
          attackPower = 3,
          damageType = "fire",
          repeatCount = math.huge,
          repeatDelay = 1,
          onInit = function(self)
            if self.go.map:getElevation(self.go.x, self.go.y) < self.go.elevation then
              spawn("under_lava_effects", self.go.level, self.go.x, self.go.y, self.go.facing, self.go.elevation-1)
            end
          end,
        },
        { class = "Timer",
          timerInterval = 1,
		currentLevelOnly = true,
          triggerOnStart = true,
          onActivate = function(self)
    for f = 0,3 do spawn("eruption", self.go.level, self.go.x, self.go.y, f, self.go.elevation) end
            self.go:playSound("magma_explosion")
            spawn("lava_volcano_eruption_ground", self.go.level, self.go.x, self.go.y, self.go.facing, self.go.elevation-1)
            self:setTimerInterval(300*(0.1+0.9*math.random()))
          end,
          onInit = function(self)
            self:setTimerInterval(300*math.random())
          end,
        },
        { class = "Sound",
          sound = "fire_pit",
          volume = 0.5,
        },
      },
      placement = "floor",
      editorIcon = 88,
    }
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

If the object has minimalSaveState then component onInit hooks will run every time the game is loaded, otherwise they will only run once.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: Ask a simple question, get a simple answer

Post by bongobeat »

ok, thanks!

so it's not a good idea to add on this object.
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
Post Reply