fix transparency & add glass
This commit is contained in:
		| @@ -17,12 +17,13 @@ const float gamma = 2.2; | |||||||
|  |  | ||||||
|  |  | ||||||
| void main() { | void main() { | ||||||
|  | 	outputColor = texture(tex, fragTexCoord); | ||||||
|  | 	if (outputColor.a < 1e-3) | ||||||
|  | 		discard; | ||||||
|  |  | ||||||
| 	outputPosition.xyz = fragPosWorld; | 	outputPosition.xyz = fragPosWorld; | ||||||
| 	outputPosition.w = fragDepthView; | 	outputPosition.w = fragDepthView; | ||||||
| 	outputNormal.xyz = fragNormal; | 	outputNormal.xyz = fragNormal; | ||||||
| 	outputNormal.w = fragPosLightspaceZ; | 	outputNormal.w = fragPosLightspaceZ; | ||||||
| 	outputColor = texture(tex, fragTexCoord); |  | ||||||
| 	outputColor = vec4(outputColor.rgb, outputColor.a); |  | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								internal/asset/texture/world/glass.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								internal/asset/texture/world/glass.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 147 B | 
| @@ -24,7 +24,7 @@ const ( | |||||||
| 	PlayerPlaceCooldown = 200 * time.Millisecond | 	PlayerPlaceCooldown = 200 * time.Millisecond | ||||||
| ) | ) | ||||||
|  |  | ||||||
| var placeId = [10]int{blocks.Stone, blocks.Dirt, blocks.Grass, blocks.LogOak, blocks.PlanksOak, blocks.LeavesOak, blocks.Debug, blocks.DebugDir, blocks.Bedrock, blocks.Water} | var placeId = [10]int{blocks.Stone, blocks.Dirt, blocks.Grass, blocks.LogOak, blocks.PlanksOak, blocks.LeavesOak, blocks.Glass, blocks.DebugDir, blocks.Bedrock, blocks.Water} | ||||||
| var placei = 0 | var placei = 0 | ||||||
|  |  | ||||||
| var logs string | var logs string | ||||||
|   | |||||||
| @@ -129,6 +129,7 @@ func (g *Game) initRender() (err error) { | |||||||
| 	r.texture.GenerateMipMap() | 	r.texture.GenerateMipMap() | ||||||
| 	gl.BindTexture(gl.TEXTURE_2D, r.texture.Handle()) | 	gl.BindTexture(gl.TEXTURE_2D, r.texture.Handle()) | ||||||
| 	gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAX_ANISOTROPY, maxaf) | 	gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAX_ANISOTROPY, maxaf) | ||||||
|  | 	r.depthmap.shader.SetUniformTexture("tex", r.texture) | ||||||
| 	r.gbuffer.shader.SetUniformTexture("tex", r.texture) | 	r.gbuffer.shader.SetUniformTexture("tex", r.texture) | ||||||
| 	r.water.shader.SetUniformTexture("tex", r.texture) | 	r.water.shader.SetUniformTexture("tex", r.texture) | ||||||
| 	igwrap.SetTextureFlag(r.texture.Handle(), igwrap.TextureFlag_Linear, igwrap.TextureFlag_FlipY) | 	igwrap.SetTextureFlag(r.texture.Handle(), igwrap.TextureFlag_Linear, igwrap.TextureFlag_FlipY) | ||||||
|   | |||||||
| @@ -20,6 +20,8 @@ const ( | |||||||
|  |  | ||||||
| 	Water | 	Water | ||||||
|  |  | ||||||
|  | 	Glass | ||||||
|  |  | ||||||
| 	Count | 	Count | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -35,13 +37,15 @@ func init() { | |||||||
| 	world.RegisterBlockBehaviour(7, world.BlockBehaviourStatic(world.BlockAppearance{Name: "bedrock"})) | 	world.RegisterBlockBehaviour(7, world.BlockBehaviourStatic(world.BlockAppearance{Name: "bedrock"})) | ||||||
| 	world.RegisterBlockBehaviour(8, world.BlockBehaviourStatic(world.BlockAppearance{Name: "sand"})) | 	world.RegisterBlockBehaviour(8, world.BlockBehaviourStatic(world.BlockAppearance{Name: "sand"})) | ||||||
| 	world.RegisterBlockBehaviour(9, world.BlockBehaviourStatic(world.BlockAppearance{Name: "log_oak", RenderType: world.ThreeTexture})) | 	world.RegisterBlockBehaviour(9, world.BlockBehaviourStatic(world.BlockAppearance{Name: "log_oak", RenderType: world.ThreeTexture})) | ||||||
| 	world.RegisterBlockBehaviour(10, world.BlockBehaviourStatic(world.BlockAppearance{Name: "leaves_oak"})) | 	world.RegisterBlockBehaviour(10, world.BlockBehaviourStatic(world.BlockAppearance{Name: "leaves_oak", Transparent: true})) | ||||||
|  |  | ||||||
| 	world.RegisterBlockBehaviour(11, world.BlockBehaviourStatic(world.BlockAppearance{Name: "planks_oak"})) | 	world.RegisterBlockBehaviour(11, world.BlockBehaviourStatic(world.BlockAppearance{Name: "planks_oak"})) | ||||||
|  |  | ||||||
| 	world.RegisterBlockBehaviour(12, WaterBehaviour{}) | 	world.RegisterBlockBehaviour(12, WaterBehaviour{}) | ||||||
|  |  | ||||||
| 	if Count != 13 { | 	world.RegisterBlockBehaviour(13, world.BlockBehaviourStatic(world.BlockAppearance{Name: "glass", Transparent: true})) | ||||||
|  |  | ||||||
|  | 	if Count != 14 { | ||||||
| 		panic("world.DefaultBlocks: block count not correct (check for block numbering in default_blocks.go)") | 		panic("world.DefaultBlocks: block count not correct (check for block numbering in default_blocks.go)") | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user