Big fancy shaders
This commit is contained in:
parent
86603bf729
commit
dbc620aa03
@ -31,8 +31,8 @@ void main()
|
|||||||
vec2 baseUV = fragTexCoord;
|
vec2 baseUV = fragTexCoord;
|
||||||
|
|
||||||
// Use a wave function to translate the pixel UV
|
// Use a wave function to translate the pixel UV
|
||||||
float X = baseUV.x*5.+time;
|
float X = baseUV.x*0.5+time;
|
||||||
float Y = baseUV.y*5.+time;
|
float Y = baseUV.y*0.5+time;
|
||||||
baseUV.y += cos(X+Y)*0.01*cos(Y);
|
baseUV.y += cos(X+Y)*0.01*cos(Y);
|
||||||
baseUV.x += sin(X-Y)*0.01*sin(Y);
|
baseUV.x += sin(X-Y)*0.01*sin(Y);
|
||||||
|
|
||||||
|
@ -65,7 +65,12 @@ impl InGameScreen {
|
|||||||
width: game_core.resources.background_back.width as f32,
|
width: game_core.resources.background_back.width as f32,
|
||||||
height: game_core.resources.background_back.height as f32,
|
height: game_core.resources.background_back.height as f32,
|
||||||
},
|
},
|
||||||
Rectangle::new(0.0,0.0, (game_core.resources.background_back.width * 2) as f32, (game_core.resources.background_back.height * 2) as f32),
|
Rectangle::new(
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
(game_core.resources.background_back.width * 2) as f32,
|
||||||
|
(game_core.resources.background_back.height * 2) as f32,
|
||||||
|
),
|
||||||
Vector2 { x: 0.0, y: 0.0 },
|
Vector2 { x: 0.0, y: 0.0 },
|
||||||
0.0,
|
0.0,
|
||||||
Color::WHITE,
|
Color::WHITE,
|
||||||
@ -78,7 +83,12 @@ impl InGameScreen {
|
|||||||
width: game_core.resources.background_front.width as f32,
|
width: game_core.resources.background_front.width as f32,
|
||||||
height: game_core.resources.background_front.height as f32,
|
height: game_core.resources.background_front.height as f32,
|
||||||
},
|
},
|
||||||
Rectangle::new(0.0 ,0.0, (game_core.resources.background_front.width * 2) as f32,(game_core.resources.background_front.height * 2) as f32),
|
Rectangle::new(
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
(game_core.resources.background_front.width * 2) as f32,
|
||||||
|
(game_core.resources.background_front.height * 2) as f32,
|
||||||
|
),
|
||||||
Vector2 { x: 0.0, y: 0.0 },
|
Vector2 { x: 0.0, y: 0.0 },
|
||||||
0.0,
|
0.0,
|
||||||
Color::WHITE,
|
Color::WHITE,
|
||||||
@ -251,13 +261,22 @@ impl Screen for InGameScreen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the shader's internal time
|
||||||
|
unsafe {
|
||||||
|
let time_var_location = raylib::ffi::GetShaderLocation(
|
||||||
|
*game_core.resources.pixel_shader,
|
||||||
|
rstr!("time").as_ptr(),
|
||||||
|
);
|
||||||
|
game_core.resources.pixel_shader.set_shader_value(time_var_location, draw_handle.get_time() as f32);
|
||||||
|
}
|
||||||
|
|
||||||
// Render the 2D context via the ripple shader
|
// Render the 2D context via the ripple shader
|
||||||
{
|
{
|
||||||
let mut shader_context =
|
let mut shader_context =
|
||||||
draw_handle.begin_shader_mode(&game_core.resources.pixel_shader);
|
draw_handle.begin_shader_mode(&game_core.resources.pixel_shader);
|
||||||
|
|
||||||
// Blit the texture
|
// Blit the texture
|
||||||
shader_context.draw_texture_rec(
|
shader_context.draw_texture_pro(
|
||||||
&game_core.resources.shader_texture,
|
&game_core.resources.shader_texture,
|
||||||
Rectangle {
|
Rectangle {
|
||||||
x: 0.0,
|
x: 0.0,
|
||||||
@ -265,7 +284,14 @@ impl Screen for InGameScreen {
|
|||||||
width: game_core.resources.shader_texture.width() as f32,
|
width: game_core.resources.shader_texture.width() as f32,
|
||||||
height: (game_core.resources.shader_texture.height() as f32) * -1.0,
|
height: (game_core.resources.shader_texture.height() as f32) * -1.0,
|
||||||
},
|
},
|
||||||
|
Rectangle {
|
||||||
|
x: -10.0,
|
||||||
|
y: -10.0,
|
||||||
|
width: win_width as f32 + 20.0,
|
||||||
|
height: win_height as f32 + 20.0
|
||||||
|
},
|
||||||
Vector2::zero(),
|
Vector2::zero(),
|
||||||
|
0.0,
|
||||||
Color::WHITE,
|
Color::WHITE,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user