work on some water
This commit is contained in:
parent
26e49a1a5f
commit
6e5241c4cb
@ -2,7 +2,9 @@
|
||||
|
||||
cam : Camera = .{
|
||||
far = 2000.0,
|
||||
near = 1.0
|
||||
near = 1.0,
|
||||
target = .{0.0, 0.0, 0.0},
|
||||
position = .{10.0, 10.0, 10.0}
|
||||
};
|
||||
|
||||
#scope_export
|
||||
|
||||
@ -281,11 +281,35 @@ create_sky_pipeline :: () {
|
||||
gPipelines.sky.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer);
|
||||
}
|
||||
|
||||
create_plane_pipeline_reflection_image :: (binding: *sg_bindings) {
|
||||
reflection_img := sg_alloc_image();
|
||||
w, h := get_window_size();
|
||||
sg_init_image(*reflection_img, *(sg_image_desc.{
|
||||
width = w,
|
||||
height = h,
|
||||
pixel_format = sg_pixel_format.RGBA8,
|
||||
render_target = true
|
||||
}));
|
||||
binding.images[0] = reflection_img;
|
||||
|
||||
depth_img_desc := sg_image_desc.{
|
||||
render_target = true,
|
||||
width = w,
|
||||
height = h,
|
||||
pixel_format = sg_pixel_format.DEPTH_STENCIL,
|
||||
label = "depth-target-image"
|
||||
};
|
||||
|
||||
offscreen_depth_image := sg_make_image(*depth_img_desc);
|
||||
|
||||
}
|
||||
|
||||
create_plane_pipeline :: () {
|
||||
pipeline: sg_pipeline_desc;
|
||||
shader_desc := plane_shader_desc(sg_query_backend());
|
||||
pipeline.shader = sg_make_shader(*shader_desc);
|
||||
pipeline.layout.buffers[0].stride = 4*3;
|
||||
|
||||
|
||||
pipeline.layout.attrs[ATTR_plane_position] = .{ format = .FLOAT3, buffer_index = 0 };
|
||||
pipeline.index_type = .UINT16;
|
||||
@ -325,6 +349,7 @@ create_plane_pipeline :: () {
|
||||
|
||||
gPipelines.plane.bind.index_buffer = sg_make_buffer(*ibuffer);
|
||||
gPipelines.plane.bind.vertex_buffers[0] = sg_make_buffer(*vbuffer);
|
||||
create_plane_pipeline_reflection_image(*gPipelines.plane.bind);
|
||||
}
|
||||
|
||||
create_arbtri_pipeline :: () {
|
||||
@ -358,4 +383,5 @@ create_arbtri_pipeline :: () {
|
||||
min_filter = .NEAREST,
|
||||
mag_filter = .NEAREST,
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -13,7 +13,7 @@ out flat int idx;
|
||||
|
||||
void main() {
|
||||
vec3 multisize = vec3(position.xyz * 1000.0);
|
||||
gl_Position = mvp * (vec4(multisize.x, 0.0 + float(gl_InstanceIndex) * 0.003, multisize.z, 1.0));
|
||||
gl_Position = mvp * (vec4(multisize.x, 0.0 + float(gl_InstanceIndex) * 0.006, multisize.z, 1.0));
|
||||
pos = position;
|
||||
idx = gl_InstanceIndex;
|
||||
}
|
||||
@ -57,6 +57,8 @@ layout(binding=1) uniform plane_world_config {
|
||||
int planeType;
|
||||
|
||||
float time;
|
||||
|
||||
float grassDensity;
|
||||
};
|
||||
|
||||
#define hash(p) fract(sin(dot(p, vec2(11.9898, 78.233))) * 43758.5453)
|
||||
@ -101,7 +103,7 @@ void main() {
|
||||
if(planeType == 1) {
|
||||
frag_color = vec4(0.0, 0.0, 1.0, 1.0);
|
||||
} else {
|
||||
float density = 80000.0;
|
||||
float density = grassDensity;
|
||||
vec2 densifiedCoordinate = pos.xz * density;
|
||||
densifiedCoordinate.x += sin(densifiedCoordinate.y);
|
||||
densifiedCoordinate.y += sin(densifiedCoordinate.x);
|
||||
@ -109,12 +111,18 @@ void main() {
|
||||
|
||||
float noiseval_fine = noise(densifiedCoordinate / 50.0);
|
||||
float noiseval_coarse = noise(densifiedCoordinate / 500.0);
|
||||
float noiseval_plantti = noise(densifiedCoordinate / 500.0);
|
||||
if(noiseval_plantti < 0.9) {
|
||||
noiseval_plantti = 0.0;
|
||||
} else {
|
||||
noiseval_plantti = (noiseval_plantti - 0.9) * 10.0;
|
||||
}
|
||||
|
||||
float h = (1.0 / 128.0) * idx;
|
||||
float rand = (B(ruohokeskus) + sin(pos.x) * 0.4) * 0.5;
|
||||
rand += noiseval_coarse * 0.4 + noiseval_fine * 0.1;
|
||||
|
||||
ruohokeskus.x += sin(time * 1.2) * 0.6 * h;
|
||||
ruohokeskus.x += sin(time * 1.2) * 0.5 * h;
|
||||
|
||||
float distanceFromCenter = length(ruohokeskus - (densifiedCoordinate));
|
||||
|
||||
@ -130,11 +138,10 @@ void main() {
|
||||
if(idx > 0 && (rand - h) * thickness < distanceFromCenter) {
|
||||
discard;
|
||||
} else {
|
||||
frag_color = vec4(noiseval_coarse * 0.5, min(1.0, h + 0.2) + noiseval_fine * 0.2, 0.0, 1.0);
|
||||
vec4 grass_color = vec4(noiseval_coarse * 0.5, min(1.0, h + 0.2) + noiseval_fine * 0.2, 0.1, 1.0);
|
||||
vec4 plantti_color = vec4(h, h * 0.3, 0.0, 1.0);
|
||||
frag_color = mix(grass_color, plantti_color, noiseval_plantti);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@ -17,6 +17,7 @@ void main() {
|
||||
@end
|
||||
|
||||
@fs fs_sky
|
||||
|
||||
layout(binding=1) uniform sky_world_config {
|
||||
vec3 skyBase;
|
||||
vec3 skyTop;
|
||||
@ -35,6 +36,8 @@ layout(binding=1) uniform sky_world_config {
|
||||
int planeType;
|
||||
|
||||
float time;
|
||||
|
||||
float grassDensity;
|
||||
};
|
||||
|
||||
in vec4 pos;
|
||||
|
||||
@ -46,6 +46,8 @@ layout(binding=1) uniform trile_world_config {
|
||||
int planeType;
|
||||
|
||||
float time;
|
||||
|
||||
float grassDensity;
|
||||
};
|
||||
|
||||
in vec3 cam;
|
||||
|
||||
@ -45,6 +45,8 @@ layout(binding=1) uniform trixel_world_config {
|
||||
int planeType;
|
||||
|
||||
float time;
|
||||
|
||||
float grassDensity;
|
||||
};
|
||||
|
||||
in vec4 color;
|
||||
|
||||
@ -14,7 +14,9 @@ World_Config :: struct {
|
||||
|
||||
hasPlane : s32 = 0; @Slider,0,1,1
|
||||
planeHeight : float = 0.0; @Slider,-100,100,1
|
||||
planeType : s32 = 0; @Slider,0,2,1
|
||||
planeType : s32 = 1; @Slider,0,1,1
|
||||
|
||||
grassDensity : float = 40000; @Slider,10000,100000,1000
|
||||
}
|
||||
|
||||
// Copies over all the fields of our world config into a given shader type.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user