MCprep icon indicating copy to clipboard operation
MCprep copied to clipboard

Add a Moon lamp when creating an MC Sky

Open TheDuckCow opened this issue 5 years ago • 22 comments

Right now when creating an MC Sky (previously called MC World), only a single sun lamp is added. The request was made to also add a sun lamp or whatever appropriate for the moon as well.

Possible behaviors to decide on:

  • Only include the Moon lamp if either shader or physical sun/moons are added
  • Have a tick box (default on? Defaulted off?) that explicitly adds the moon lamp. (I'm thinking this is unnecessary, someone can always just delete the moon lamp if they don't want it)
  • Similar shading as the sun lamp, with shadows? Soft shadows? No shadows, acting more like a hemi lamp?

Will need to experiment and also see what adverse effects it could have on daylight-only scenes with the different default settings.

TheDuckCow avatar Apr 11 '20 22:04 TheDuckCow

I think it's a good idea. Generally, the moon has very soft shadows and isn't too bright(maybe about 200 lumens as it just reflects light). I also think the sun in the sky should be brighter (maybe 5-10 watts)

StandingPadAnimations avatar Apr 13 '21 13:04 StandingPadAnimations

I'll implement this in #334

StandingPadAnimations avatar Sep 15 '22 16:09 StandingPadAnimations

hey @StandingPadAnimations did you end up making this change at some point? regardless no worries, for this one I'm deferring it to MCprep 3.4.3 (or later) anyways

TheDuckCow avatar Jan 30 '23 03:01 TheDuckCow

I'll work on this in Kaion and see if I can get a working implementation by the next release (hopefully in mid-Feburary)

StandingPadAnimations avatar Jan 30 '23 04:01 StandingPadAnimations

That'd be awesome. One reason I've been dragging my feet on this one, is I really want to ensure that the sun/moon lamps smoothly turn off and are disabled when underneath the horizon. A driver can safely address this, but the change mostly needs to be in the source blend files for the eevee and standard version.

TheDuckCow avatar Jan 30 '23 07:01 TheDuckCow

I've noticed there's already a moonlamp in MCprep, so I'm working on the drivers (and editing the sun lamp to be more representative of the real sun). This is actually all that's needed: image

StandingPadAnimations avatar Jan 31 '23 02:01 StandingPadAnimations

Ok looks like EEVEE needs some work

StandingPadAnimations avatar Jan 31 '23 02:01 StandingPadAnimations

Actually the drivers are wrong as frick, I need to look into this more

StandingPadAnimations avatar Jan 31 '23 02:01 StandingPadAnimations

Looks like we can make the driver only go between the values 0 and 24, but implementing that will prove to be a challenge

StandingPadAnimations avatar Jan 31 '23 02:01 StandingPadAnimations

Alternatively (and likely the easier route) we could implement a new property that returns the hour

StandingPadAnimations avatar Jan 31 '23 02:01 StandingPadAnimations

Ight, I've completed this. This will be coming to MCprep Kaion in the next couple of weeks/days, depending on how everything else goes (I've also sent the files on Discord)

StandingPadAnimations avatar Jan 31 '23 02:01 StandingPadAnimations

is this reasonable to get ready before the 3.5.0 release @StandingPadAnimations? I'm refining the milestone to aim for a nearer-term release.

TheDuckCow avatar Jul 05 '23 00:07 TheDuckCow

Yep, I just need to have MCprep generate embedded text files and it'll be done (I should also make a more in depth document on how the equations were derived, not a blocker though)

StandingPadAnimations avatar Jul 05 '23 00:07 StandingPadAnimations

Yep, I just need to have MCprep generate embedded text files and it'll be done (I should also make a more in depth document on how the equations were derived, not a blocker though)

Great - we do this already for rigs which come with scripts, feel free to borrow or improve from that mob-import logic. Documentation would be nice to have, can iterate on if not ready right away though.

TheDuckCow avatar Jul 05 '23 00:07 TheDuckCow

Is this working as you expect when you use the Create Sky function in MCprep, off this branch? I'm using your files most recently linked in the issue, but for both eevee and cycles only the sun lamp comes through, and I'm not exactly sure why. The moon lamp is in the same import ground, and has the same parent etc. Anyhow, it would be good to have you confirm if it's working in the actual compiled MCprep flow for you, or if it's just the driver working in isolation.

Sorry this one is dragging on, I was hoping to approve but I can't until i see it working.

TheDuckCow avatar Jul 17 '23 03:07 TheDuckCow

I did notice recently on my end that the moon lamp wasn't appended either, and I'm not sure why. I'll have to check with stock MCprep to rule out if it was a Blender change

StandingPadAnimations avatar Jul 17 '23 03:07 StandingPadAnimations

I wouldn't be surprised if we hard code look for the names of certain objects while importing, but a quick search against "sun" didn't seem to show that was the case (other than where we generate a sun if they choose the non imported option).

TheDuckCow avatar Jul 17 '23 04:07 TheDuckCow

Also seems to occur in stock MCprep. I can't tell what's going on in the sky creation code but it does seem like we're not appending or creating a moon lamp. I did find this:

	def create_sunlamp(self, context):
		"""Create new sun lamp from primitives"""
		if hasattr(bpy.data, "lamps"):  # 2.7
			newlamp = bpy.data.lamps.new("Sun", "SUN")
		else:  # 2.8
			newlamp = bpy.data.lights.new("Sun", "SUN")
		obj = bpy.data.objects.new("Sunlamp", newlamp)
		obj.location = (0, 0, 20)
		obj.rotation_euler[0] = 0.481711
		obj.rotation_euler[1] = 0.303687
		obj.rotation_euler[1] = 0.527089
		obj.data.energy = 1.0
		# obj.data.color
		util.obj_link_scene(obj, context)
		util.scene_update(context)
		if hasattr(obj, "use_contact_shadow"):
			obj.use_contact_shadow = True
		return obj

So it seems like we're creating a sun lamp but not a moon lamp. I've checked with both telescope.nvim and fzf and I don't see any references to appending an object called sun (which is the name of the sun lamp that is appended), but maybe I've missed something.

StandingPadAnimations avatar Jul 17 '23 04:07 StandingPadAnimations

Yeah that create_sunlamp function is for when the user chooses one of the "static sky" options, and thus wouldn't have the drivers and everything anyways. It also does not animate the sun in that scenario, it's just a fixed position.

Screen Shot 2023-07-16 at 9 55 34 PM

TheDuckCow avatar Jul 17 '23 04:07 TheDuckCow