How can i disable backface cull for my entity

Post Reply
User avatar
Drachenbauer32
Member
Posts: 105
Joined: Wed Aug 28, 2019 18:11

How can i disable backface cull for my entity

by Drachenbauer32 » Post

Hello

i have got a hot air balloon entity.
it uses a node with an *.obj (wavefront) -model as it´s visualisation

Now i want to use a texture with transparent parts at the bottom of the balloon-hull (because real hot air balloons have a hole there).
I think, it will look more realistic, if the player can see the inside of the hull from below.

so my question is, how can i disable backface cull for this specific entity (other entities and nodes can stay backface culled)

I tryed to put the texture for the node (the visualisation of the entity) like this:

Code: Select all

tiles = {
        {
            name = "hotair_" .. name .. ".png",
            backface_culling = false,
        }
    },
But it still shows no insides of this model.

User avatar
Drachenbauer32
Member
Posts: 105
Joined: Wed Aug 28, 2019 18:11

Re: How can i disable backface cull for my entity

by Drachenbauer32 » Post

This is how it looks like in blender:
Image
from this perspective you can see the insides of the orange and yellow hull-slices.

but in the game just the sky appears there.

I want it look like in this blender screenshot.
Attachments
balloon.png
balloon.png (173.42 KiB) Viewed 1484 times

User avatar
Kimapr
Member
Posts: 32
Joined: Fri May 24, 2019 15:53
GitHub: Kimapr
IRC: Kimapr
In-game: Kimapr

Re: How can i disable backface cull for my entity

by Kimapr » Post

I don't think you can do that with Minetest without editing sources. A simple workaround is to duplicate all faces of the object with opposite normals
Ek59C88tAsaQuRAw6PCPsGFDozj1FuZ4

User avatar
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

Re: How can i disable backface cull for my entity

by GreenXenith » Post

Set backface_culling = false in the entity properties.
https://github.com/minetest/minetest/bl ... .txt#L6038
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

User avatar
Drachenbauer32
Member
Posts: 105
Joined: Wed Aug 28, 2019 18:11

Re: How can i disable backface cull for my entity

by Drachenbauer32 » Post

GreenDimond wrote:Set backface_culling = false in the entity properties.
https://github.com/minetest/minetest/bl ... .txt#L6038
makes no difference (even, if i use it for the entity and for the texture of the used node-model).

Does it work only with a .b3d-mesh as the model for the entity?
i use a node with a .obj-mesk as the model (i noticed, with this, the different faces of the model get different light and shadow-shadings and look more realistic, in a .b3d all faces get exact the same shading deep, and it looks flat).

User avatar
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

Re: How can i disable backface cull for my entity

by GreenXenith » Post

Drachenbauer32 wrote:
GreenDimond wrote:Set backface_culling = false in the entity properties.
https://github.com/minetest/minetest/bl ... .txt#L6038
makes no difference (even, if i use it for the entity and for the texture of the used node-model).

Does it work only with a .b3d-mesh as the model for the entity?
i use a node with a .obj-mesk as the model (i noticed, with this, the different faces of the model get different light and shadow-shadings and look more realistic, in a .b3d all faces get exact the same shading deep, and it looks flat).
It should work on any entity regardless of visual/mesh type. If you could post the relevant code that might be helpful.
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

User avatar
Drachenbauer32
Member
Posts: 105
Joined: Wed Aug 28, 2019 18:11

Re: How can i disable backface cull for my entity

by Drachenbauer32 » Post

This is the code for my hot air balloon-set:

Code: Select all

dofile(minetest.get_modpath("hotairballoons") .. "/config.lua")

local function get_sign(i)
    if i == 0 then
        return 0
    else
        return i / math.abs(i)
    end
end

local designs = {
    { "rainbow_1",     "Rainbow Hot Air Balloon Type 1",     "rainbow",     "hotairballoon.obj" },
    { "rainbow_2",     "Rainbow Hot Air Balloon Type 2",     "rainbow",     "hotairballoon.obj" },
    { "four_colors_1", "Four Colors Hot Air Balloon Type 1", "four_colors", "hotairballoon.obj" },
    { "four_colors_2", "Four Colors Hot Air Balloon Type 2", "four_colors", "hotairballoon.obj" },
    { "stella_1",      "Stella Hot Air Balloon Type 1",      "stella",      "hotairballoon_stella.obj" },
    { "stella_2",      "Stella Hot Air Balloon Type 2",      "stella",      "hotairballoon_stella.obj" }
}

