How can i disable backface cull for my entity

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

How can i disable backface cull for my entity

by Drachenbauer32 » Tue Oct 08, 2019 14:27

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: 104
Joined: Wed Aug 28, 2019 18:11

Re: How can i disable backface cull for my entity

by Drachenbauer32 » Wed Oct 09, 2019 14:23

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
(173.42 KiB) Not downloaded yet
 

User avatar
Kimapr
Member
 
Posts: 19
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 » Wed Oct 09, 2019 16:01

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
GreenDimond
Member
 
Posts: 1273
Joined: Wed Oct 28, 2015 01:26
Location: SCP-3008
GitHub: GreenXenith
IRC: GreenDimond
In-game: GreenDimond

Re: How can i disable backface cull for my entity

by GreenDimond » Wed Oct 09, 2019 16:46

Set backface_culling = false in the entity properties.
https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L6038
Y▹uTube | Mods | Patre●n | Twitter | Minetest Discord | GreenDimond#3232

Hey, you. You're finally awake.
You were trying to view their profile, right? Found the rest of their signature, same as us, and that guest over there.
 

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

Re: How can i disable backface cull for my entity

by Drachenbauer32 » Thu Oct 10, 2019 14:29

GreenDimond wrote:Set backface_culling = false in the entity properties.
https://github.com/minetest/minetest/blob/master/doc/lua_api.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
GreenDimond
Member
 
Posts: 1273
Joined: Wed Oct 28, 2015 01:26
Location: SCP-3008
GitHub: GreenXenith
IRC: GreenDimond
In-game: GreenDimond

Re: How can i disable backface cull for my entity

by GreenDimond » Thu Oct 10, 2019 14:52

Drachenbauer32 wrote:
GreenDimond wrote:Set backface_culling = false in the entity properties.
https://github.com/minetest/minetest/blob/master/doc/lua_api.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.
Y▹uTube | Mods | Patre●n | Twitter | Minetest Discord | GreenDimond#3232

Hey, you. You're finally awake.
You were trying to view their profile, right? Found the rest of their signature, same as us, and that guest over there.
 

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

Re: How can i disable backface cull for my entity

by Drachenbauer32 » Fri Oct 11, 2019 20:15

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: 104
Joined: Wed Aug 28, 2019 18:11

Re: How can i disable backface cull for my entity

by Drachenbauer32 » Wed Oct 16, 2019 20:26

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

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

User avatar
runs
Member
 
Posts: 926
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

Re: How can i disable backface cull for my entity

by runs » Sun Nov 03, 2019 22:02

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

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

Re: How can i disable backface cull for my entity

by Drachenbauer32 » Mon Nov 18, 2019 19:15

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
runs
Member
 
Posts: 926
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy
 

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

Re: How can i disable backface cull for my entity

by Drachenbauer32 » Thu Nov 21, 2019 11:47

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

User avatar
runs
Member
 
Posts: 926
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

Re: How can i disable backface cull for my entity

by runs » Thu Nov 21, 2019 21:13

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: 104
Joined: Wed Aug 28, 2019 18:11

Re: How can i disable backface cull for my entity

by Drachenbauer32 » Sun Nov 24, 2019 16:23

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: 104
Joined: Wed Aug 28, 2019 18:11

Re: How can i disable backface cull for my entity

by Drachenbauer32 » Wed Dec 04, 2019 16:20

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


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 1 guest