Godot Shader:无需建模用一张图片在Godot中生成一座山

Godot Shader:无需建模用一张图片在Godot中生成一座山

原理类似置换贴图,只不过还想借助生成的高度区分出海面山体以及山顶的树木
效果不理想。没有办法像Blender那样在材质层次混合,要实现PBR效果只能靠引入大量的材质贴图。下面简述一下制作的思路

效果图

1. 在Godot中新建一个PlaneMeshInstance


增加细分

2.贴图制作

一张Perlin Noise

一张遮罩


把噪声和遮罩以类似相乘的方式叠加一下

3.着色器代码
shader_type spatial;
uniform sampler2D height_map : hint_white; 
uniform float height_scale = 1.0;
uniform float uv_scale : hint_range(0.1,2.0) = 1.0;
uniform vec4 water_color : hint_color;
uniform vec4 stone_color : hint_color;
uniform vec4 tree_color : hint_color;varying float height;void vertex(){VERTEX.y = height = texture(height_map,UV * uv_scale).y * height_scale;
}void fragment(){if(height < 0.1){ALBEDO = water_color.rgb;}else if(height < 0.2){ALBEDO = stone_color.rgb;}else{ALBEDO = tree_color.rgb;}
}
4.材质

发布者:admin,转转请注明出处:http://www.yc00.com/news/1692633109a621551.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信