newb-x-mcbe icon indicating copy to clipboard operation
newb-x-mcbe copied to clipboard

Revamp shading

Open devendrn opened this issue 2 months ago • 48 comments

All changes made to this branch will be for testing, and will include redundant code and comments.

Changes in mind for this PR:

  • New sky model
  • Update lighting
  • Improve clouds
  • Improve fog
sunrise rain during sunrise noon sun reflection on water

Please report any issue with these changes. Feedback will really help.

New Sky

Features

  • Custom sun/moon rotation (yaw, tilt) . Also removes in-game sun/moon scaling effect when looking at it.
  • 2d sky based on sun/moon direction (old one was 1d, with extra overlay effects)
  • New cube sun texture (based on current moon texture)
  • Rainbow positioning based on sun direction (also rainbow is now enabled by default during rain). Reduced rainbow width also.
  • Sun/moon light present in sky reflections and fog now (TODO: Make this a brighter for reflection and dimmer for fog?)

Known issues:

  • ~~Moon abtruptly changing position right after midnight (FIXED)~~
  • Disabled underwater streak. need to update it (TOFIX)
  • ~~Sun/Moon flickering near sunrise/sunset (FIXED)~~
  • ~~Dark blob artifact at sun/moon center in some devices (FIXED)~~

Updated Lighting

Features

  • New lighting logic (also moved all lighting logic to vertex shader itself). No more hacky torchlight dimming in sunlight region. Now it blends properly with sun light.
  • Improved day/night transition using sun direction
  • Improved dawn lighting. Slight sunlight gradient fade during sunrise.
  • Correct cloud shadow projection (also enabled cloud shadow on terrain by default)

Known issuer:

  • Need to update actor,items shading to match terrain (TODO)
  • Need to update underwater lighting (TODO)

Update clouds

Features

  • Move clouds with minecraft world position (for rounded, realistic)
  • Cloud reflection now matches correctly with actual cloud plane and is now present for terrain reflection aswell.
  • Improve clouds lighting (TODO)

Other changes

Features

  • Improve water and lava noise (TODO)

devendrn avatar Oct 22 '25 18:10 devendrn

🔥🔥🔥

xLynxiummcx avatar Oct 22 '25 21:10 xLynxiummcx

Can someone test sun moon rotation for windows?

devendrn avatar Oct 23 '25 18:10 devendrn

ok

BatmanBinSuparman49 avatar Oct 23 '25 18:10 BatmanBinSuparman49

Sun/moon rotation in Windows | Minecraft - 1.21.114 @devendrn https://streamable.com/th7wqb

BatmanBinSuparman49 avatar Oct 24 '25 05:10 BatmanBinSuparman49

Batman saves the day 🗣️🔥🔥

faizul726 avatar Oct 24 '25 06:10 faizul726

Can someone test simple, rounded, and realistic clouds movement on windows? It should change with camera position.

devendrn avatar Oct 27 '25 17:10 devendrn

Can someone test simple, rounded, and realistic clouds movement on windows? It should change with camera position.

doing a little bit later @devendrn

faizul726 avatar Oct 27 '25 18:10 faizul726

Clouds 3: https://streamable.com/kn6fle

Clouds 2: https://streamable.com/w121kn

Clouds 1: https://streamable.com/wtn1bx

@devendrn

BatmanBinSuparman49 avatar Oct 27 '25 18:10 BatmanBinSuparman49

doing a little bit later @devendrn

Batman saves the day again

faizul726 avatar Oct 27 '25 18:10 faizul726

doing a little bit later @devendrn

Batman saves the day again

Windows User

BatmanBinSuparman49 avatar Oct 27 '25 18:10 BatmanBinSuparman49

@devendrn build pack -p windows fails

image

default Clouds was successful

faizul726 avatar Oct 27 '25 18:10 faizul726

@faizul726 try again. I made a typo previously.

devendrn avatar Oct 27 '25 18:10 devendrn

@devendrn there's an animated artifact on the sun

see

https://github.com/user-attachments/assets/92f753be-b828-4d11-acc0-014313f95722

https://github.com/user-attachments/assets/d679be4f-b9bd-415a-969b-43d62b14d04c

also, the sun side during rain is a little too bright

faizul726 avatar Oct 27 '25 18:10 faizul726

@faizul726 when you are free later, check if that sun artifact happens with fully transparent sun texture.

devendrn avatar Oct 27 '25 19:10 devendrn

