Jump to content

[Solved][1.7.10] Problem with rendering shadows


wesserboy

Recommended Posts

Hello,

I am currently on my summer break, and i decided i would go do some minecraft modding.

One thing i could never do was rendering, so i figured i would use this extra time to learn how to do it.

To learn how to do it i set myself up with a nice challenge.

I wanted to make a block look like it was decaying by gradually making little blocks disappear from it.

 

I already learned a lot and its beginning to look like something, but i'm not yet happy with it.

 

This is how it currently looks:

Video

 

I use the following code to achieve this:

link

 

There's a couple of problems with this:

 

Firstly, the animation looks different depending on the side of the block you're looking at, form one side it looks like the blocks are disappearing, but from the other side it looks like the blocks 'slide away'. If you look at the video you will see what i mean.

 

Secondly, I keep rendering the original top of the block, this way there is still a crafting grid on layers deeper inside the block, which looks kinda odd. I would like to render the bottom of the block on top after the first layer has been removed, because i think it would look better that way. I know how to write the logic for this, but the rendering code...

 

If i would have to guess i think i need to stop using the RenderStanderdBlock method and draw the sides by directly interacting with the tessellator.

But I am not sure about this at all, as i said it is just i guess.

 

So my question is if someone knows how i would go about achieving this. Is my guess right, or is there a better way? And if my guess is right how would i go about implementing this idea? Does somebody maybe know a good tutorial where this is explained?

 

If you need more code/screenshots/video's or explanation, just ask and i will provide it.

I would like to thank you in advance!

 

-Wesserboy

I made the Mob Particles mod, you can check it out here: http://www.minecraftforum.net/topic/2709242-172-forge-mob-particles/

Link to comment
Share on other sites

Hello,

Today i spent the day rewriting my rendering code, and at this point it is almost perfect.

 

This is how it looks using the new code:

Video

 

This is my updated rendering code:

Link

 

There is only one problem, the block renders too bright. (there is no shadow)

15sar1y.png

 

(left is an original crafting table, right is my decaying block)

The block can look like any block in the game, I made it to look like a crafting table because it has a 'complex' texture, which is nice to test with.

 

I have tried different values in the methods tessellator.setColorOpaque_F(1F, 1F, 1F) and tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)). But i can't get the shadows to work properly.

 

My question is: How do i get/calculate the right values for the mentioned methods to render the shadows properly, or am i using the wrong methods and is there a different way of doing this?

 

-Wesserboy

I made the Mob Particles mod, you can check it out here: http://www.minecraftforum.net/topic/2709242-172-forge-mob-particles/

Link to comment
Share on other sites

Hi

What happens when you do not use these methods:

tessellator.setColorOpaque_F(1F, 1F, 1F); 
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)); 

I'm not good at rendering, but there seems to be either something your setting that is causing this, or lightning that needs to be updated when changing the block model frequently.

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Link to comment
Share on other sites

When i remove those two lines it looks like this:

2ir3fpw.png

The block looks very dark, the top is a lot darker than it is supposed to be, the sides look more like the normal crafting table, but still not quite the same.

 

as i said in the first post, this is one of my first attempts at rendering, so i'm also not quite sure what i am supposed to set, and what is already setup for me...

I made the Mob Particles mod, you can check it out here: http://www.minecraftforum.net/topic/2709242-172-forge-mob-particles/

Link to comment
Share on other sites

Try to set the normal in the tessellator before drawing each plane.

Look at

renderBlockAnvilRotate()

inside

net.minecraft.client.renderer.RenderBlocks

on how to set the normals correctly.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Try to set the normal in the tessellator before drawing each plane.

Look at

renderBlockAnvilRotate()

inside

net.minecraft.client.renderer.RenderBlocks

on how to set the normals correctly.

 

It looks to me like renderBlockAnvilRotate() only uses the tessellator.setNormal() method when it renders the block in an inventory. I think the boolean declares wether it is rendered in an inventory or in the world, and if it is rendered in the world it looks like it just passes the args to renderStandardBlock(). But i could be wrong, it's a little hard to follow the code with all the deobf arg names...

 

