Thanks for such the prompt response! I noticed that in the "create" event, two additional surfaces are created ('emissionSurf' and 'blrSurf') but they never get used anywhere. the circle drawing code in the draw event also doesn't seem to render anything in my game, I'm assuming that maybe it's supposed to be drawing to a separate surface other than 'lightSurf' but I'm not 100% sure. I also noticed that in the for loop at the end of the create event, the array names for the Gaussian blur arrays were both missing the 'u' at the beginning.
Since the editor demo itself runs perfectly, I'm sure the code is fine internally; but I think the code the demo is outputting may be incorrect since it doesn't work when copied into a new GameMaker project. Just for reference, this is the output I'm currently getting:
-------------------------------------------------------------------------
//Create Event
var cam = camera_get_active();
var camWidth = camera_get_view_width(cam);
var camHeight = camera_get_view_height(cam);
ambience = 0.20;
blurSteps = 8
blurIntensity = 0.50
lightStrength = 1;
uLightingAmbience = shader_get_uniform(shdrLighting, "ambience");
lightSurf = surface_create(camWidth, camHeight);
emissionSurf = surface_create(lSWidth, lSHeight); // for emissions
blrSurf = surface_create(lSWidth, lSHeight); // for blur (first pass)
uGaussSize = shader_get_uniform(shdrGaussian, "size");
uGaussIntensity = shader_get_uniform(shdrGaussian, "intensity");
//Must equal the GLSL ES constant Directions
#macro GAUSSIAN_DIRECTIONS 16
uGaussSines = shader_get_uniform(shdrGaussian, "sines");
uGaussCoses = shader_get_uniform(shdrGaussian, "coses");
var gaussInterval = 360 / GAUSSIAN_DIRECTIONS;
for (var i = 0; i < GAUSSIAN_DIRECTIONS; i++) {
gaussSines[i] = dsin(gaussInterval * i);
gaussCoses[i] = dcos(gaussInterval * i);
}
//Draw Event
var cam = camera_get_active();
var camWidth = camera_get_view_width(cam);
var camHeight = camera_get_view_height(cam);
// Subtractive Lighting
if (!surface_exists(lightSurf)) {
lightSurf = surface_create(camWidth, camHeight);
}
surface_set_target(lightSurf);
var lum = ambience * 255;
draw_clear_alpha(make_color_rgb(lum, lum, lum), 1.0);gpu_set_blendmode(bm_add);
// Draw Point Lights
var lightCol = make_color_hsv(0, 0, lightStrength * 255);
// Use below to draw a circle
//draw_circle_color(x, y, radius, lightCol, c_black, false);
surface_reset_target();
gpu_set_blendmode_ext(bm_zero, bm_src_color);
draw_surface(lightSurf, view_xview[0], view_yview[0]);
gpu_set_blendmode(bm_normal);
//Gaussian Shader
//
// Gaussian Shader
// Semi-Expensive Circular One-Pass Blur Shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec3 size; //width, height, radius
uniform float intensity;
const int Directions = 16; // must equal the GML macro
uniform float sines[Directions];
uniform float coses[Directions];
const int Quality = 8;
const float TwoPi = 6.283185307179586476925286766559; //one rotation of a circle
//Precalculate for loop constant requirements
const float qualityIts = 1.0 / float(Quality);
const float dirIts = TwoPi / float(Directions);
//Precalculate divisior of sum color product
float preSumDivisor = float(Quality) * float(Directions) * intensity + 1.0;
vec2 radius = size.z / size.xy;
void main()
{
vec4 Color = texture2D(gm_BaseTexture, v_vTexcoord);
for( int d = 0; d < Directions; d ++ ) {
vec2 displacement = vec2(coses[d], sines[d]) * radius;
for( float i = qualityIts; i <= 1.0; i += qualityIts ) {
Color += texture2D( gm_BaseTexture, v_vTexcoord + displacement * i);
}
}
Color /= preSumDivisor;
gl_FragColor = Color * v_vColour;
}
--------------------------------------------------------------------------
I'm also using GameMaker Studio 2 so I'm not sure if that makes a difference. I noticed there were a couple of deprecated function calls in the code but I updated them to their GMS2 equivalents so that shouldn't pose an issue anymore.