Jump to content

Recommended Posts

Posted

Hi, I have been looking into creating a coloured light mod for Minecraft, and the far the best idea I have come up with would be to enlarge the lightmap that minecraft uses to render sky light and block light together.

 

However, to reference a point on the light map Minecraft uses a short coordinate value so light values (0-15) can be mapped directly to the texture.  The problem I am having is when I try to reference a point in a larger lightmap (say 32 by 32 or 4096 by 16) the coordinates simply do not map correctly and ever Google search I have done says shorts (16-bit integers) cannot be uses in the function minecraft uses to set texture coordinates (glTexCoordPointer) but minecraft obviously does use it.  I just don't get it.  I simply want to be able to use a larger lighmap.

 

If anyone want to see what I'm talking about in the minecraft source (MCP or forge), look up the Tessellator object and draw() in it.

 

If anyone has an explanation on how this function works with shorts or a helpful link please post. :)

  • Like 1
Posted

Hi

 

Here's a little bit more background information, although it sounds like you might know it already.

 

http://greyminecraftcoder.blogspot.com.au/2013/08/lighting.html

 

The lightmap texture is set up in

EntityRenderer.enableLightmap()

 

The size is 256x256 (since the blocklight and skylight values are multiplied by 16 when they are stored in the "mixed brightness" number), i.e. each of the 16 blocklight x 16 skylight combinations has a 16x16 texels patch which is all the same colour.

 

( float f = 0.00390625F;  --> 1/f = 256,  i.e. the texels are scaled to each be 1/256 wide x 1/256 high)

 

I suspect (but I'm not sure) that the 16x16 texels patches is necessary because the block textures are also 16x16 texels in size.

 

Not sure how all this will help you, but if you figure it out I'm keenly interested...

 

-TGG

 

 

 

 

  • Like 1
Posted

Thank you a bunch!  I was wondering why the texture coordinates were shifted 4 bits and had not discovered this function.  I'll look into it now and see what I can come up with.

 

Once again thanks a lot, I post again if I'm successful or run into any more problems. :)

  • Like 1
Posted

Update:

Changing scaling to 1/4096 in the EntityRenderer.enableLightmap() function allowed me to change the size of the lightmap to 256 by 256 so I can fit both RGB and skylight values... and it worked!  The block light and skylight blended properly and colours also rendered correctly.  Now I have to implement the three block light values throughout the rest of minecraft and fix the ao calculations, but so far so good!

  • Like 1
Posted

Nope, this pretty much is incompatible with everything right now.

 

I may be able to make it compatible but there are many problems to fix before I get there.

  • Like 1
Posted

Alright, so I think I've got a good handle on how minecraft does it AO calculations and rendering and there is a problem.

 

When the blending for a block is rendered, each of the four corners of each face are assigned a brightness which is mixed (it is in the form of coordinates that points to somewhere on the lighmap).  So, when the face is rendered, each corner is given a texture coordinate that corresponds to a smooth version of this map:

 

LightMap.png

(pic from this very helpful blog post http://greyminecraftcoder.blogspot.ca/2013/08/lighting.html, thanks Ghost!)

 

So, when I try to do this with my enlarged lighmap (which is pretty much 256 of these lighmaps tacked together) the texture coordinates cover a very large area of the map and end up looking like this:

 

xo855s8.png

8fSPuXn.png

 

Not quite sure how to solve this, I tried setting the colour of the blocks but that was really finicky and not a good solution.  I am going to look into using multiple light textures and layer them to get good blending.

 

If anyone has any suggestions feel free to post 'em!  I'll post again if I have anything worth mentioning.

  • Like 1
Posted

Hi

 

Wow that looks pretty impressive even if it wasn't the effect you were looking for!!

 

Looks like a tricky problem.  I think the issue is that you're trying to interpolate across four dimensions (R,G,B, skylight) in something that's only represented in two dimensions.

 

I'm not  familiar with OpenGL at all, but your idea of multitexturing with a total of three lightmaps (R * skylight, G * skylight, B * skylight) sounds like a good idea to try.  I also notice that textures can have up to four dimensions which might be another way to get the GFX card to do linear interpolation across four dimensions for you.  Don't ask me how because I'm just guessing!

 

Interesting challenge...

 

-TGG

 

Posted

I think of blending the colours into the 16/16 lightmap right before a block corner has is brightness set. You'll need to calculate the colours first then. Don't know if that makes sense with the Minecraft lighting engine.

Posted

@TGG

Your 4D interpolation sounds like the best solution out of the two, except it will probable take the most to implement so I've tried the other way and I think it could work.  However I am also extremely new to OpenGL and am having lots of trouble trying to mix the texture with glTexEnvi calls, the solution's probably obvious to someone who knows what their doing. 

 

I've been able to make vanilla lighting work with the two lightmaps (skylight and blocklight, both 1x16 textures) but text stops rendering properly and colours don't work correctly (eg. grass colour, AO, and block shading).  I'll keep looking for a solution.  Any help would me most welcome!

 

EDIT: I took a quick look into it and 4D textures are not supported like I would have hoped and I think they're currently beyond me.

 

@GotoLink

I don't know if I exactly understand what you're suggesting, but Minecraft generates the lighmap once at the beginning of each frame and uses it to render the whole frame.  Changing it for each vertex would probably be incredibly laggy and yield unexpected results.  Thanks for the suggestion though. :)

 

 

Should I start a new topic to ask for help with the OpenGL problem?  Or just ask here?

Posted

Just a guess - since I have ~0 clue of opengl, since it worked without smooth textures, maybe its because of interpolation?

If my math is right you make a 4096 big texture, maybe something else is scaling it down with bilinear filter or something?

 

Posted

@ailmanki

You're right, the funky colours were because of interpolation.  So now instead of one 256*256 (or 16*4096) texture, I'm trying to use four 1*16 textures.  I'm having trouble getting the blending to work.

Posted

This is a very interesting project!

Awesome stuff mate :)

 

