Skip to content

Commit

Permalink
Some changes
Browse files Browse the repository at this point in the history
- Updated README.md
- Added simple cloud shadow
  • Loading branch information
devendrn committed Dec 4, 2023
1 parent 12c1b40 commit 8fcab35
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ Nightly builds for Android (ESSL) and Windows (DX) can be found at [Discord serv
1. Use [BetterRenderDragon](https://github.com/ddf8196/BetterRenderDragon) to enable MaterialBinLoader.
2. Import resource pack and activate it in global resources.

## Building
#### Android:
1. Install [Patched Minecraft app (Only for 64-bit)](https://github.com/DominoKorean/Render-dragon-shader-list/blob/main/patchedapp.md)
2. Import resource pack and activate it in global resources.

## Building

#### Windows:
1. Setup build evironment:
Expand Down
1 change: 1 addition & 0 deletions include/newb_config_legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#define NL_CAVE_BRIGHTNESS 0.1 // 0.0 dark ~ 2.0 bright
#define NL_SHADOW_INTENSITY 0.7 // 0.0 no shadow ~ 1.0 strong shadow
//#define NL_BLINKING_TORCH // [toggle] flickering light
//#define NL_CLOUD_SHADOW // [toggle] cloud shadow (simple clouds only)

/* Sun/moon light color on terrain */
#define NL_MORNING_SUN_COL vec3(1.0,0.45,0.14)
Expand Down
31 changes: 14 additions & 17 deletions include/newb_legacy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ float calculateFresnel(float cosR, float r0) {
/* CLOUDS */
// 2D cloud noise - used by clouds
// simple clouds noise
float cloudNoise2D(vec2 p, highp float t, float rain) {
t *= NL_CLOUD1_SPEED;
p += t;
Expand Down Expand Up @@ -328,7 +328,7 @@ float bevel(float x, float r) {
return (1.0-r)*(1.0-sqrt(1.0-y*y));
}

float cloud_sdf(vec3 pos, float rain) {
float cloud_df(vec3 pos, float rain) {
vec2 p0 = floor(pos.xz);
vec2 u = smoothstep(0.99*NL_CLOUD2_SHAPE,0.995,pos.xz-p0);
vec2 v = 1.0 - u;
Expand Down Expand Up @@ -361,7 +361,7 @@ vec4 render_clouds(vec3 vDir, vec3 vPos, float rain, float time, vec3 fog_col, v
vec3 d = vec3(0.0,1.0,1.0);
for (int i=0; i<NL_CLOUD2_STEPS; i++) {
pos += delta_p;
float m = cloud_sdf(pos.xyz, rain);
float m = cloud_df(pos.xyz, rain);
d.x += m*NL_CLOUD2_DENSITY*(1.0-d.x)/NL_CLOUD2_STEPS.0;
d.y = mix(d.y, pos.y, d.z);
d.z *= 1.0 - m;
Expand Down Expand Up @@ -422,15 +422,10 @@ vec3 sunLightTint(float dayFactor, float rain, vec3 FOG_COLOR) {
dayFactor), r*r);
}
// bool between function
bool is(float val, float val1, float val2) {
return (val > val1 && val < val2);
}
/* IMPLEMENTATION */
vec3 nl_lighting(out vec3 torchColor, vec3 COLOR, vec3 FOG_COLOR, float rainFactor, vec2 uv1, vec2 lit, bool isTree,
vec3 nl_lighting(vec3 wPos, out vec3 torchColor, vec3 COLOR, vec3 FOG_COLOR, float rainFactor, vec2 uv1, vec2 lit, bool isTree,
vec3 horizonCol, vec3 zenithCol, float shade, bool end, bool nether, bool underwater, highp float t) {
// all of these will be multiplied by tex uv1 in frag so functions should be divided by uv1 here
Expand Down Expand Up @@ -480,6 +475,11 @@ vec3 nl_lighting(out vec3 torchColor, vec3 COLOR, vec3 FOG_COLOR, float rainFact
shadow = max(shadow, (1.0 - NL_SHADOW_INTENSITY + (0.6*NL_SHADOW_INTENSITY*nightFactor))*lit.y);
shadow *= shade > 0.8 ? 1.0 : 0.8;

// shadow cast by simple cloud
#ifdef NL_CLOUD_SHADOW
shadow *= 1.0 - cloudNoise2D(wPos.xz*NL_CLOUD1_SCALE, t, rainFactor);
#endif

// direct light from top
float dirLight = shadow*(1.0-uv1.x*nightFactor)*lightIntensity;
light += dirLight*sunLightTint(dayFactor, rainFactor, FOG_COLOR);
Expand Down Expand Up @@ -555,7 +555,7 @@ vec4 nl_water(inout vec3 wPos, inout vec4 color, vec3 viewDir, vec3 light, vec3
// torch light reflection
waterRefl += torchColor*NL_TORCH_INTENSITY*(lit.x*lit.x + lit.x)*bump*10.0;

if (is(fractCposY, 0.8, 0.9)) {
if (fractCposY>0.8 || fractCposY<0.9) {
// flat plane
waterRefl *= 1.0 - clamp(wPos.y, 0.0, 0.66);
} else {
Expand Down Expand Up @@ -685,17 +685,14 @@ void nl_wave(inout vec3 worldPos, inout vec3 light, float rainFactor, vec2 uv1,
bool isChain = bPosC.x==0.0625 && y6875;

// fix for non-hanging lanterns waving top part (works only if texPosY is correct)
if (y5625 && (texPosY < 0.3 || is(texPosY, 0.55, 0.69))) {
if (y5625 && (texPosY < 0.3 || (texPosY>0.55 && texPosY<0.69))) {
isLantern = false;
}

// X,Z axis rotation
if (uv1.x > 0.6 && (isChain || isLantern)) {
// wave phase diff for individual lanterns
float offset = dot(floor(cPos), vec3_splat(0.3927));

// simple random wave for angle
highp vec2 theta = vec2(t + offset, t*1.4 + offset);
float phase = dot(floor(cPos), vec3_splat(0.3927));
highp vec2 theta = vec2(t + phase, t*1.4 + phase);
theta = sin(vec2(theta.x,theta.x+0.7)) + rainFactor*sin(vec2(theta.y,theta.y+0.7));
theta *= NL_LANTERN_WAVE*windStrength;

Expand All @@ -704,6 +701,7 @@ void nl_wave(inout vec3 worldPos, inout vec3 light, float rainFactor, vec2 uv1,

vec3 pivotPos = vec3(0.5,1.0,0.5) - bPos;

// apply XZ rotation
worldPos.x += dot(pivotPos.xy, vec2(1.0-cosA.x, -sinA.x));
worldPos.y += dot(pivotPos, vec3(sinA.x*cosA.y, 1.0-cosA.x*cosA.y, sinA.y));
worldPos.z += dot(pivotPos, vec3(sinA.x*sinA.y, -cosA.x*sinA.y, 1.0-cosA.y));
Expand Down Expand Up @@ -774,7 +772,6 @@ vec3 nl_actor_lighting(vec3 pos, vec4 normal, mat4 world, vec4 tileLightCol, vec
N.y *= tileLightCol.w;
N.xz *= N.xz;

//intensity = (0.5 + N.y*0.5)*0.5 - N.x*0.1 + N.z*0.1 + 0.5;
intensity = 0.75 + N.y*0.25 - N.x*0.1 + N.z*0.1;
intensity *= intensity;
#else
Expand Down
2 changes: 1 addition & 1 deletion materials/RenderChunk/src/RenderChunk.vertex.sc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void main() {
#endif

vec3 torchColor; // modified by nl_lighting
vec3 light = nl_lighting(torchColor, a_color0.rgb, FogColor.rgb, rainFactor,uv1, lit, isTree,
vec3 light = nl_lighting(worldPos, torchColor, a_color0.rgb, FogColor.rgb, rainFactor,uv1, lit, isTree,
horizonCol, zenithCol, shade, end, nether, underWater, t);

#if defined(ALPHA_TEST) && (defined(NL_PLANTS_WAVE) || defined(NL_LANTERN_WAVE))
Expand Down

0 comments on commit 8fcab35

Please sign in to comment.