M
Murr_
Guest
So i was digging shader's some time a week ago. And now, i'm trying to do this thing <last topic ref.>. So i have a SURFACE which acts as a cloud atmosphere, which sets a shader (Gussian Blur) to make it more volumetric. (used Xor's shader for this, combined the x/y shader code together).
I have a global.gussian_CloudActive variable, to call if its activated or not. Regen fixes the surface if it is resized. When i set the shader along with the drawn BG it doesn't seem to add the effect nor show the BG.
shd_Gussian_cloud
[ Fragment ]
oSURFOverworld
CREATE_EVENT
DRAW_BEGIN EVENT
The problem is, that it's not visible. Possibly something having to do with the vec2 variables or the views that fix the resized surface. I don't know for sure. Any pointers?
I have a global.gussian_CloudActive variable, to call if its activated or not. Regen fixes the surface if it is resized. When i set the shader along with the drawn BG it doesn't seem to add the effect nor show the BG.
shd_Gussian_cloud
[ Fragment ]
Code:
varying vec2 v_texcoord;
uniform float time;
uniform vec2 mouse_pos;
uniform vec2 resolution;
uniform float blur_xAmount;
uniform float blur_yAmount;
void main()
{
float blur_xSize = 1.0/resolution.x * blur_xAmount;
float blur_ySize = 1.0/resolution.y * blur_yAmount;
vec4 sum = vec4(0.0);
sum += texture2D(gm_BaseTexture, vec2(v_texcoord.x - 4.0 * blur_xSize, v_texcoord.y)) * 0.05;
sum += texture2D(gm_BaseTexture, vec2(v_texcoord.x - 3.0 * blur_xSize, v_texcoord.y)) * 0.09;
sum += texture2D(gm_BaseTexture, vec2(v_texcoord.x - 2.0 * blur_xSize, v_texcoord.y)) * 0.12;
sum += texture2D(gm_BaseTexture, vec2(v_texcoord.x - blur_xSize, v_texcoord.y)) * 0.15;
sum += texture2D(gm_BaseTexture, vec2(v_texcoord.x, v_texcoord.y)) * 0.16;
sum += texture2D(gm_BaseTexture, vec2(v_texcoord.x + blur_xSize, v_texcoord.y)) * 0.15;
sum += texture2D(gm_BaseTexture, vec2(v_texcoord.x + 2.0 * blur_xSize, v_texcoord.y)) * 0.12;
sum += texture2D(gm_BaseTexture, vec2(v_texcoord.x + 3.0 * blur_xSize, v_texcoord.y)) * 0.09;
sum += texture2D(gm_BaseTexture, vec2(v_texcoord.x + 4.0 * blur_xSize, v_texcoord.y)) * 0.05;
sum += texture2D(gm_BaseTexture, vec2(v_texcoord.x, v_texcoord.y- 4.0 * blur_ySize)) * 0.05;
sum += texture2D(gm_BaseTexture, vec2(v_texcoord.x, v_texcoord.y- 3.0 * blur_ySize)) * 0.09;
sum += texture2D(gm_BaseTexture, vec2(v_texcoord.x, v_texcoord.y - 2.0 * blur_ySize)) * 0.12;
sum += texture2D(gm_BaseTexture, vec2(v_texcoord.x, v_texcoord.y - blur_ySize)) * 0.15;
sum += texture2D(gm_BaseTexture, vec2(v_texcoord.x, v_texcoord.y)) * 0.16;
sum += texture2D(gm_BaseTexture, vec2(v_texcoord.x, v_texcoord.y + blur_ySize)) * 0.15;
sum += texture2D(gm_BaseTexture, vec2(v_texcoord.x, v_texcoord.y + 2.0 *blur_ySize)) * 0.12;
sum += texture2D(gm_BaseTexture, vec2(v_texcoord.x, v_texcoord.y + 3.0 * blur_ySize)) * 0.09;
sum += texture2D(gm_BaseTexture, vec2(v_texcoord.x, v_texcoord.y + 4.0 * blur_ySize)) * 0.05;
gl_FragColor = sum;
}
CREATE_EVENT
Code:
/// Initialize the surface ******************************************************************************************************************
global.gussian_CloudActive = true;
prevViewX = view_xview[0];
prevViewY = view_yview[0];
surf_overworld = surface_create(room_width, room_height);
// Scrolling clouds on the SURF *************************************************************************************************************
/* Scroll speed */
hspeed = 0.3;
scroll_num = 0.13;
Code:
/// Draws the oSURF: Overworld **************************************************************************************************************
scroll_num += hspeed;
// Creates surface if not already done ******************************************************************************************************
if ( global.gussian_CloudActive ) {
var regen = false;
//Recreate surface if window is minimised
if (!surface_exists(surf_overworld)) {
regen = true;
surf_overworld = surface_create(room_width, room_height);
}
//Order regeneration if the view position has changed
if ( view_xview[0] != prevViewX ) || ( view_yview[0] != prevViewY ) {
regen = true;
}
if (regen) {
surface_set_target(surf_overworld);
draw_clear_alpha(c_black, 0);
shader_set(shd_Gussian_cloud);
draw_background_tiled(MAP_overworld_cloud_1, scroll_num, 0);
draw_surface_ext(surf_overworld, 0, 0, 10, 10, 0, c_black, 0.2);
shader_reset();
surface_reset_target();
}
}