From bd9f57fe3d84d9bb2e3dc17ca7a1c9b3e497403a Mon Sep 17 00:00:00 2001 From: austin Date: Sat, 26 Apr 2025 22:34:07 -0400 Subject: [PATCH] block work --- assets/Data/entity/foliage/trees.json | 6 ++++ assets/Data/game/blockTypes.json | 16 ++++++++++ assets/Shaders/entities/block/block.fs | 12 ++++---- assets/Shaders/entities/blocksingle/block.fs | 12 ++++---- assets/Textures/block/glass1.png | Bin 0 -> 204682 bytes assets/Textures/block/roof1.png | Bin 0 -> 125468 bytes assets/Textures/block/woodfiber.png | Bin 0 -> 34365 bytes buildNumber.properties | 4 +-- docs/src/progress/renderertodo.md | 3 ++ .../game/data/block/BlockType.java | 28 ++++++++++++++++-- 10 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 assets/Textures/block/glass1.png create mode 100644 assets/Textures/block/roof1.png create mode 100644 assets/Textures/block/woodfiber.png diff --git a/assets/Data/entity/foliage/trees.json b/assets/Data/entity/foliage/trees.json index 75dfeb7e..a759e8f5 100644 --- a/assets/Data/entity/foliage/trees.json +++ b/assets/Data/entity/foliage/trees.json @@ -198,6 +198,12 @@ "rarity" : 0.8, "minQuantity" : 0, "maxQuantity" : 2 + }, + { + "itemId" : "block:wood", + "rarity" : 0.8, + "minQuantity" : 0, + "maxQuantity" : 5 } ] } diff --git a/assets/Data/game/blockTypes.json b/assets/Data/game/blockTypes.json index f17be9ac..4e0401e1 100644 --- a/assets/Data/game/blockTypes.json +++ b/assets/Data/game/blockTypes.json @@ -18,6 +18,22 @@ "id" : 3, "name" : "brick_fant", "texture" : "/Textures/block/ruin_wall_01.png" + }, + { + "id" : 4, + "name" : "roof_1", + "texture" : "/Textures/block/roof1.png" + }, + { + "id" : 5, + "name" : "refined_wood", + "texture" : "/Textures/block/woodfiber.png" + }, + { + "id" : 6, + "name" : "glass", + "texture" : "/Textures/block/glass1.png", + "transparent" : true } ] } \ No newline at end of file diff --git a/assets/Shaders/entities/block/block.fs b/assets/Shaders/entities/block/block.fs index 70db1fb0..ef80d9f3 100644 --- a/assets/Shaders/entities/block/block.fs +++ b/assets/Shaders/entities/block/block.fs @@ -39,7 +39,7 @@ out vec4 FragColor; // function prototypes -vec3 getColor(vec2 uv, vec3 normal, int samplerIndexVec, Material material); +vec4 getColor(vec2 uv, vec3 normal, int samplerIndexVec, Material material); void main(){ vec3 norm = normalize(Normal); @@ -49,7 +49,7 @@ void main(){ vec3 lightIntensity = vec3(calcLightIntensityTotal(norm)); //get color of base texture - vec3 textureColor = getColor(uv, norm, samplerIndexVec, material); + vec4 textureColor = getColor(uv, norm, samplerIndexVec, material); //shadow float shadow = ShadowCalculation(FragPosLightSpace, normalize(-directLight.direction), -norm); @@ -70,10 +70,10 @@ void main(){ } //calculate final color - vec3 finalColor = textureColor * lightIntensity * max(shadow,0.4); + vec3 finalColor = textureColor.rgb * lightIntensity * max(shadow,0.4); //this final calculation is for transparency - FragColor = vec4(finalColor, 1); + FragColor = vec4(finalColor, textureColor.a); } @@ -81,7 +81,7 @@ void main(){ * The function that gets the texture color based on the triplanar texture mapping and the voxel type at each point along the vert. * See the triplanar mapping wiki article for an explanation of math involved. */ -vec3 getColor(vec2 uv, vec3 normal, int samplerIndexVec, Material material){ +vec4 getColor(vec2 uv, vec3 normal, int samplerIndexVec, Material material){ //the uv of the texture clamped within the atlas vec2 actualUv = vec2( @@ -89,7 +89,7 @@ vec3 getColor(vec2 uv, vec3 normal, int samplerIndexVec, Material material){ (fract(uv.y) * ATLAS_NORMALIZED_ELEMENT_WIDTH) + (round(samplerIndexVec / ATLAS_EL_PER_ROW) * ATLAS_NORMALIZED_ELEMENT_WIDTH_FULL) ); //albedo for the X texture - vec3 color = texture(material.diffuse, actualUv).rgb; + vec4 color = texture(material.diffuse, actualUv); return color; diff --git a/assets/Shaders/entities/blocksingle/block.fs b/assets/Shaders/entities/blocksingle/block.fs index 9906fadb..5f20e658 100644 --- a/assets/Shaders/entities/blocksingle/block.fs +++ b/assets/Shaders/entities/blocksingle/block.fs @@ -39,7 +39,7 @@ out vec4 FragColor; // function prototypes -vec3 getColor(vec2 uv, vec3 normal, int blockIndex, Material material); +vec4 getColor(vec2 uv, vec3 normal, int blockIndex, Material material); void main(){ vec3 norm = normalize(Normal); @@ -49,7 +49,7 @@ void main(){ vec3 lightIntensity = vec3(calcLightIntensityTotal(norm)); //get color of base texture - vec3 textureColor = getColor(uv, norm, blockAtlasIndex, material); + vec4 textureColor = getColor(uv, norm, blockAtlasIndex, material); //shadow float shadow = ShadowCalculation(FragPosLightSpace, normalize(-directLight.direction), -norm); @@ -70,10 +70,10 @@ void main(){ } //calculate final color - vec3 finalColor = textureColor * lightIntensity * max(shadow,0.4); + vec3 finalColor = textureColor.rgb * lightIntensity * max(shadow,0.4); //this final calculation is for transparency - FragColor = vec4(finalColor, 1); + FragColor = vec4(finalColor, textureColor.a); } @@ -81,7 +81,7 @@ void main(){ * The function that gets the texture color based on the triplanar texture mapping and the voxel type at each point along the vert. * See the triplanar mapping wiki article for an explanation of math involved. */ -vec3 getColor(vec2 uv, vec3 normal, int blockIndex, Material material){ +vec4 getColor(vec2 uv, vec3 normal, int blockIndex, Material material){ //the uv of the texture clamped within the atlas vec2 actualUv = vec2( @@ -89,7 +89,7 @@ vec3 getColor(vec2 uv, vec3 normal, int blockIndex, Material material){ (fract(uv.y) * ATLAS_NORMALIZED_ELEMENT_WIDTH) + (round(blockIndex / ATLAS_EL_PER_ROW) * ATLAS_NORMALIZED_ELEMENT_WIDTH_FULL) ); //albedo for the X texture - vec3 color = texture(material.diffuse, actualUv).rgb; + vec4 color = texture(material.diffuse, actualUv); return color; diff --git a/assets/Textures/block/glass1.png b/assets/Textures/block/glass1.png new file mode 100644 index 0000000000000000000000000000000000000000..f1476c28282bae9ca0e30425bfa972e7d2243bcd GIT binary patch literal 204682 zcmeFXbx>U0(mpy^a2ed)LV~-yCAdq_!CeM-cMS;+!5u;Z!Ce#FHMqOm0CUNE-gCZl z>i(*3eO34O-Dsr`J}^0OOYuE30=im}+IO*u38hRGB|-5n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