for i = 1, #designs do
    local name, description, inv_image, mesh = unpack(designs[i])

    local balloon = {
        textures = { "hotairballoons:hotair_node_" .. name },
        visual = "item",
        visual_size = { x = 0.667, y = 0.667 },
        backface_culling = false,
        physical = true,
        collisionbox = { -1, -0.5, -1, 1, 0.5, 1 },
        collide_with_objects = true,
        driver = nil,
        yaw = 0,
        vx = 0,
        vy = 0,
        vz = 0,
    }

    function balloon:on_rightclick(clicker)
        if not clicker or not clicker:is_player() then
            return
        end
        local name = clicker:get_player_name()
        if self.driver and clicker == self.driver then
            clicker:set_detach()
            self.driver = nil
            default.player_attached[name] = false
            default.player_set_animation(clicker, "stand", 10)
            if hotairballoon.one_use == true then
                self.object:remove()
            end
        elseif not self.driver then
            self.driver = clicker
            clicker:set_attach(self.object, "", { x = -4, y = 10.1, z = 0 }, { x = 0, y = 90, z = 0 })
            default.player_attached[name] = true
            minetest.after(0.2, function()
                default.player_set_animation(clicker, "sit", 10)
            end)
            self.object:setyaw(clicker:get_look_yaw() - math.pi / 2)
        end
    end

    function balloon:on_activate(staticdata, dtime_s)
        self.object:set_armor_groups({ immortal = 1 })
        if staticdata then
            self.v = tonumber(staticdata)
        end
    end

    function balloon:on_punch(puncher, time_from_last_punch, tool_capabilities, direction)
        if not self.driver then self.object:remove() end
        if puncher and puncher:is_player() and not self.driver and not minetest.setting_getbool("creative_mode") then
            puncher:get_inventory():add_item("main", "hotairballoons:hotair_" .. name)
        end
    end

    function balloon:on_step(dtime)
        if self.driver then
            self.yaw = self.driver:get_look_yaw()
            local yaw = self.object:getyaw()
            self.vx = self.object:getvelocity().x
            self.vy = self.object:getvelocity().y
            self.vz = self.object:getvelocity().z
            local ctrl = self.driver:get_player_control()
            --Forward/backward
            if ctrl.up then
                self.vx = self.vx + math.cos(yaw) * 0.4
                self.vz = self.vz + math.sin(yaw) * 0.4
            end
            if ctrl.down then
                self.vx = self.vx - math.cos(yaw) * 0.4
                self.vz = self.vz - math.sin(yaw) * 0.4
            end
            --Left/right
            if ctrl.left then
                self.object:setyaw(self.object:getyaw() + math.pi / 60 + dtime * math.pi / 60)
            end
            if ctrl.right then
                self.object:setyaw(self.object:getyaw() - math.pi / 60 - dtime * math.pi / 60)
            end
            --up/down
            if ctrl.jump then
                if self.vy < 1.5 then
                    self.vy = self.vy + 0.3
                end
            end
            if ctrl.sneak then
                if self.vy > -1.5 then
                    self.vy = self.vy - 0.6
                end
            end
            --
        end
        if self.vx == 0 and self.vz == 0 and self.vy == 0 then
            return
        end
        --Decelerating
        local sx = get_sign(self.vx)
        self.vx = self.vx - 0.02 * sx
        local sz = get_sign(self.vz)
        self.vz = self.vz - 0.02 * sz
        local sy = get_sign(self.vy)
        self.vy = self.vy - 0.01 * sy

        --Stop
        if sx ~= get_sign(self.vx) then
            self.vx = 0
        end
        if sz ~= get_sign(self.vz) then
            self.vz = 0
        end
        if sy ~= get_sign(self.vy) then
            self.vy = 0
        end

        --Speed limit
        if math.abs(self.vx) > 87 then
            self.vx = 87 * get_sign(self.vx)
        end
        if math.abs(self.vz) > 87 then
            self.vz = 87 * get_sign(self.vz)
        end
        if math.abs(self.vy) > 87 then
            self.vz = 87 * get_sign(self.vy)
        end

        self.object:setvelocity({ x = self.vx, y = self.vy, z = self.vz })
    end

    minetest.register_entity("hotairballoons:hotair_" .. name, balloon)

    minetest.register_craftitem("hotairballoons:hotair_" .. name, {
        description = description,
        inventory_image = "hotair_" .. inv_image .. "_inv.png",
        wield_image = "hotair_" .. inv_image .. "_inv.png",
        liquids_pointable = false,
        on_place = function(itemstack, placer, pointed_thing)
            if pointed_thing.type ~= "node" then
                return
            end
            if minetest.get_node(pointed_thing.above).name ~= "air" then
                return
            end
            pointed_thing.under.y = pointed_thing.under.y + 1
            minetest.add_entity(pointed_thing.under, "hotairballoons:hotair_" .. name)
            if not minetest.setting_getbool("creative_mode") then
                itemstack:take_item()
            end
            return itemstack
        end,
    })

    minetest.register_node("hotairballoons:hotair_node_" .. name, {
        description = description,
        tiles = {
            {
                name = "hotair_" .. name .. ".png",
                backface_culling = false,
            },
        },
        paramtype = "light",
        drawtype = "mesh",
        mesh = mesh,
        groups = { not_in_creative_inventory = 1 },
    })
end
Someone created a simple hot air balloon from a flying carpet mod, created by a third person.