I'm sure you can just use this thread to ask about the gl stuff as well, its related and besides I'm sure this thread will be an interesting read for others diving into this kind of thing :D

  Quote

If you guys dont get it.. then well ya.. try harder...

Posted

@Mazetar

Thanks for the interest!  I'll go ahead and post some more stuff then.

 

Since in MC 1.7 their adding official support for shaders, I think they will be a better solution than screwing around with  the glTexEnv stuff (that feature was deprecated in OpenGL 1.3 I think and was added in 1999, almost 15 years old!).  So if anyone has any advice for using shaders for multi-textureing, don't be afraid to post!

 

I have had a look into it and I think it wont be too difficult, a very simple fragment shader will do the trick I think.  I'll just have to figure out how to sample the textures properly.

Posted

If the project is finished, can you upload some screenshots and maybe make API of it, so other mods can use it too.

 

BTW, your project looks amazing!

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/

Posted

Hi again, just wanted to mention that was able to get a shader working where the glTexEnv failed with vanilla light.  So what that means is I made the lighting system use two lightmaps instead of one (skylight and blocklight) and combine them via a shader, and this worked with smooth lighting perfectly.  So that's a nice step forward. 

 

However, using the shader at only one step of rendering caused a lot of other things to render wrong (like held blocks and items).  This problem will probably be fixed when I finish going through everywhere in the code where the Tessallator.setBrightness member is accessed.

 

Also the first little test I made was made using vanilla MCP, no forge, and I'd like to make this forge compatible with an API and not break anything and forge has a few more things that need to be made compatible to work with this.  This will probably take quite a bit of time and tons of debugging to get it to work properly.  AND Minecraft 1.7 will add official support for shaders with will require a rewrite of the mod, which will probably take a good bit less time than the first.  All in all, don't hold your breath for a final version, it's going to take some time I think.

 

Also, any suggestions how you think the API should be layed out are welcome.

 

Tiedye

Posted

I would suggest that for held items, that the light value just be grayscale lighting (i.e. like vanilla).  I don't think its really worth the overhead of trying to do calculated lighting on inventory items and ItemEntity objects.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
  On 10/22/2013 at 6:29 PM, Tiedye said:

Also, any suggestions how you think the API should be layed out are welcome.

 

If it would be possible, I'm sure being able to change the light colour based on metadata would be very useful, as many mods have coloured lamps now ;)

 

Either way, an API for this would be great! Best of luck!

Posted

@Draco18s

I think when it comes down to it, not Including the coloured lighting may be more of a pain that including it due to fact that the default lightmap is being completely replaced, and since its being done with shaders the overhead should be essentially zero. :)

 

@luisc99

Thanks for the suggestion!  I'll be sure to do my best to add that, seems like an excellent idea.

 

One last thing, the 1.7 per-release just got released (Yay) so I'll be aiming to release this mod for that instead, so don't expect anything before 1.7.

Posted
  On 10/22/2013 at 11:31 PM, Tiedye said:

@Draco18s

I think when it comes down to it, not Including the coloured lighting may be more of a pain that including it due to fact that the default lightmap is being completely replaced, and since its being done with shaders the overhead should be essentially zero. :)

 

Point.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Another little update.

 

Note that I've been pretty busy with school stuff so that's why I've made so little progress, but here's a screenshot.

 

cUR76lO.png

 

Smooth lighting!  Its using the multi-lightmap with shaders idea and its working pretty well.  Do note however this is just a modification my original test that I used to make the not-smooth-lighting screenshot from before, so extremely incomplete (note black block in hand), and has no semblance of an API.  Just thought I'd post something so you know I haven't given it up.

  • Like 1

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

    • Looks like an issue with biomeswevegone
    • In the server.properties, set max-tick-time to -1   if there are further issues, make a test without distanthorizons
    • Verified user can get a $300 off TℰℳU Coupon code using the code ((“{{ '[''com31844'']}}”)). This TℰℳU $100Off code is specifically for new and existing customers both and can be redeemed to receive a $100discount on your purchase. Our exclusive TℰℳU Coupon code offers a flat $100off your purchase, plus an additional 100% discount on top of that. You can slash prices by up to $100as a new TℰℳU customer using code ((“{{ '[''com31844'']}}”)). Existing users can enjoy $100off their next haul with this code. But that’s not all! With our TℰℳU Coupon codes for 2025, you can get up to 90% discount on select items and clearance sales. Whether you’re a new customer or an existing shopper, our TℰℳU codes provide extra discounts tailored just for you. Save up to 100% with these current TℰℳU Coupons ["^"{{ '[''com31844'']}} "^"] for April 2025. The latest TℰℳU coupon codes at here. New users at TℰℳU receive a $100discount on orders over $100Use the code ((“{{ '[''com31844'']}}”)) during checkout to get TℰℳU Coupon $100Off For New Users. You can save $100Off your first order with the coupon code available for a limited time only. TℰℳU 90% Off promo code ((“{{ '[''com31844'']}}”)) will save you $100on your order. To get a discount, click on the item to purchase and enter the coe. Yes, offers $100Off coupon code “{{ '[''com31844'']}}” for first time users. You can get a $100bonus plus $100Off any purchase at TℰℳU with the $100Coupon Bundle at TℰℳU if you sign up with the referral code ((“{{ '[''com31844'']}}”)) and make a first purchase of $100or more. Free TℰℳU codes $100off — ((“{{ '[''com31844'']}}”)) Get a $100discount on your TℰℳU order with the promo code "{{ '[''com31844'']}}". You can get a discount by clicking on the item to purchase and entering this TℰℳU Coupon code $100off ((“{{ '[''com31844'']}}”)). ŢℰNew User Coupon ((“{{ '[''com31844'']}})): Up To $100OFF For First-Time Users Our TℰℳU first-time user coupon codes are designed just for new customers, offering the biggest discounts and the best deals currently available on TℰℳU To maximize your savings, download the TℰℳU app and apply our TℰℳU new user coupon during checkout. TℰℳU Coupon Codes For Existing Users ((“{{ '[''com31844'']}}”)): $100Price Slash Have you been shopping on TℰℳU or a while? Our TℰℳU Coupon for existing customers is here to reward you for your continued support, offering incredible discounts on your favorite products. TℰℳU Coupon For $100Off ((“{{ '[''com31844'']}}”)): Get A Flat $100Discount On Order Value Get ready to save big with our incredible TℰℳU Coupon for $100off! Our amazing ŢℰM$100off coupon code will give you a flat $100discount on your order value, making your shopping experience even more rewarding. TℰℳU Coupon Code For $100Off ((“{{ '[''com31844'']}}”)): For Both New And Existing Customers Our incredible TℰℳU Coupon code for $100off is here to help you save big on your purchases. Whether you’re a new user or an existing customer, our $100off code for TℰℳU will give you an additional discount! TℰℳU Coupon Bundle ((“{{ '[''com31844'']}}”)): Flat $100Off + Up To $100Discount Get ready for an unbelievable deal with our TℰℳU Coupon bundle for 2025! Our TℰℳU Coupon bundles will give you a flat $100discount and an additional $100off on top of it. Free TℰℳU Coupons ((“{{ '[''com31844'']}}”)): Unlock Unlimited Savings! Get ready to unlock a world of savings with our free TℰℳU Coupons! We’ve got you covered with a wide range of TℰℳU Coupon code options that will help you maximize your shopping experience. 100% Off TℰℳU Coupons, Promo Codes + 25% Cash Back ((“{{ '[''com31844'']}}”)) Redeem TℰℳU Coupon Code ((“{{ '[''com31844'']}}”)) TℰℳU Coupon $100OFF ((“{{ '[''com31844'']}}”)) TℰℳU Coupon $100OFF FOR EXISTING CUSTOMERS ((“{{ '[''com31844'']}}”)) TℰℳU Coupon $100OFF FIRST ORDER ((“{{ '[''com31844'']}}”)) TℰℳU Coupon $100OFF REDDIT ((“{{ '[''com31844'']}}”)) TℰℳU Coupon $100OFF FOR EXISTING CUSTOMERS REDDIT ((“{{ '[''com31844'']}}”)) TℰℳU $100OFF CODE ((“{{ '[''com31844'']}}”)) TℰℳU 70 OFF COUPON 2025 ((“{{ '[''com31844'']}}”)) DOMINOS 70 RS OFF COUPON CODE ((“{{ '[''com31844'']}}”)) WHAT IS A COUPON RATE ((“{{ '[''com31844'']}}”)) TℰℳU $100OFF FOR EXISTING CUSTOMERS ((“{{ '[''com31844'']}}”)) TℰℳU $100OFF FIRST ORDER ((“{{ '[''com31844'']}}”)) TℰℳU $100OFF FREE SHIPPING ((“{{ '[''com31844'']}}”)) You can get an exclusive $100off discount on your TℰℳU purchase with the code [{{ '[''com31844'']}}] Or [{{ '[''com31844'']}}].This code is specially designed for new customers and offers a significant price cut on your shopping. Make your first purchase on TℰℳU more rewarding by using this code to get $100off instantly.   TℰℳU Coupon Code For $100Off [{{ '[''com31844'']}}] Or [{{ '[''com31844'']}}]: Get A Flat $100Discount On Order Value Get ready to save big with our incredible TℰℳU coupon for $100off! Our coupon code will give you a flat $100discount on your order value, making your shopping experience even more rewarding.   Exclusive TℰℳU Discount Code [{{ '[''com31844'']}}] Or [{{ '[''com31844'']}}]: Flat $300 OFF for New and Existing Customers Using our TℰℳU promo code you can get A$ 200 off your order and 100% off using our TℰℳU promo code [{{ '[''com31844'']}}] Or [{{ '[''com31844'']}}]. As a new TℰℳU customer, you can save up to $100using this promo code. For returning users, our TℰℳU promo code offers a $100price slash on your next shopping spree. This is our way of saying thank you for shopping with us! Get ready to save big with our incredible TℰℳU Coupon code for $300 off! Our amazing TℰℳU $300 off coupon code will give you a flat $300 discount on your order value, making your shopping experience even more rewarding.   TℰℳU Coupon Code For 40% Off ["{com31844}"] For Both New And Existing Customers   Our incredible TℰℳU Coupon code for 40% off is here to help you save big on your purchases. Whether you’re a new user or an existing customer, our 40% off code for TℰℳU will give you an additional discount!   TℰℳU Coupon Bundle ["{com31844}"]: Flat $300 Off + Up To 90% Discount   Get ready for an unbelievable deal with our TℰℳU Coupon bundle for 2025! Our TℰℳU Coupon bundles will give you a flat $300 discount and an additional 40% off on top of it.   Free TℰℳU Coupons ["{com31844}"]: Unlock Unlimited Savings!   Get ready to unlock a world of savings with our free TℰℳU Coupons! We’ve got you covered with a wide range of TℰℳU Coupon code options that will help you maximize your shopping experience.   50% Off TℰℳU Coupons, Promo Codes + 25% Cash Back ["{com31844}"]   Redeem TℰℳU Coupon Code ["{com31844}"]   TℰℳU Coupon $300 OFF ["{com31844}"]   TℰℳU Coupon $300 OFF ["{com31844}"]   TℰℳU Coupon $300 OFF FOR EXISTING CUSTOMERS ["{com31844}"]   TℰℳU Coupon $300 OFF FIRST ORDER ["{com31844}"]   TℰℳU Coupon $300 OFF FIRST ORDER ["{com31844}"]   TℰℳU Coupon $300 OFF FOR EXISTING CUSTOMERS FREE SHIPPING USA ["{com31844}"]   TℰℳU Coupon $300 OFF HOW DOES IT WORK ["{com31844}"]   TℰℳU Coupon $300 OFF FOR EXISTING CUSTOMERS CANADA ["{com31844}"]   TℰℳU Coupon $300 OFF 2025 ["{com31844}"]   TℰℳU Coupon $300 OFF FOR NEW CUSTOMERS ["{com31844}"]   TℰℳU Coupon $300 OFF CANADA ["{com31844}"]   TℰℳU Coupon $300 OFF FOR EXISTING CUSTOMERS FIRST ORDER ["{com31844}"]   TℰℳU 300 OFF COUPON BUNDLE ["{com31844}"]   This TℰℳU coupon $300 off is designed to provide substantial savings on your purchases, making shopping for your favorite items easier than ever. With our $300 off TℰℳU coupon, you'll be amazed at how much you can save on your next order. Here are the key benefits you can expect when using our coupon code {com31844} "OR" {com31844}: {com31844} "OR" {com31844}: Flat $300 off on your purchase {com31844} "OR" {com31844}: $300 coupon pack for multiple uses {com31844} "OR" {com31844}: $300 flat discount for new customers {com31844} "OR" {com31844}: Extra $300 promo code for existing customers {com31844} "OR" {com31844}: $300 coupon exclusively for USA/Canada users H2: TℰℳU Coupon Code $300 Off For New Users In 2024 New users can reap the highest benefits by using our coupon code on the TℰℳU app. This TℰℳU coupon $300 off is specifically designed to welcome new customers with incredible savings  
    • Now the serve runs for a bit, then crashes after 20 minutes of running, what's the issue here? apologies if I need to start a new post and didn't https://pastebin.com/uBpp5bCz  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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