happens with fully transparent image also

image image

and moon is also affected by this issue

@devendrn

faizul726 avatar Oct 28 '25 05:10 faizul726

image

It's doesn't happen to me @faizul726 It could be a GPU issue @devendrn

Also Fazul, send that transparent sun.png and let me try

BatmanBinSuparman49 avatar Oct 28 '25 07:10 BatmanBinSuparman49

image

Sky is too bright when looking at the side of the sun during rain

BatmanBinSuparman49 avatar Oct 28 '25 07:10 BatmanBinSuparman49

@faizul726 does this artifact happen when you set mg8 to 0.0?

# src/newb/functions/sky.h
-  float mg8 = (g8.x+g8.y)*mask*(1.0-0.9*env.rainFactor);
+  float mg8 = 0.0;

devendrn avatar Oct 28 '25 18:10 devendrn

@devendrn it's 12 am here right now. i will try to test in morning.

also i am updating minecraft to v1.21.120 (which broke materials again)

so you may want to update the material source once again.

faizul726 avatar Oct 28 '25 18:10 faizul726

image still happens @devendrn

faizul726 avatar Oct 29 '25 04:10 faizul726

@faizul726 are you sure you applied the change properly?

Try again. If it still shows up, try with this change instead:

# src/newb/functions/sky.h
-  vec2 g = 0.5 - 0.5*vec2(dot(env.sunDir, viewDir), dot(env.moonDir, viewDir));
+  vec2 g = vec2_splat(0.0);

devendrn avatar Oct 29 '25 18:10 devendrn

@devendrn i just checked again to be sure. let me try the new fix shortly...

https://github.com/user-attachments/assets/4cc034be-97f6-4468-9263-cb7c77130068

faizul726 avatar Oct 30 '25 05:10 faizul726

assuming i am supposed to revert the previous change (mg8) and build new Sky material.

this is what it looks like now

https://github.com/user-attachments/assets/866ada20-22ba-4f67-b85a-f2c86488aff3

faizul726 avatar Oct 30 '25 05:10 faizul726

By the way, did you remove Weather material from source? It seems to no longer build it when I run build mats -p windows.

faizul726 avatar Oct 30 '25 05:10 faizul726

I just noticed there's a black blob sometimes glitching, even through solid blocks. I think that can be the sun (or moon?)

faizul726 avatar Oct 30 '25 05:10 faizul726

Just a reminder that there are several visual changes. Feedback is needed for me to know whether these changes are moving in the right direction or wrong direction and no new issues are introduced. If lighting could use further improvement, this is the place to comment.

I update the PR heading message every commit to include current changes and to-do changes. Please refer that before testing or giving feedback. https://github.com/devendrn/newb-x-mcbe/pull/52#issue-3541988564

devendrn avatar Oct 31 '25 20:10 devendrn

@devendrn sky being bright in rain issue is fixed. and the blob thing is still there, as well as the dot on sun/moon. build from latest commit. I have attached a video for you to see.

Screenshot_20251101-102826 Screenshot_20251101-102902 Screenshot_20251101-102928 Screenshot_20251101-103011 Screenshot_20251101-103023 Screenshot_20251101-103102 Screenshot_20251101-103114 Screenshot_20251101-103128 Screenshot_20251101-103142 Screenshot_20251101-103221

https://github.com/user-attachments/assets/f615e9f1-1917-4296-af0f-3355d3936363

faizul726 avatar Nov 01 '25 04:11 faizul726

@faizul726 try testing with this change:

# src/newb/functions/sky.h
-  vec2 g = 0.5 - 0.5*vec2(dot(env.sunDir, viewDir), dot(env.moonDir, viewDir));
+  vec2 g = vec2_splat(1.0);

devendrn avatar Nov 01 '25 08:11 devendrn

@devendrn no longer happens. but the glow is gone now.

image

faizul726 avatar Nov 01 '25 17:11 faizul726

Maybe clamping this value could fix this issue. @faizul726 Try this:

# src/newb/functions/sky.h
-  vec2 g = 0.5 - 0.5*vec2(dot(env.sunDir, viewDir), dot(env.moonDir, viewDir));
+  vec2 g = clamp(0.5 - 0.5*vec2(dot(env.sunDir, viewDir), dot(env.moonDir, viewDir)), 0.0, 1.0);

devendrn avatar Nov 01 '25 17:11 devendrn