however, if i look at the renderBlockAnvilMetadata() method, it uses the tessellator.setBrightness(block.getMixedBrightnessForBlock()) method, which leads me to think that that line in my code was correct.

It also uses the tessellator.setColorOpaque_F() method, but it seems to calculate the three float values according to a block.colorMultiplier() and some hardcoded bit manipulation...

The values are calculated even more if EntityRenderer.anaglyphEnable is true. I'm not quite sure what anaglyphEnable means, but it seems odd to me that a setting in the EntityRenderer influences the way a block is rendered...

 

I will put the tessellator.setBrightness(block.getMixedBrightnessForBlock()) call back in my code, because it seems to be right since minecraft itself uses the same call.

The bit manipulation is still a bit of a mystery to me, I don't get where all these hardcoded values come from, but it seems to me that the answer to my problem lies within that calculation.

You would think there must be a method to get the calculated results for those floats, but the hardcoded calculations lead me to think that's not the case...

 

I will have another look through the RenderBlocks class, any help/explanation on these calculations, or on another approach would be very much appreciated.

I made the Mob Particles mod, you can check it out here: http://www.minecraftforum.net/topic/2709242-172-forge-mob-particles/

Link to comment
Share on other sites

From TheGreyGhost's blog/lighting post:

render the six faces with a different lighting intensity depending on which direction the faces points:

1. Top face (Ypos) is at full intensity

2. Bottom face (Yneg) is 50% intensity

3. Z-side faces (Zpos, Zneg = South, North) are 80% intensity

4. X-side faces (Xpos, Xneg = East, West) are 60% intensity.

Use

Tessellator#setColorOpaque_F

to set the intensity before rendering the actual side. Use 1F for 100%, and e.g. 0.6F for 60%.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Thank you very much!!!  :)

if smooth lighting is turned off my block looks exactly the same as the original:

2qu2fde.png

(left vanilla crafting table, right my block)

 

I looked up the blog post you mentioned (I think you ment this one) and I still have a couple of questions.

In the tutorial it shows a chart on how to apply lighting when rendering.

 

It states the first thing you have to do is apply the side dependent intensities. This is what i have done to (mostly) fix my problem.

Then you have to apply the ColorMultiplier. It states this is what makes blocks appear blue underwater etc.

I didn't apply any colorMultiplier, but underwater my block still looks exactly the same as a normal block:

2r2vw5i.png

(left vanilla crafting table, right my block)

 

I saw the tutorial is a little outdated (2013) so my question is: Is it possible that minecraft applies the ColorMultiplier automatically now?

 

When i turn on smooth lighting, my block doesn't look the same anymore, in the tutorial it states that this is due to the 'Ambient occlusion', and if i'm not mistaking it should be as easy as to multiply the side dependent percentage with another calculated value.

But the tutorial only tells what the value is based on, not how to get/calculate it. So my question is, is there some method or formula somewhere to get this value from?

 

It's not completely necessary to fix this, but if it is as easy as applying a multiplication, i think it would be worth the effort.

 

I made the Mob Particles mod, you can check it out here: http://www.minecraftforum.net/topic/2709242-172-forge-mob-particles/

Link to comment
Share on other sites

If you have a Block without a custom renderer, you can use the

colorMultiplier

method to return a hexadecimal color value and Minecraft uses that that to apply colors (that is what those bitwise operaters are doing, getting the RGB values from 1 value).

 

If the player is underwater, that lighting is done automatically somewhere else, so you don't need to worry about that.

 

As for ambient occlusion, if you have a look at

RenderBlocks#renderStandardBlockWithAmbientOcclusion

, you can see how Minecraft calculates the ambient occlusion. As you can see, it's not easy to replicate and Minecraft doesn't even do that for it's custom renderer block, so you probably don't have to worry about that.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Thank you for your explanation, I understand it a lot better now :)

 

I had a look at renderStandardBlockWithAmbientOcclusion, but it looks really difficult, so I'll just leave it the way it is now. The difference is so small that it's probably not worth the effort anyway. ;)

I made the Mob Particles mod, you can check it out here: http://www.minecraftforum.net/topic/2709242-172-forge-mob-particles/

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.