i modifyed the model for better proportions (balloon bigger, in relation to the basket) and added a seccond, more specific model for a balloon, that looks like Stella, the pink bird from the "Angry Birds".
Stella is my favorite character from theese birds, and in the classic version (not the movie) she is round, just like most members of the flock.
So i thaught, she can be a good design for a hot air balloon.

for all designs i created a texture with the realistic looking open bottom area of the balloon-hull.

And i use a node with a .obj-mesh as visualisation, because it has a better shading then directly using a .b3d-mesh.
I use this variant .for all vehicle-entities (living entities are another thing, because they need an animation-skeleton).
Last edited by Drachenbauer32 on Sat Oct 19, 2019 17:14, edited 1 time in total.

User avatar
Drachenbauer32
Member
Posts: 105
Joined: Wed Aug 28, 2019 18:11

Re: How can i disable backface cull for my entity

by Drachenbauer32 » Post

Did i make something wrong about backface culling in this code?

User avatar
Drachenbauer32
Member
Posts: 105
Joined: Wed Aug 28, 2019 18:11

Re: How can i disable backface cull for my entity

by Drachenbauer32 » Post

I still need help here.

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: How can i disable backface cull for my entity

by runs » Post

Try in Blender: Edit > Mesh panel you see there is a big button with “Double Sided”.

User avatar
Drachenbauer32
Member
Posts: 105
Joined: Wed Aug 28, 2019 18:11

Re: How can i disable backface cull for my entity

by Drachenbauer32 » Post

I cannot find a Mesh panel under "Edit" in my blender...
I use Blender 2.80.
I find an Object Data panel, that has a green mesh-icon in front of it, but it has no "Double Sided" button there.

I found out, that there is a checkbox "Backface Culling" under Materials.
But it has no effect on how it appears in the game.


User avatar
Drachenbauer32
Member
Posts: 105
Joined: Wed Aug 28, 2019 18:11

Re: How can i disable backface cull for my entity

by Drachenbauer32 » Post

I´m looking for the reason, why backface_culling = false does not work for my model.

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: How can i disable backface cull for my entity

by runs » Post

Drachenbauer32 wrote:I´m looking for the reason, why backface_culling = false does not work for my model.
put your model here.

User avatar
Drachenbauer32
Member
Posts: 105
Joined: Wed Aug 28, 2019 18:11

Re: How can i disable backface cull for my entity

by Drachenbauer32 » Post

Now i made a github-repository from my hotairballoons mod:
https://github.com/Drachenbauer/hotairballoons

You find the models in the models-folder.
There is a simple classic shaped hot air balloon and two character-special-shape-balloons.
The displayed characters are:
1. Stella from the Angry Birds
2. Coral from the Fruit Nibblers (another game from the creator of Angry Birds)
For the character-balloons the blend files with "huge size" in the name are my working files, because so i was able to model the extra deteils with more clear vertex position values.
after saving i scaled them down to ingame size and saved them under the names with "node"
theese files have the same scale for all three variants and i exported them to the .obj-files, wich are used in the game.

User avatar
Drachenbauer32
Member
Posts: 105
Joined: Wed Aug 28, 2019 18:11

Re: How can i disable backface cull for my entity

by Drachenbauer32 » Post

Did you look at my models and find the reason, why disable backface-culling not work?

User avatar
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

Re: How can i disable backface cull for my entity

by GreenXenith » Post

Drachenbauer32 wrote:Did you look at my models and find the reason, why disable backface-culling not work?
I would, but the GitHub link is now dead. I can take a look whenever you reupload the models/mod.
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

User avatar
sirrobzeroone
Member
Posts: 593
Joined: Mon Jul 16, 2018 07:56
GitHub: sirrobzeroone
Contact:

Re: How can i disable backface cull for my entity

by sirrobzeroone » Post

Noting this for others who may google and find this thread:
I can't be 100% sure but I believe for "mesh" type for an entity backface culling may not be working. However I need to do a super simple plane and check as this could also be an issue with blenders b3d exporter as last time I did a plane from blender for obj file it worked fine. That was however a mesh for a node not entity not that I think MT engine cares to much at that level - Hence the testing needed

Workaround that definitly works for blender which is mentioned above (assuming its not that a complex face hasn't been triangulated):

All in Edit mode
  • Select your plane - Ctrl-L to select all linked faces if it's triangulated
  • Duplicate plane - Shift-D and confirm place (you'll have to planes ontop of each other)
  • Grab plane - G, lock to axis press X or Y or Z
  • Manually type in a low number eg for neg Z -0.001 super close
  • Flip Normals - Alt N then flip or Mesh >> Normals >> Flip
  • Change back to object mode and export model to b3d
Using duplicate also keeps any weight painting etc you may have done for animating/rigging so minimal messing around with adjusting any animations it'll follow whatever you have currently done.

As I mentioned though not convinced this is an MT engine bug it could easily be a problem in Blender B3D exporter which is doing "something" - sorry I only dabble Nathan/GreenXenith may have more idea than me.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests