Moo-Ack-Productions / MCprep

Blender python addon to increase workflow for creating minecraft renders and animations
https://theduckcow.com/MCprep
GNU General Public License v3.0
279 stars 26 forks source link

Add a Moon lamp when creating an MC Sky #112

Open TheDuckCow opened 4 years ago

TheDuckCow commented 4 years ago

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:

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

StandingPadAnimations commented 3 years ago

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 commented 1 year ago

I'll implement this in #334

TheDuckCow commented 1 year ago

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

StandingPadAnimations commented 1 year ago

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

TheDuckCow commented 1 year ago

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.

StandingPadAnimations commented 1 year ago

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 commented 1 year ago

Ok looks like EEVEE needs some work

StandingPadAnimations commented 1 year ago

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

StandingPadAnimations commented 1 year ago

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 commented 1 year ago

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

StandingPadAnimations commented 1 year ago

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 commented 1 year ago

EEVEE Sky Cycles Sky

TheDuckCow commented 1 year ago

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.

StandingPadAnimations commented 1 year ago

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)

TheDuckCow commented 1 year ago

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 commented 1 year ago

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.

StandingPadAnimations commented 1 year ago

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

TheDuckCow commented 1 year ago

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).

StandingPadAnimations commented 1 year ago

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.

TheDuckCow commented 1 year ago

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
StandingPadAnimations commented 4 months ago

Removing myself as the assignee. For anyone wanting to take up this task, see #370 for an attempt at this

TheDuckCow commented 4 months ago

Understood, np