#How do I render a square?

109 messages · Page 1 of 1 (latest)

hushed moat
#

I have this method and I need to use that VertexConsumer to render a square of the texture.

override fun render(
        poseStack: PoseStack,
        multiBufferSource: MultiBufferSource,
        i: Int,
        entityRenderState: HappyGhastRenderState,
        f: Float,
        g: Float
    ) {
        val vertexConsumer = multiBufferSource.getBuffer(RenderType.entityCutoutNoCull(RENDER_TYPE_ID))
    }
hushed moat
#

bump

hushed moat
#

Edit: Now I have this but the texture renders pure black, and I have no idea what uv1 and uv2 and normal are because chatgpt wrote it

override fun render(
        poseStack: PoseStack,
        multiBufferSource: MultiBufferSource,
        i: Int,
        entityRenderState: HappyGhastRenderState,
        f: Float,
        g: Float
    ) {
        val vertexConsumer = multiBufferSource.getBuffer(RenderType.entityCutoutNoCull(RENDER_TYPE_ID))
        val pose = poseStack.last()

        // Bottom-right vertex
        vertexConsumer.addVertex(pose, 0.0f, 0.0f, 0.0f)
            .setColor(255, 255, 255, 255)
            .setUv(0.0f, 1.0f)
            .setUv1(0, 240)
            .setNormal(0.0f, 0.0f, 1.0f)
            .setUv2(0, 0)

        // Top-right vertex
        vertexConsumer.addVertex(pose, 1.0f, 0.0f, 0.0f)
            .setColor(255, 255, 255, 255)
            .setUv(1.0f, 1.0f)
            .setUv1(0, 240)
            .setNormal(0.0f, 0.0f, 1.0f)
            .setUv2(0, 0)

        // Top-left vertex
        vertexConsumer.addVertex(pose, 1.0f, 1.0f, 0.0f)
            .setColor(255, 255, 255, 255)
            .setUv(1.0f, 0.0f)
            .setUv1(0, 240)
            .setNormal(0.0f, 0.0f, 1.0f)
            .setUv2(0, 0)

        // Bottom-left vertex
        vertexConsumer.addVertex(pose, 0.0f, 1.0f, 0.0f)
            .setColor(255, 255, 255, 255)
            .setUv(0.0f, 0.0f)
            .setUv1(0, 240)
            .setNormal(0.0f, 0.0f, 1.0f)
            .setUv2(0, 0)
    }
worldly thunder
hushed moat
hushed moat
worldly thunder
hushed moat
#

not onto a ghast, a bit beside it

#

but as part of it's renderer

hushed moat
worldly thunder
#

i have no idea

frail jay
#

and do this

VertexConsumer vertexConsumer = multiBufferSource.getBuffer(RenderLayer.getEntityTranslucent(sprite.getAtlasId()));

instead of your current way of creating a vertex consumer

hushed moat
#

I'm doing it how it is done in vanilla, and as I said, it does render the texture, but only a silhouette of it which likely means i set the wrong values for the vertices

frail jay
#

try adding them in a counter clockwise order

#

i'm not sure

frail jay
hushed moat
#

(The texture id is ender pearl)

#

val RENDER_TYPE_ID: ResourceLocation = ResourceLocation.withDefaultNamespace("textures/item/ender_pearl.png")

hushed moat
frail jay
#

maybe .light(i) on each vertex

frail jay
frail jay
hushed moat
frail jay
#

so??

#

does it work??

hushed moat
#

nope

#

I think it might have something to do with the uv1, or overlay as it is called on yarn

frail jay
#

do you plan on rendering an item on the ghast?

hushed moat
#

no, i just didn't do the texture yet

frail jay
#

maybe just make the texture an item

#

and use the builtin function

#

or just test it with the builtin function rn

hushed moat
#

its going to be a propeller that is rendered on the back of the ghast but offset from it's body

#

maybe i should make an entity model for it and add that to my renderlayer

#

but I have no idea how that will work

#

Do you have any suggestions on a potentially easier way to do this?

frail jay
#

maybe a last idea

#

for the setNormal

#

maybe try 0f, 1f, 0f

hushed moat
#

ok

#

still same

#

maybe the uv1

#

idk what it is

#

chatgpt set it to some completely random number

frail jay
#

do you know what setUv2 does??

hushed moat
#

the lightmap apparently

frail jay
#

huh

hushed moat
#

its what the setLight method changes

frail jay
#

try and remove it

#

i dunno bro honestly

hushed moat
#

hmm in yarn uv1 is called overlay

#

it crashes if any of the values are missing

#

do you know what this is?

#

default VertexConsumer setOverlay(int i) { return this.setUv1(i & 65535, i >> 16 & 65535); }

frail jay
#

yes

#

this is the method i know

#

okaaayyyy

hushed moat
#

what is the parameter

frail jay
#

try i

hushed moat
#

i is the light though

#

i already used it for setLight()

frail jay
#

but why aren't the arguments properly named??

hushed moat
#

mojmap!

frail jay
#

ooohhhh

#

wait im gonna see on yarn

hushed moat
#

in yarn its not that much better as i can tell from linkie

#

bruh nothing is changing anything its still a black silhouette

frail jay
#

even the setOverlay with i??

hushed moat
#

yup

#

wait i found something

frail jay
#

bruh

hushed moat
#

OverlayTexture.NO_OVERLAY

#

IT WORKED!!!

frail jay
#

NICEEEE

#

GGS BRO

hushed moat
#

i saw that field in one of the things chatgpt wrote which didn't compile

frail jay
#

do you know what an overlay is??

hushed moat
#

Thanks for the help!

frail jay
#

because bro

frail jay
hushed moat
frail jay
#

ohh

#

okay i get it

#

nice find tho

hushed moat
#

theres 3 other fields here

public static final int NO_WHITE_U = 0;
    public static final int RED_OVERLAY_V = 3;
    public static final int WHITE_OVERLAY_V = 10;
    public static final int NO_OVERLAY = pack(0, 10);
frail jay
#

what were you using before?

hushed moat
#

some random number chatgpt put

#

0, 240

#

now it's time for me to figure out pose stacks

frail jay
#

good luck

hushed moat
#

what does setNormal do though?

#

it works the exact same set to 0, 0, 0

frail jay
#

do you know what a normal is?

hushed moat
#

nope

#

this is my first time doing rendering

frail jay
#

it's a vector that points straight up

hushed moat
#

so the face to render on

frail jay
#

that is perpendicular to the plane of the triangle

#

normally

#

and i say normally

hushed moat
#

so it splits the set of 4 vertices into 2 triangles to render the quad?

frail jay
hushed moat
#

hmm

frail jay
#

but i don't know what it is used for in minecraft's rendering

frail jay
main sorrel
#

ItemRenderer go brrrrr