Discussions for Scenes for Version 1.2.X Fullscreen Mode here
Wszystko o iStripper
September 17, 2021, 5087 odpowiedzi
and the second part - with a one line overlap
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
vec2 Emu_Normalise_to_Window ( vec2 xy )
{ return EMU_NORMALISE_TO_WINDOW_1 ( xy, u_WindowSize.xy );
}
// ============================================================================
// == Shader specific inputs ==================================================
// ============================================================================
// EmuLib standard scale and hotspot parameters. Note, a hotspot of (0.5,0.5)
// is required to produce a symetric result.
uniform vec2 Emu_Shadow_scale;
uniform vec2 Emu_Shadow_hotspot;
vec2 scale = EMU_DEFAULT ( vec2, Emu_Shadow_scale, vec2(1.0) );
vec2 hotspot = EMU_DEFAULT ( vec2, Emu_Shadow_hotspot, vec2(0.0) );
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// The shear and taper for X and Y are specified by the following parameters.
// Value of zero for an axis produces no *****. Values are expected to
// be in the range -1.0 to +1.0, but values outside that range are valid. It
// is expected that taper would normaly only be used in a scene using a 2D
// camera, where rotations about the X or Y axes do not work, in order to get
// the effect of a long shadow tapering into the distance. In 3D scenes it is
// more natural to rotate about the X axis to acheive this effect.
uniform vec2 Emu_Shadow_shear;
uniform vec2 Emu_Shadow_taper;
#define shear Emu_Shadow_shear
#define taper Emu_Shadow_taper
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// The shadow's degree of blur is controlled by the following parameter which
// defaults to 0.0 corresponding to no blur. Values are expected to be in the
// range 0.0 to 10.0 but values outside that range are valid.
uniform float Emu_Shadow_blur;
#define blur Emu_Shadow_blur
// ============================================================================
// == Blur filter definition ==================================================
// ============================================================================
// The shadow is blurred using a simple one dimensional convolutional filter.
// The code used here was derived from that used for the more general filters
// in the TheEmuLib.Filters directory and their sources should be consulted
// if more information is wanted. A two dimensional blur could be used but it
// would not produce a significantly better result for a clipSprite shadow.
vec2 sample_step = vec2 ( blur/u_WindowSize.x, 1.0 );
#define BLUR QQ(-4.0,0.1) + QQ(-3.0,0.1) \
+ QQ(-2.0,0.1) + QQ(-1.0,0.1) \
+ QQ(0.0,0.2) \
+ QQ(+1.0,0.1) + QQ(+2.0,0.1) \
+ QQ(+3.0,0.1) + QQ(+4.0,0.1) \
#define CL(xy) clamp(xy,vec2(0.0),vec2(1.0))
#define TX(xy) texture2D ( iChannel0, CL(xy*sample_step+st) )
#define QQ(xx,ww) ( TX(vec2(xx,0.0)) * ww )
// ============================================================================
// == The shader's major functions ============================================
// ============================================================================
vec4 Emu_Shadow ( vec2 uv )
{
// Apply the transform with its fixed point at the hotspot. Note, the code
// here is the inverse of the required transform because we are determining
// what point in the source image will be transformed to the current pixel.
vec2 st = ( uv - hotspot ) / scale;
st = st - shear*st.yx;
st = st / ( 1.0 - taper*st.yx );
st = st + hotspot;
// Determine the colour using transparent black if the point
// lies outside of the area of the transformed source image.
return ( st == fract(abs(st)) ) ? (BLUR) : vec4(0.0);
}
// ============================================================================
// == The shader's main routine ===============================================
// ============================================================================
void main ( void )
{
// Get the normalised coordinates of the current point.
vec2 uv = Emu_Normalise_to_Window ( gl_FragCoord.xy );
// Apply the transform and update the shader's outputs.
gl_FragColor = Emu_Shadow(uv) * gl_Color;
}
// ============================================================================