Jump to content

(1.18.2) learn to render custom complex VFX


ElTotisPro50

Recommended Posts

So, i want to render complex visual effects in minecraft 1.18.2, from creating simple lines, to things more complicated, like ray beams, electricity/lightning, explosions, player rendering, etc. Im guessing i need the knowledge of Tesselator, BufferBuilder, OpenGL etc. Do you know where could i learn from almost 0 this things? I dont mean a tutorial for creating this effects, but something to get me started, and something to give me enough knowledge to start this renderings. 

Link to comment
Share on other sites

1 hour ago, ChampionAsh5357 said:

Probably the best place to start is OpenGL and its integration into LWJGL. From there, it's mainly just looking over the vanilla source code and see how they abstract those features into Blaze3D (since Blaze3D has no documentation).

this things can be rendered from anywhere? or i have to use the "RenderLevelLastEvent"?

Link to comment
Share on other sites

On 5/8/2023 at 1:38 PM, ElTotisPro50 said:

this things can be rendered from anywhere? or i have to use the "RenderLevelLastEvent"?

It depends on what you are doing. For example, entities would use an EntityRenderer while an overlay may use IOverlayRenderer. You will need to figure out what you are trying to render and how you want to implement it.

Link to comment
Share on other sites

1 hour ago, ChampionAsh5357 said:

It depends on what you are doing. For example, entities would use an EntityRenderer while an overlay may use IOverlayRenderer. You will need to figure out what you are trying to render and how you want to implement it.

im trying to render a simple line (two vertex) in the world, so im using RenderLevelLastEvent, the problem is that, is not working (does not render anything), the game does not crash, or give errors, or anything, if you know a bit about this, can you help to solve this? thanks

btw: the start and end Vecs are positions of 2 blocks on my world, I tripled checked them, the positions are correct, so the problem is not the start and end positions.

@SubscribeEvent
    public static void test(RenderLevelLastEvent event) {
        if (mc.player != null && mc.player.isAlive()) {
            Player player = mc.player;
            Level level = player.level;
            PoseStack stack = event.getPoseStack();
            Matrix4f matrix = stack.last().pose();

            Tesselator tesselator = Tesselator.getInstance();
            BufferBuilder buffer = tesselator.getBuilder();
            Vec3 start = new Vec3(-74, -61 ,-39);
            Vec3 end = new Vec3(-74, -54 ,-39);

            RenderSystem.disableTexture();
            RenderSystem.enableDepthTest();
            RenderSystem.depthFunc(515);
            RenderSystem.enableBlend();
            RenderSystem.defaultBlendFunc();
            RenderSystem.depthMask(false);

            drawLine(start,end, 1.0f);

            RenderSystem.enableCull();
            RenderSystem.depthMask(true);
            RenderSystem.disableBlend();
            RenderSystem.defaultBlendFunc();
            RenderSystem.enableTexture();
            
        }

public static void drawLine(Vec3 start, Vec3 end, float alpha) {
        if(start == null || end == null) return;
        PoseStack stack = RenderSystem.getModelViewStack();

        Matrix4f matrix = stack.last().pose();
        Tesselator tes = Tesselator.getInstance();
        BufferBuilder buffer = tes.getBuilder();

        RenderSystem.setShader(GameRenderer::getPositionColorShader);
        RenderSystem.lineWidth(1);
        buffer.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR);
        buffer.vertex(matrix,(float)start.x,(float)start.y,(float)start.z).color(1.0f,1.0f,1.0f, alpha).endVertex();
        buffer.vertex(matrix,(float)end.x,(float)end.y,(float)end.z).color(1.0f,1.0f,1.0f, alpha).endVertex();
        tes.end();
    }

 

Edited by ElTotisPro50
Link to comment
Share on other sites

21 hours ago, ElTotisPro50 said:

btw: the start and end Vecs are positions of 2 blocks on my world, I tripled checked them, the positions are correct, so the problem is not the start and end positions.

First of all, you should be using RenderTypes instead of direct RenderSystem calls. Second, you need to transform the line based on the vector of the projected view before drawing to the screen. You should be able to see how this is done by looking at any entity call. Third, don't use pose stacks interchangeably, each is for their individual purpose. If you are rendering in the world, use the posestack provided by the event.

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I'm opening the forge 1.8.9 installer properly I click install with the client option selected, it says it installs properly but when I go into my files and also when I go into the minecraft launcher, it's just not there.  JVM info: Oracle Corporation - 1.8.0_431 - 25.431-b10 java.net.preferIPv4Stack=true Found java version 1.8.0_431 Considering minecraft client jar Considering library net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9: Not Downloading {Wrong Side} Considering library net.minecraft:launchwrapper:1.12: Not Downloading {Wrong Side} Considering library org.ow2.asm:asm-all:5.0.3: Not Downloading {Wrong Side} Considering library jline:jline:2.13: Not Downloading {Wrong Side} Considering library com.typesafe.akka:akka-actor_2.11:2.3.3 Considering library com.typesafe:config:1.2.1 Considering library org.scala-lang:scala-actors-migration_2.11:1.1.0 Considering library org.scala-lang:scala-compiler:2.11.1 Considering library org.scala-lang.plugins:scala-continuations-library_2.11:1.0.2 Considering library org.scala-lang.plugins:scala-continuations-plugin_2.11.1:1.0.2 Considering library org.scala-lang:scala-library:2.11.1 Considering library org.scala-lang:scala-parser-combinators_2.11:1.0.1 Considering library org.scala-lang:scala-reflect:2.11.1 Considering library org.scala-lang:scala-swing_2.11:1.0.1 Considering library org.scala-lang:scala-xml_2.11:1.0.2 Considering library lzma:lzma:0.0.1: Not Downloading {Wrong Side} Considering library net.sf.jopt-simple:jopt-simple:4.6: Not Downloading {Wrong Side} Considering library java3d:vecmath:1.5.2 Considering library net.sf.trove4j:trove4j:3.0.3 Extracting: /forge-1.8.9-11.15.1.2318-1.8.9-universal.jar To: C:\Users\Ian\AppData\Roaming\.minecraft\libraries\net\minecraftforge\forge\1.8.9-11.15.1.2318-1.8.9\forge-1.8.9-11.15.1.2318-1.8.9.jar That's the installer log and I have no idea if anything is wrong.
    • https://mclo.gs/NQ786zI   I don’t understand what I need to do.
    • I am wanting to give the armour in my mod special properties, but I have no idea how to do so.   For the first armour set I want it to be the case that when the full set is worn it has the properties of a carved pumpkin, making it so you won't aggravate endermen when you look at them.    The second, and presumably harder property is that for the second set I would like it to be the case that when the full set is worn, you can walk over the void without falling. (I was considering using the levitation to accomplish this but I wanted to check beforehand).   Would both of these specialities be achievable for each armour set and how exactly would they both be done? Help would be much appreciated. 
    • I finally got my Forge server up and running thanks to the help of the people on this forum and played fine for a day. Now since I started playing today, the server runs for 20-30 minutes then freezes and kicks everyone out but stays up and running but won't let anyone connect. Here is the latest debug log and crashlog from the server. Thank you for reading & helping   https://gist.github.com/Dwolfwoood/d0410e581c86772694f1d8007431c409   https://gist.github.com/Dwolfwoood/b5d521fd071dbfcc816949924757fef9
    • I got the infamous crash log that you get when you have a mod or multiple mods that are incompatible with the version being used. however.. I have no idea which ones are wrong. I was hoping the forums could help me figure it out. does the crsh report tell me and im just dumb?  
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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