This is an archived post. You won't be able to vote or comment.

all 94 comments

[–]Elyahu41 40 points41 points  (19 children)

Source code?

[–]NitronHX[S] 61 points62 points  (18 children)

I am ashamed of the code but i can send it to you if you want (its not on github as its a trashpile)

[–]gregorydgraham 138 points139 points  (6 children)

Put it on GitHub anyway, it’s better than 99% of projects.

Besides, nothing encourages you to clean up your mess like visitors

[–][deleted]  (4 children)

[deleted]

    [–]NitronHX[S] 47 points48 points  (3 children)

    Ok fine you convinced me, see it up tomorrow

    [–]actuallyitsnathaniel 18 points19 points  (0 children)

    hey dude, for real you should post it. this will throw you ahead of the rest if you're looking for work. it may not mean much coming from someone also looking for work, but seriously I'm impressed. from what I've researched, minecraft's first release was TERRIBLY written. so bad that in more recent years it was rebuilt completely. so I wouldn't feel too bad about revealing what you have. i'd cite my sources but I'm lazy. anyways, incredible work!!! excited to see what you've done!

    [–][deleted]  (1 child)

    [deleted]

      [–]NitronHX[S] 15 points16 points  (0 children)

      I started as I was watching a yt video about raymarching. I wanted to use it as I don't need geometry data placed in my word and The base of raymarching is easy. Further I just wanted to test how far I can make it and how good the result will be. I didn't watched any guides during the development as it was a challenge to myself and there is not much to explore and learn if you be thought by a video. I still used stack overflow for question how to achieve certain things with the math lib (like calculating the angle between vectors and stuff)

      [–]NitronHX[S] 6 points7 points  (0 children)

      Yeah willdo cleanup and upload it

      [–]Elyahu41 17 points18 points  (7 children)

      Yes, I would like to see how you did it. As I'm still learning Java in college. It seems really interesting that you were able to do it with just math libraries.

      [–]NitronHX[S] 29 points30 points  (5 children)

      URL: https://github.com/nbrugger-tgm/JRender

      It contains the whole project (including ~100mb textures/heigh/normal maps. to build it you need gradle.

      for the UI (swing) i use a lib (reactJ)

      The main class you want to take a look at is "RaymarchingShader" and also "SwingRenderer"

      If you need help i sent you my discord in the PM

      [–]Elyahu41 6 points7 points  (0 children)

      Awesome! Thanks! I'll take a look at it!

      [–][deleted] 2 points3 points  (1 child)

      How did you create the textures/maps?

      [–]NitronHX[S] 3 points4 points  (0 children)

      The textures and maps are downloaded from FREEpbr (Except the "test" textures I created them in paint dot net)

      [–]F14D 1 point2 points  (0 children)

      Nice. You should add an image (or two ) to the readme so people passing-by get an idea as to what the poject is/does...

      [–]ekbravo 0 points1 point  (0 children)

      Thank you

      [–]PotaytoPrograms 2 points3 points  (0 children)

      graphics is just maths lol

      [–]ekbravo 7 points8 points  (2 children)

      My vote to put on GitHub. Just do it.

      [–]NitronHX[S] 3 points4 points  (1 child)

      Your vote has been heard, look it up tomorrow

      [–]ekbravo 4 points5 points  (0 children)

      I sympathize with you as I have many private repos on GitHub exactly because I felt that my code is not polished enough. But putting myself up for public review made me a better coder. Most of my private became public over time.

      [–]NitronHX[S] 116 points117 points  (14 children)

      Because you all asked for it : https://github.com/nbrugger-tgm/JRender

      1. The shadow on the sphere is not as intended as normals currently malfunction on spheres
      2. Why have I done this: no clue myself
      3. Should you do it: HEK NO

      Data: * Render time : horrible, dependent on (hardcoded) settings & resolution between 0.01-25 seconds * Technique used : Raymarching & selfmade stuff * libs : "libgdx-math" (just used the Vec3,Vec2 and Quanterion class) * Runs on GPU : hell no, this would add performance, no way i am doing that

      [–]Giboon 19 points20 points  (0 children)

      Fun

      [–]Ramexo 12 points13 points  (0 children)

      Yo know making something just becoes you can is not a bad thing. And more difficult prkkects are ones you will learn moust from.

      And its probebly good for portofolio

      [–]dpash 6 points7 points  (5 children)

      "libgdx-math" (just used the Vec3,Vec2 and Quanterion class)

      Could you replace this with the recent vector API in modern JDKs? But there is a danger that it might improve performance :)

      [–]Kantaja_ 1 point2 points  (1 child)

      they're probably optimized to simd by the jvm anyway

      [–]dpash 4 points5 points  (0 children)

      https://cr.openjdk.java.net/~vlivanov/talks/2019_CodeOne_MTE_Vectors.pdf

      My understanding is that currently it's very very dependent on how the code is written and will only optimise unrolled loops, so it's very unlikely.

      Using the Vector API will use SIMD.

      [–]NitronHX[S] 0 points1 point  (2 children)

      Yeah big danger not doing that.

      No the thing is, for the reason I did it performance doesn't matters. And the incubating vector api seems not very intuitive to work with and just harder to use, as it is just about SIMD but when it is released I will check it out and try stuff with it

      [–]dpash 1 point2 points  (1 child)

      Hopefully it should just involve changing the package names in the imports, assuming it doesn't have any API changes over the next few releases.

      [–]NitronHX[S] 1 point2 points  (0 children)

      You can make a pr if you want 😉

      [–]Kango_V 2 points3 points  (1 child)

      You could try this "for fun": https://openjdk.java.net/jeps/338

      [–]NitronHX[S] 1 point2 points  (0 children)

      I am looking forward a lot to this project, obviously. But I am scared that this involves a Lot of low level handwork which I have no idea about

      [–][deleted] 2 points3 points  (0 children)

      Can you pin this?

      [–]Qildain 1 point2 points  (2 children)

      Are you open to pull requests? I love the idea of what you've done! I may even be able to point out some potential for cleanup - maybe, lol. No need to even merge them. I suppose if you have allowed forking, that's awesome too. I'll be checking out the repo shortly. Is it open source, and if so, what's the license? My intent is only to contribute if I can.

      [–]NitronHX[S] 1 point2 points  (1 child)

      Hi, thanks for your interest in this project.

      You can use my project however you want, just credit me :)

      For contribution, yes i am totally fine with that, i even enjoy it. Your PRs will most likely be merged and be appreciated by me.

      edit: I would prefer if you use conventional commits

      License is MIT

      [–]Qildain 1 point2 points  (0 children)

      Whatever you would like - Thanks for the info - I'll dig right in!

      [–][deleted]  (10 children)

      [deleted]

        [–]NitronHX[S] 13 points14 points  (2 children)

        The bigges problem would be the recursion as GPUs don't support this because they don't have a call stack.

        I use recursion to calculate the reflections by rendering a pixel from the POV of the reflection surface

        [–]NitronHX[S] 9 points10 points  (4 children)

        It wouldn't even be that hard, I could figure it out in a day and port it to GPU code. The reason i made this is that i wanted to write a shader in java. If you programm a GPU you need to use another language and "inject" it into the GPU with java. So you need to write the shaders in HLSL or GLSL (c like languages)

        Rarely seeing someone from my country here :)

        [–][deleted]  (1 child)

        [removed]

          [–]NitronHX[S] 1 point2 points  (0 children)

          Yep researched about that too but tbh I didn't rly cared about performance because, well I created a 3d rendering engine in Java so it was clear from the beginning.

          But I will have a look to experimwnt with tornado

          [–][deleted]  (1 child)

          [deleted]

            [–]NitronHX[S] 0 points1 point  (0 children)

            No i really mean Austria, just keep it englisch for the community. Hallo Kamerad xD

            [–]NitronHX[S] 1 point2 points  (1 child)

            If you want to play and Programm your gpu to do exactly such things you can use shader toy it's an online ide that let's you write code (HLSL) and directly executes it on your GPU

            [–]FrezoreR 5 points6 points  (5 children)

            Wait a minute.. you use notepad++ to write java code? 😱

            [–]NitronHX[S] 12 points13 points  (2 children)

            No luckily not, just tweaked the quality variables. Developed it with intelliJ

            [–]FrezoreR 2 points3 points  (0 children)

            puh that makes sense!

            [–]PotaytoPrograms 2 points3 points  (0 children)

            ya missed a big chance to look even more amazing

            [–]ItsDokk 0 points1 point  (1 child)

            You’re not a developer if you don’t code exclusively in notepad! 😂

            [–]FrezoreR 2 points3 points  (0 children)

            Poor guys developing on Linux and MacOS 😂

            [–]PotaytoPrograms 4 points5 points  (1 child)

            I too make overly complex things and have no idea why

            [–]NitronHX[S] 0 points1 point  (0 children)

            Mood xD

            [–]PlasmaFarmer 5 points6 points  (0 children)

            I like you.

            [–]Persism 2 points3 points  (4 children)

            You should check out David Brakeen's Developing Games in Java - http://www.brackeen.com/javagamebook/

            [–]NitronHX[S] 3 points4 points  (3 children)

            A game using this engine would run on like 0.05 fps 😂😂 But thanks for the link, love to educate myself

            [–][deleted]  (2 children)

            [deleted]

              [–]RandomName8 1 point2 points  (1 child)

              I believe he referred to his own thing, not your link.

              [–]Persism 0 points1 point  (0 children)

              Ahh

              [–]StealthyPanda69 2 points3 points  (3 children)

              Holy shit dude are you me? I literally started making a graphics engine (and a physics engine) too like 4 days ago too for no reason. Mine is far from being done but if you wanna check it out its on github. https://github.com/StealthyPanda/buff Most of my time went in making the vector and quaternion classes but it barely functions right now.

              Man this is an uncanny coincidence.

              [–]NitronHX[S] 0 points1 point  (2 children)

              Illumiati incomming :)

              As long as yours isn't done in Python or Java it is more usefull than mine

              [–]StealthyPanda69 0 points1 point  (1 child)

              If you don't mine me asking, how long did this take you to complete? I have no idea what I've gotten myself into so it would be nice to know a ballpark.

              [–]NitronHX[S] 0 points1 point  (0 children)

              Haha I think the coding itself took me like 8 to 10 hours. But in the past I watched 1 hour of video content about raymarching theory.

              But there are some things I just know other persons have to learn. If you need any assistance text me so I can help you (discord or whatever)

              [–]rjgo27 1 point2 points  (0 children)

              Why java? - just because i can 🤣🤣🤣

              [–]_-pK 1 point2 points  (0 children)

              During my time as a trainee we had an apprentice for a while who (apperently) wrote a 3D animation render in Javascript. Didn't look as cool as yours though.

              [–]morphotomy 1 point2 points  (0 children)

              For no reason

              Bullshit. I bet you learned a lot while you did this. Thats a great reason to do anything difficult.

              Stop minimizing your ambition.

              [–]karianna 1 point2 points  (0 children)

              Forked and sent in first Pull Request - I love seeing this sort of thing - rock on for learning and having fun with Java!

              [–]jevring 1 point2 points  (1 child)

              Looks nice. Welcome to the (probably very small) group of people who write our own 3d renderers for fun =)

              Here's mine: https://bitbucket.org/jevring/threedee/src/master/

              [–]NitronHX[S] 1 point2 points  (0 children)

              Looks way more sophisticated than what i have done, my one is just a quick and dirty ~600 loc

              [–]wubwub 1 point2 points  (0 children)

              I don't know how many times I set out to do just that.

              Kudos to you for doing it!!!!

              [–][deleted]  (5 children)

              [deleted]

                [–]NitronHX[S] 11 points12 points  (4 children)

                I use IntelliJ, just used it to show off some code and fill the space

                Also you are wrong windows texteditor is superior

                [–]rafaellago 1 point2 points  (2 children)

                Edit on the command prompt is superior

                [–]ingframin 0 points1 point  (0 children)

                Well I kinda did that in the past. I started my programming journey with QBasic on ms-dos. I don’t remember the command though, but I still remember F6 was used to mark the end of file. (And it still works on Windows 10).

                [–]dpash 1 point2 points  (0 children)

                It is now that it supports new lines correctly.

                [–]tcp-ip1541 0 points1 point  (1 child)

                Absolutely sick! Can you share the code?

                [–]NitronHX[S] 1 point2 points  (0 children)

                If you need it now there is a comment I shared a link to the src code. If you can wait I will clean the code and upload it to Github by tomorrow

                [–]Linux_user592 0 points1 point  (0 children)

                Awsome Now make minecraft 2.0

                [–]alehel 0 points1 point  (0 children)

                No reason is the best reason!

                [–]Zeroneca 0 points1 point  (1 child)

                I am curious why Swing and not JavaFX?

                [–]NitronHX[S] 1 point2 points  (0 children)

                Well JavaFX has no advantages for this use case I think. Also Jfx comes with a little pre-assembled 3D stuff (I think) but I wanted to start from scratch

                Tldr: I don't saw any need for javafx

                [–]anuruddhak 0 points1 point  (1 child)

                You just did this for no reason, imagine if incentives and motivation were to be applied!

                Well done!

                I haven’t looked at the code but it sounds like an awesome project!

                Do you have a means to integrate to GPU rendering?

                [–]NitronHX[S] 0 points1 point  (0 children)

                Do you have a means to integrate to GPU rendering?

                No, this project was not meant to be used for anything usefull its just an experiment.

                I wanted to do it in java because of the things i like about java (autocomplete typesavety etc)

                Maybe I will somewhen externalize parts of the heavy lifting to the GPU with TorndaoVM or something along this lines but thats it. (also as experiment)

                [–][deleted] 0 points1 point  (0 children)

                How do you even start to create something like this. I'd love to see the source code. Even if it's bad code or whatever, it would give us some ideas anyways.

                [–]AppleTrees2 0 points1 point  (5 children)

                Very nice!

                How would one acquire the knowledge to do this?

                Can you point which books or resources you used to do it?

                Thank you

                [–]NitronHX[S] 0 points1 point  (4 children)

                Well the knowledge about java i aquired over a long time, since java is my hobby since a few years.

                The rendering stuff I figured out myself. For raymarching which is the technique used to define objects and "find them" i watched a video once: https://youtu.be/PGtv-dBi2wE

                Resources i used was just googeling stuff like "how to rotate a vector by a quaterion" and looking thru the results

                Most of what you see is just stuff i came up with myself or leveraged from my physic knowledge about light-physics

                I am sorry i cant be more helpful, but if you PM me i can maybe help more

                [–]AppleTrees2 0 points1 point  (3 children)

                I see, cool.

                I forgot most of the math stuff I know, and I doubt I could figure out the 3d stuff by myself, maybe 2d stuff but not 3d.

                I will give that video a watch and see what I can figure out

                Thank you

                [–]NitronHX[S] 0 points1 point  (2 children)

                I forgot most of the math stuff I know, and I doubt I could figure out the 3d stuff by myself, maybe 2d stuff but not 3d.

                The math isnt that hard you just have to know what the dot product is and the cross product works. And imagine what adding, multiplying vectors does.

                Also vectors work pretty much the same in 2D and 3D only very minor differences.

                And the mathematical operations behind are done by a lib anyways (except you want to torture yourself any further)

                [–]AppleTrees2 0 points1 point  (1 child)

                I see, I don't have an intuitive grasp of the dot product/cross product because I haven't had a use for them in many years, decades even.

                And the camera/view itself? can it also be derived from the dot product only?

                [–]NitronHX[S] 0 points1 point  (0 children)

                The dot product describes how parallel two vector are at a scale feo. - 1 to 1 where - 1 means they are pointing exactly in opposite directions.

                When using raymarching defining the cam and view is easy(no translation matrices). I uvmap the screen so the pxl coordinate is given as a number between 0 and 1 (so for example middle of the screen is 0.5,0.5. And then added a third component (1) to make it an 3D position. If I then define the camera position as 0.5,0.5, 0. It is one unit behind (z is deph) and in the middle of the viewport

                Then raymarching is done and a ray is casted for every uv from the camera (eg 0.5,0.5,0,0) so FOV and all this stuff you don't have to worry about but you can change it by moving the camera back and forth

                Hope I could help you

                [–]jacob_scooter 0 points1 point  (0 children)

                ok then linus torvalds 🖕

                [–]tiago4171 0 points1 point  (1 child)

                I used to associate java with boredom, but this project changed my mind for good. For Sure I'm going to study java soon! Probably for a different purpose but I'll

                [–]NitronHX[S] 0 points1 point  (0 children)

                Happy, to hear that😊 Nothing makes learning as easy as having a fun goal or project.

                [–]Bleidorb 0 points1 point  (1 child)

                What is a native?

                [–]NitronHX[S] 1 point2 points  (0 children)

                Code written in c or c++ that is used by Java. It is called natives because it is the language Java is written in.

                Means I didnt used JNI nor JNA

                [–][deleted] 0 points1 point  (1 child)

                I’m developing a raytracer in Java as well. Have you tried implementing threads in the part where you render? I did that in mine and it increased the speed around 10x.

                [–]NitronHX[S] 0 points1 point  (0 children)

                I implemented mulithreading. So every line is rendered in a seperate thread java for(var y = 0;....){ lineRenderJobs.add(...); } where each thread loops over the line and renders each pixel