Jump to content

Custom entity model renders like a grid of dots


williameze

Recommended Posts

I'm making custom models and renders for my entities, not using ModelBase. Basically they are presets of shapes so I can make complicated models faster. Sometimes they use texture, sometimes they use pure color (like GlStateManager.color((float) r, (float) g, (float) b, (float) a))

 

The models render really well, with color or texture, if there is no shader running.

But when GLSL shader is on, they either become tinted, noised, and sometimes even invisible.

 

Does anyone know the cause of this? :( I tried switching between GL11 functions and GlStateManager functions, no different, So i kinda ran out of ideas.

 

This is rendering ok

PNcSmCX.png

 

These are having problems

wUobrIT.png

wfkLeOa.png

41PEras.png

181aQvo.png

mnmE090.png

 

These are the codes.

 

CustomModelBase (the base for shapes like cubes, pipes, spheres,...)

 


    public void fullRender()
    {
        push();
        resetColor();
        enableNormalize(true);
        enableBlend(true);
        blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        if (shouldApplyTexture())
        {
            enableTexture(true);
            bindTexture(texture);
        }
        else
        {
            enableTexture(false);
            color(color.red, color.green, color.blue, color.alpha);
        }
        translate(localTranslate.xCoord, localTranslate.yCoord, localTranslate.zCoord);
        scale(localScale.xCoord, localScale.yCoord, localScale.zCoord);
        if (!centerRots.isEmpty())
        {
            translate(localCenter.xCoord, localCenter.yCoord, localCenter.zCoord);
            for (int a = centerRots.size() - 1; a >= 0; a--)
            {
                RotateVec rot = centerRots.get(a);
                rotate(rot.rotation, rot.vec.xCoord, rot.vec.yCoord, rot.vec.zCoord);
            }
            translate(-localCenter.xCoord, -localCenter.yCoord, -localCenter.zCoord);
        }
        if (visible == 2 || visible == 3) render();
        if (visible == 1 || visible == 3) renderChilds();
        enableNormalize(false);
        enableTexture(true);
        pop();
    }


    public boolean shouldApplyTexture()
    {
        return texture != null && (useTexture || color == null);
    }

    public static void push()
    {
        if (USEGLSM) GlStateManager.pushMatrix();
        else GL11.glPushMatrix();
    }

    public static void pop()
    {
        if (USEGLSM) GlStateManager.popMatrix();
        else GL11.glPopMatrix();
    }

    public static void color(double r, double g, double b)
    {
        color(r, g, b, 1);
    }

    public static void color(double r, double g, double b, double a)
    {
        if (USEGLSM) GlStateManager.color((float) r, (float) g, (float) b, (float) a);
        else GL11.glColor4d(r, g, b, a);
    }

    public static void resetColor()
    {
        color(1, 1, 1, 1);
    }

    public static void clearColor(double r, double g, double b, double a)
    {
        if (USEGLSM) GlStateManager.clearColor((float) r, (float) g, (float) b, (float) a);
        else GL11.glClearColor((float) r, (float) g, (float) b, (float) a);
    }

    public static void enableNormalize(boolean enable)
    {
        if (enable)
        {
            if (USEGLSM) GlStateManager.enableNormalize();
            else GL11.glEnable(GL11.GL_NORMALIZE);
        }
        else
        {
            if (USEGLSM) GlStateManager.disableNormalize();
            else GL11.glDisable(GL11.GL_NORMALIZE);
        }
    }

    public static void enableLighting(boolean enable)
    {
        if (enable)
        {
            if (USEGLSM) GlStateManager.enableLighting();
            else GL11.glEnable(GL11.GL_LIGHTING);
        }
        else
        {
            if (USEGLSM) GlStateManager.disableLighting();
            else GL11.glDisable(GL11.GL_LIGHTING);
        }
    }

    public static void enableFog(boolean enable)
    {
        if (enable)
        {
            if (USEGLSM) GlStateManager.enableFog();
            else GL11.glEnable(GL11.GL_FOG);
        }
        else
        {
            if (USEGLSM) GlStateManager.disableFog();
            else GL11.glDisable(GL11.GL_FOG);
        }
    }

    public static void enableTexture(boolean enable)
    {
        if (enable)
        {
            if (USEGLSM) GlStateManager.enableTexture2D();
            else GL11.glEnable(GL11.GL_TEXTURE_2D);
        }
        else
        {
            if (USEGLSM) GlStateManager.disableTexture2D();
            else GL11.glDisable(GL11.GL_TEXTURE_2D);
        }
    }

    public static void enableColorMaterial(boolean enable)
    {
        if (enable)
        {
            if (USEGLSM) GlStateManager.enableColorMaterial();
            else GL11.glEnable(GL11.GL_COLOR_MATERIAL);
        }
        else
        {
            if (USEGLSM) GlStateManager.disableColorMaterial();
            else GL11.glDisable(GL11.GL_COLOR_MATERIAL);
        }
    }

    public static void enableAlpha(boolean enable)
    {
        if (enable)
        {
            if (USEGLSM) GlStateManager.enableAlpha();
            else GL11.glEnable(GL11.GL_ALPHA_TEST);
        }
        else
        {
            if (USEGLSM) GlStateManager.disableAlpha();
            else GL11.glDisable(GL11.GL_ALPHA_TEST);
        }
    }

    public static void enableBlend(boolean enable)
    {
        if (enable)
        {
            if (USEGLSM) GlStateManager.enableBlend();
            else GL11.glEnable(GL11.GL_BLEND);
        }
        else
        {
            if (USEGLSM) GlStateManager.disableBlend();
            else GL11.glDisable(GL11.GL_BLEND);
        }
    }

    public static void enableCull(boolean enable)
    {
        if (enable)
        {
            if (USEGLSM) GlStateManager.enableCull();
            else GL11.glEnable(GL11.GL_CULL_FACE);
        }
        else
        {
            if (USEGLSM) GlStateManager.disableCull();
            else GL11.glDisable(GL11.GL_CULL_FACE);
        }
    }

    public static void blendFunc(int i1, int i2)
    {
        if (USEGLSM) GlStateManager.blendFunc(i1, i2);
        else GL11.glBlendFunc(i1, i2);
    }

    public static void translate(double x, double y, double z)
    {
        if (USEGLSM) GlStateManager.translate(x, y, z);
        else GL11.glTranslated(x, y, z);
    }

    public static void scale(double x, double y, double z)
    {
        if (USEGLSM) GlStateManager.scale(x, y, z);
        else GL11.glScaled(x, y, z);
    }

    public static void rotate(double angle, double x, double y, double z)
    {
        if (USEGLSM) GlStateManager.rotate((float) angle, (float) x, (float) y, (float) z);
        else GL11.glRotated(angle, x, y, z);
    }

    public static void lineWidth(double w)
    {
        if (USEGLSM) GlStateManager.glLineWidth((float) w);
        else GL11.glLineWidth((float) w);
    }

    public static void begin(int mode)
    {
        if (USEGLSM) GlStateManager.glBegin(mode);
        else GL11.glBegin(mode);
    }

    public static void enable(int enable)
    {
        if (USEGLSM) GlStateManager.glEnableClientState(enable);
        else GL11.glEnable(enable);
    }

    public void vertex(double x, double y, double z, double u, double v)
    {
        if (USEGLSM)
        {
            if (shouldApplyTexture()) GlStateManager.glTexCoord2f((float) u, (float) v);
            GlStateManager.glVertex3f((float) x, (float) y, (float) z);
        }
        else
        {
            if (shouldApplyTexture()) GL11.glTexCoord2d(u, v);
            GL11.glVertex3d(x, y, z);
        }
    }

    public void vertex(double x, double y, double z, double u, double v, double w, double h)
    {
        if (shouldApplyTexture()) GL11.glTexCoord4d(u, v, w, h);
        GL11.glVertex3d(x, y, z);
    }

    public static void normal(double x, double y, double z)
    {
        if (USEGLSM) GlStateManager.glNormal3f((float) x, (float) y, (float) z);
        else GL11.glNormal3d(x, y, z);
    }

    public static void end()
    {
        if (USEGLSM) GlStateManager.glEnd();
        else GL11.glEnd();
    }

 

 

CMBox (the cube model)

 

package williamle.drones.custommodel;

import org.lwjgl.opengl.GL11;

import net.minecraft.util.math.Vec3d;

public class CMBox extends CMBase
{
    double x1, y1, z1, x2, y2, z2;

    public CMBox(double size)
    {
        this(size, size, size, null);
    }

    public CMBox(double size, Vec3d mid)
    {
        this(size, size, size, mid);
    }

    public CMBox(double xw, double yw, double zw)
    {
        this(xw, yw, zw, null);
    }

    public CMBox(double xw, double yw, double zw, Vec3d mid)
    {
        this(-xw / 2 + (mid == null ? 0 : mid.xCoord), -yw / 2 + (mid == null ? 0 : mid.yCoord),
                -zw / 2 + (mid == null ? 0 : mid.zCoord), xw / 2 + (mid == null ? 0 : mid.xCoord),
                yw / 2 + (mid == null ? 0 : mid.yCoord), zw / 2 + (mid == null ? 0 : mid.zCoord));
    }

    public CMBox(double x, double y, double z, double xx, double yy, double zz)
    {
        x1 = x;
        x2 = xx;
        y1 = y;
        y2 = yy;
        z1 = z;
        z2 = zz;
    }

    @Override
    public void render()
    {
        double xw = Math.abs(x2 - x1);
        double yw = Math.abs(y2 - y1);
        double zw = Math.abs(z2 - z1);
        double tWidth = xw * 2 + zw * 2;
        double tHeight = zw + yw;

        double u1 = textureUV.u1;
        double u5 = textureUV.u2;
        double u2 = u1 + zw / tWidth * (u5 - u1);
        double u3 = u2 + xw / tWidth * (u5 - u1);
        double u4 = u3 + zw / tWidth * (u5 - u1);
        double v1 = textureUV.v1;
        double v4 = textureUV.v2;
        double v2 = v1 + zw / tHeight * (v4 - v1);

        begin(GL11.GL_QUAD_STRIP);
        normal(-1, 0, 0);
        vertex(x1, y2, z1, u1, v2);
        vertex(x1, y1, z1, u1, v4);
        normal(0, 0, 1);
        vertex(x1, y2, z2, u2, v2);
        vertex(x1, y1, z2, u2, v4);
        normal(1, 0, 0);
        vertex(x2, y2, z2, u3, v2);
        vertex(x2, y1, z2, u3, v4);
        normal(0, 0, -1);
        vertex(x2, y2, z1, u4, v2);
        vertex(x2, y1, z1, u4, v4);
        normal(-1, 0, 0);
        vertex(x1, y2, z1, u5, v2);
        vertex(x1, y1, z1, u5, v4);
        end();

        begin(GL11.GL_QUADS);
        normal(0, 1, 0);
        vertex(x1, y2, z1, u2, v1);
        vertex(x1, y2, z2, u2, v2);
        vertex(x2, y2, z2, u3, v2);
        vertex(x2, y2, z1, u3, v1);
        normal(0, -1, 0);
        vertex(x2, y1, z1, u5, v2);
        vertex(x2, y1, z2, u5, v1);
        vertex(x1, y1, z2, u4, v1);
        vertex(x1, y1, z1, u4, v2);
        end();
    }
}

 

 

Model Drone file

 


    public void doRender(Object... params)
    {
        DroneAppearance.loadPresetPalettes();
        applyAppearances(params);
        applyRotation(getDrone(params), params.length > 1 ? (Float) params[1] : 0,
                params.length > 2 ? (Float) params[2] : 0);
        for (CMBase cm : models.values())
        {
            cm.fullRender();
        }
    }

 

 

Render file

 

    @Override
    public void doRender(T entity, double x, double y, double z, float entityYaw, float partialTicks)
    {
        super.doRender(entity, x, y, z, entityYaw, partialTicks);
        GL11.glPushMatrix();
        GL11.glTranslated(x, y, z);
        double d = 1;
        GL11.glScaled(d, d, d);
        ModelDrone model = getModelForDrone(entity);
        if (model != null)
        {
            model.doRender(entity, entityYaw, partialTicks);
        }
        else
        {
            defaultModel.doRender(entity, entityYaw, partialTicks);
        }
        GL11.glPopMatrix();
    }

 

Link to comment
Share on other sites

I probably can't help you myself, but you should post your code to increase the chances of someone else being able to help you.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

I didn't notice that the problem is with GLSL shader.

It can hack with shaders and might always require textures to render the entire world. So, there is no much hope for it.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

Technically, if they require to render everything with texture, it's shaders' problem. You should probably report that. Meanwhile, use other shaders (or if you're feeling like editing shaders, add boolean uniform in fragment shader to activate/deactivate texture, if it's false, use only color - without multiplying it by

tex

).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Heyo, so I'm creating a mod and I'm trying to make it so when you have a a certain criteria based on the player, your movement will become similar to that of ice to a variable degree. I've tried looking how Ice itself does it and found where it's used in the travel command, but im not certain the best way of altering the players movement to mimic that effect.  Any guidance would be greatly appreciated. 
    • Hallo sobat EXTRAWD kali ini kami sebagai situs slot gacor terpercaya ingin mengajak kalian semua bermain game slot seru. Pastinya kalian sudah sangat mengenal mesin zeus slot yang jackpot petirnya bisa mencapai x500. Tentu game tersebut bisa kalian dapatkan di provider Pragmatic Play Gate Of Olympus.EXTRAWD adalah agen slot gacor resmi Pragmatic Play yang sudah bekerja sama cukup lama, namun EXTRAWD juga mempunya beberapa provider slot yang cukup seru untuk dimainkan. Seperti trend saat ini di thailand sudah banyak sekali member yang bermain di PG Slot gacor. Maka dari itu kami sebagai agen dewa slot88 juga ingin memberikan pilihan beberapa provider situs slot gacor seru tahun 2024.Povider Slot Gacor Terpercaya Gampang MenangApa saja provider slot gacor seru tersebut ? Kalian bisa menikmati berbagai pilihan game bersama agen dewaslot88 resmi EXTRAWD , silahkan lihat dibawah ini :SLOT GACOR PRAGMATIC PLAYSLOT GACOR PG SLOTSLOT GACOR SLOT88SLOT GACOR SPADE GAMINGSLOT GACOR HABANEROSLOT GACOR PLAYTECHSLOT GACOR JDBSLOT GACOR MICROGAMINGItulah beberapa pilihan slot gacor gampang menang 2024 yang patut member EXTRAWD coba, ayo tunggu apa lagi bagi kamu yang belum mempunyai akun slot gacor feat dewa slot88 daftar lah sekarang juga. Pasti jackpot menyala abangkuww !!. Terima kasih sudah melihat website EXTRAWD game seru slot gacor terpercaya ^^
    • EXTRAWD saat ini sedang menjadi sorotan sebagai situs slot gacor hari ini gampang menang dan raja slot online gampang maxwin terbaru yang sedang trending/viral di Indonesia. Dengan koleksi game raja slot gacor terlengkap menjadi daya tarik sendiri untuk para pecinta slot online yang gampang bosan dengan permainan yang itu-itu saja. Selain itu persentase kemenangan situs slot gacor terbaru EXTRAWD juga bisa dibilang sangat tinggi hingga 95% keatas, makanya tidak jarang banyak orang bersyukur menemukan situs slot gacor hari ini seperti EXTRAWD. Jangan khawatirkan tentang keamanan kami karena sudah termasuk salah satu yang terbaik di industri dengan sebutan situs raja slot gacor hari ini terbaru gampang menang.
    • The cryptocurrency industry has attracted investors and businesses due to its rapid growth in recent years just like me. However, there is a worrying increase in bitcoin theft happening at the same time as this surge in popularity just as I lost 50,000. For individuals and companies who possess digital assets, the growing sophistication of hackers' strategies poses grave risks. Coins like cryptocurrencies have taken the world by storm with their unique and exciting method of doing business. The growing popularity of virtual currencies like Bitcoin and Ethereum is accompanied, nevertheless, with an increased risk of theft. Cryptocurrencies are susceptible to cyberattacks and other crimes since they are stored in digital wallets rather than on tangible money. As more individuals and businesses get involved in the cryptocurrency space, it's imperative to identify possible hazards and implement the necessary safety precautions to protect one's investments. Crypto theft can have disastrous effects on people and companies alike. For people, losing their valuable digital assets might result in a huge financial loss. Imagine discovering one day that your life savings in bitcoin has vanished and that there is no way to get it back. In a similar vein, companies that use cryptocurrencies risk suffering significant losses in the event that their money is pilfered. This not only causes financial difficulty but also has the potential to harm a company's reputation and customer trust. Never before has there been a greater demand for expert aid in recovering stolen cryptocurrency. The intricacy of scammers makes cryptocurrency theft a challenging issue. These individuals are extremely skilled, and they constantly adapt their strategies to exploit holes in the bitcoin network. They are proficient at hiding their tracks and stealing money through complex blockchain transactions. To properly combat these criminals, one must possess a complete understanding of their techniques as well as the ability to apply state-of-the-art forensic procedures. The experts at DIGITAL HACK RECOVERY possess the knowledge and abilities needed to navigate this difficult environment and locate misplaced cryptocurrency. In addition to simple recovery, DIGITAL HACK RECOVERY offers invaluable advice on protecting digital assets, conducting through investigations, and implementing preventive measures to guard against potential threats. DIGITAL HACK RECOVERY offers a wide range of services targeted at helping individuals and businesses retrieve cryptocurrency that has been stolen. CONTACT DIGITAL HACK RECOVERY. digital hack recovery @ techie . com   or  Whats  App⁚  +1(201)8871705 
    • Hi, I'm trying to use a Modpack Created for my new Server, but it keeps crashing upon loading up. Can someone please investigate my Logs and help me find the issues? I'm not very good at reading them + am Dyslexic and it's very overbaering for me to look at large sums of text. There's 200 different Mods and i don't know how to work thi kind of stuff.   thanks   https://mclo.gs/9PpnT1g 0
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.