@@ -170,10 +170,10 @@ public void resetBuffer() {
170170 }
171171
172172 private MeshData buildClouds (Tesselator tesselator , int centerCellX , int centerCellZ , double cloudY ) {
173- final int upFaceColor = ColorUtil . RGBA . pack ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
174- final int xDirColor = ColorUtil . RGBA . pack ( 0.9f , 0.9f , 0.9f , 1.0f ) ;
175- final int downFaceColor = ColorUtil . RGBA . pack ( 0.7f , 0.7f , 0.7f , 1.0f ) ;
176- final int zDirColor = ColorUtil . RGBA . pack ( 0.8f , 0.8f , 0.8f , 1.0f ) ;
173+ final float upFaceBrightness = 1.0f ;
174+ final float xDirBrightness = 0.9f ;
175+ final float downFaceBrightness = 0.7f ;
176+ final float zDirBrightness = 0.8f ;
177177
178178 BufferBuilder bufferBuilder = tesselator .begin (VertexFormat .Mode .QUADS , DefaultVertexFormat .POSITION_COLOR );
179179
@@ -186,50 +186,57 @@ private MeshData buildClouds(Tesselator tesselator, int centerCellX, int centerC
186186 for (int cellZ = -renderDistance ; cellZ < renderDistance ; ++cellZ ) {
187187 int cellIdx = this .cloudGrid .getWrappedIdx (centerCellX + cellX , centerCellZ + cellZ );
188188 byte renderFaces = this .cloudGrid .renderFaces [cellIdx ];
189+ int baseColor = this .cloudGrid .pixels [cellIdx ];
189190
190191 float x = cellX * CELL_WIDTH ;
191192 float z = cellZ * CELL_WIDTH ;
192193
193194 if ((renderFaces & DIR_POS_Y_BIT ) != 0 && cloudY <= 0.0f ) {
194- putVertex (bufferBuilder , x + CELL_WIDTH , CELL_HEIGHT , z + CELL_WIDTH , upFaceColor );
195- putVertex (bufferBuilder , x + CELL_WIDTH , CELL_HEIGHT , z + 0.0f , upFaceColor );
196- putVertex (bufferBuilder , x + 0.0f , CELL_HEIGHT , z + 0.0f , upFaceColor );
197- putVertex (bufferBuilder , x + 0.0f , CELL_HEIGHT , z + CELL_WIDTH , upFaceColor );
195+ final int color = ColorUtil .ARGB .multiplyRGB (baseColor , upFaceBrightness );
196+ putVertex (bufferBuilder , x + CELL_WIDTH , CELL_HEIGHT , z + CELL_WIDTH , color );
197+ putVertex (bufferBuilder , x + CELL_WIDTH , CELL_HEIGHT , z + 0.0f , color );
198+ putVertex (bufferBuilder , x + 0.0f , CELL_HEIGHT , z + 0.0f , color );
199+ putVertex (bufferBuilder , x + 0.0f , CELL_HEIGHT , z + CELL_WIDTH , color );
198200 }
199201
200202 if ((renderFaces & DIR_NEG_Y_BIT ) != 0 && cloudY >= -CELL_HEIGHT ) {
201- putVertex (bufferBuilder , x + 0.0f , 0.0f , z + CELL_WIDTH , downFaceColor );
202- putVertex (bufferBuilder , x + 0.0f , 0.0f , z + 0.0f , downFaceColor );
203- putVertex (bufferBuilder , x + CELL_WIDTH , 0.0f , z + 0.0f , downFaceColor );
204- putVertex (bufferBuilder , x + CELL_WIDTH , 0.0f , z + CELL_WIDTH , downFaceColor );
203+ final int color = ColorUtil .ARGB .multiplyRGB (baseColor , downFaceBrightness );
204+ putVertex (bufferBuilder , x + 0.0f , 0.0f , z + CELL_WIDTH , color );
205+ putVertex (bufferBuilder , x + 0.0f , 0.0f , z + 0.0f , color );
206+ putVertex (bufferBuilder , x + CELL_WIDTH , 0.0f , z + 0.0f , color );
207+ putVertex (bufferBuilder , x + CELL_WIDTH , 0.0f , z + CELL_WIDTH , color );
205208 }
206209
207210 if ((renderFaces & DIR_POS_X_BIT ) != 0 && (x < 1.0f || insideClouds )) {
208- putVertex (bufferBuilder , x + CELL_WIDTH , CELL_HEIGHT , z + CELL_WIDTH , xDirColor );
209- putVertex (bufferBuilder , x + CELL_WIDTH , 0.0f , z + CELL_WIDTH , xDirColor );
210- putVertex (bufferBuilder , x + CELL_WIDTH , 0.0f , z + 0.0f , xDirColor );
211- putVertex (bufferBuilder , x + CELL_WIDTH , CELL_HEIGHT , z + 0.0f , xDirColor );
211+ final int color = ColorUtil .ARGB .multiplyRGB (baseColor , xDirBrightness );
212+ putVertex (bufferBuilder , x + CELL_WIDTH , CELL_HEIGHT , z + CELL_WIDTH , color );
213+ putVertex (bufferBuilder , x + CELL_WIDTH , 0.0f , z + CELL_WIDTH , color );
214+ putVertex (bufferBuilder , x + CELL_WIDTH , 0.0f , z + 0.0f , color );
215+ putVertex (bufferBuilder , x + CELL_WIDTH , CELL_HEIGHT , z + 0.0f , color );
212216 }
213217
214218 if ((renderFaces & DIR_NEG_X_BIT ) != 0 && (x > -1.0f || insideClouds )) {
215- putVertex (bufferBuilder , x + 0.0f , CELL_HEIGHT , z + 0.0f , xDirColor );
216- putVertex (bufferBuilder , x + 0.0f , 0.0f , z + 0.0f , xDirColor );
217- putVertex (bufferBuilder , x + 0.0f , 0.0f , z + CELL_WIDTH , xDirColor );
218- putVertex (bufferBuilder , x + 0.0f , CELL_HEIGHT , z + CELL_WIDTH , xDirColor );
219+ final int color = ColorUtil .ARGB .multiplyRGB (baseColor , xDirBrightness );
220+ putVertex (bufferBuilder , x + 0.0f , CELL_HEIGHT , z + 0.0f , color );
221+ putVertex (bufferBuilder , x + 0.0f , 0.0f , z + 0.0f , color );
222+ putVertex (bufferBuilder , x + 0.0f , 0.0f , z + CELL_WIDTH , color );
223+ putVertex (bufferBuilder , x + 0.0f , CELL_HEIGHT , z + CELL_WIDTH , color );
219224 }
220225
221226 if ((renderFaces & DIR_POS_Z_BIT ) != 0 && (z < 1.0f || insideClouds )) {
222- putVertex (bufferBuilder , x + 0.0f , CELL_HEIGHT , z + CELL_WIDTH , zDirColor );
223- putVertex (bufferBuilder , x + 0.0f , 0.0f , z + CELL_WIDTH , zDirColor );
224- putVertex (bufferBuilder , x + CELL_WIDTH , 0.0f , z + CELL_WIDTH , zDirColor );
225- putVertex (bufferBuilder , x + CELL_WIDTH , CELL_HEIGHT , z + CELL_WIDTH , zDirColor );
227+ final int color = ColorUtil .ARGB .multiplyRGB (baseColor , zDirBrightness );
228+ putVertex (bufferBuilder , x + 0.0f , CELL_HEIGHT , z + CELL_WIDTH , color );
229+ putVertex (bufferBuilder , x + 0.0f , 0.0f , z + CELL_WIDTH , color );
230+ putVertex (bufferBuilder , x + CELL_WIDTH , 0.0f , z + CELL_WIDTH , color );
231+ putVertex (bufferBuilder , x + CELL_WIDTH , CELL_HEIGHT , z + CELL_WIDTH , color );
226232 }
227233
228234 if ((renderFaces & DIR_NEG_Z_BIT ) != 0 && (z > -1.0f || insideClouds )) {
229- putVertex (bufferBuilder , x + CELL_WIDTH , CELL_HEIGHT , z + 0.0f , zDirColor );
230- putVertex (bufferBuilder , x + CELL_WIDTH , 0.0f , z + 0.0f , zDirColor );
231- putVertex (bufferBuilder , x + 0.0f , 0.0f , z + 0.0f , zDirColor );
232- putVertex (bufferBuilder , x + 0.0f , CELL_HEIGHT , z + 0.0f , zDirColor );
235+ final int color = ColorUtil .ARGB .multiplyRGB (baseColor , zDirBrightness );
236+ putVertex (bufferBuilder , x + CELL_WIDTH , CELL_HEIGHT , z + 0.0f , color );
237+ putVertex (bufferBuilder , x + CELL_WIDTH , 0.0f , z + 0.0f , color );
238+ putVertex (bufferBuilder , x + 0.0f , 0.0f , z + 0.0f , color );
239+ putVertex (bufferBuilder , x + 0.0f , CELL_HEIGHT , z + 0.0f , color );
233240 }
234241
235242 }
@@ -241,15 +248,17 @@ private MeshData buildClouds(Tesselator tesselator, int centerCellX, int centerC
241248 for (int cellZ = -renderDistance ; cellZ < renderDistance ; ++cellZ ) {
242249 int cellIdx = this .cloudGrid .getWrappedIdx (centerCellX + cellX , centerCellZ + cellZ );
243250 byte renderFaces = this .cloudGrid .renderFaces [cellIdx ];
251+ int baseColor = this .cloudGrid .pixels [cellIdx ];
244252
245253 float x = cellX * CELL_WIDTH ;
246254 float z = cellZ * CELL_WIDTH ;
247255
248256 if ((renderFaces & DIR_NEG_Y_BIT ) != 0 ) {
249- putVertex (bufferBuilder , x + 0.0f , 0.0f , z + CELL_WIDTH , upFaceColor );
250- putVertex (bufferBuilder , x + 0.0f , 0.0f , z + 0.0f , upFaceColor );
251- putVertex (bufferBuilder , x + CELL_WIDTH , 0.0f , z + 0.0f , upFaceColor );
252- putVertex (bufferBuilder , x + CELL_WIDTH , 0.0f , z + CELL_WIDTH , upFaceColor );
257+ final int color = ColorUtil .ARGB .multiplyRGB (baseColor , upFaceBrightness );
258+ putVertex (bufferBuilder , x + 0.0f , 0.0f , z + CELL_WIDTH , color );
259+ putVertex (bufferBuilder , x + 0.0f , 0.0f , z + 0.0f , color );
260+ putVertex (bufferBuilder , x + CELL_WIDTH , 0.0f , z + 0.0f , color );
261+ putVertex (bufferBuilder , x + CELL_WIDTH , 0.0f , z + CELL_WIDTH , color );
253262 }
254263
255264 }
0 commit comments