Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Hey! That variable (uLightingAmbience) is unused, so you can delete it along with the reference to shdrLighting. 

The draw event code should be placed in a lighting control object, and you can draw the lights you want in the commented portion inside that draw event. Lights are circles, or sprites, or whatever other shape you want. 

(1 edit)

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.

Hm, that's interesting. I'm no longer maintaining this project (it's almost 4 years old), but I may put up the source later tonight. I don't remember if the blur surface is still being used, but I'm confident the emission one is. If major features are missing from export, they've been missing for four years, which is a little funny that it's gone unnoticed for so long.

(+2)

I uploaded a patch that adds the emissive step in and cleans up the names/surfaces. There was a bug causing emission code to only be included when you had "No emission" selected, which was the opposite of the intention. Enjoy!

(+2)

Oh wow, that's so funny! Honestly, thank you for updating the project even though it's been so long since you initially posted it! I appreciate it!