<commit_before>import luxe.Color;
import luxe.Input;
import luxe.Log;
import luxe.Rectangle;
import luxe.Sprite;
import luxe.Vector;
import phoenix.Batcher;
import phoenix.RenderTexture;
import phoenix.Texture;
import luxe.Parcel;
import phoenix.Shader;

class Main extends luxe.Game {
	// use a render texture for the "lightmap"
	var lightRenderTexture:RenderTexture;
	// it also needs it's own geometry batcher
	var lightBatcher:Batcher;

	// set the ambient colour to a deep blue for a nice nighttime effect
	var ambientColor:Vector = new Vector(0.3, 0.3, 0.7, 0.7);

	// sprite that will get rendered into the lightmap rendertexture
	var lightSprite:Sprite;
	var campfireLight:Sprite;
	var occluderSprite:Sprite;

	// a shader that all lit entities must use
	var lightShader:Shader;

	// the main background level
	var levelSprite:Sprite;

	// three types of occlusion textures to play with
	var occlusionTexture_solid:Texture;
	var occlusionTexture_rims:Texture;
	var occlusionTexture_gradient:Texture;

	// a timer to make the fire light flicker nicely
	var fireUpdateNextTime:Float = 0;

	override function ready() {
		// load the parcel
		Luxe.loadJSON("assets/parcel.json", function(jsonParcel) {
			var parcel = new Parcel();
			parcel.from_json(jsonParcel.json);

			// show a loading bar
			// use a fancy custom loading bar (https://github.com/FuzzyWuzzie/CustomLuxePreloader)
			new DigitalCircleParcelProgress({
				parcel: parcel,
				oncomplete: assetsLoaded
			});
			
			// start loading!
			parcel.load();
		});
	} //ready

	function assetsLoaded(_) {
		// create a level sprite to display in the background
		levelSprite = new Sprite({
			texture: Luxe.resources.find_texture('assets/level.png'),
			pos: Luxe.screen.mid,
			size: new Vector(960, 640),
			depth: 0
		});
		levelSprite.texture.filter = phoenix.Texture.FilterType.nearest;

		// --- NOW LIGHTS ---

		// create a render texture for the lights
		lightRenderTexture = new RenderTexture(Luxe.resources, new Vector(1024, 1024));

		// and a batcher for all the lights
		lightBatcher = Luxe.renderer.create_batcher({
			name: 'lights_batcher',
			no_add: true
		});
		// set the batcher's viewport to be the same as the main camera
		lightBatcher.view.viewport = Luxe.camera.viewport;

		// create the light sprite which will render to the lightRenderTexture
		lightSprite = new Sprite({
			texture: Luxe.resources.find_texture('assets/light.png'),
			pos: Luxe.screen.mid,
			size: new Vector(128, 128),
			batcher: lightBatcher,
			color: new Color().rgb(0xffe786)
		});
		lightSprite.texture.filter = phoenix.Texture.FilterType.nearest;

		// create the campfire light in the same way as the mouse light
		campfireLight = new Sprite({
			texture: Luxe.resources.find_texture('assets/light.png'),
			pos:Luxe.screen.mid,
			size: new Vector(256, 256),
			batcher: lightBatcher,
			color: new Color().rgb(0xff4d07)
		});

		// load the various occlusion textures
		occlusionTexture_solid = Luxe.resources.find_texture('assets/occlusion_solid.png');
		occlusionTexture_rims = Luxe.resources.find_texture('assets/occlusion_rims.png');
		occlusionTexture_gradient = Luxe.resources.find_texture('assets/occlusion_gradient.png');

		// make em nice and pixely
		occlusionTexture_solid.filter = phoenix.Texture.FilterType.nearest;
		occlusionTexture_rims.filter = phoenix.Texture.FilterType.nearest;
		occlusionTexture_gradient.filter = phoenix.Texture.FilterType.nearest;

		// create the occluder
		occluderSprite = new Sprite({
			texture: occlusionTexture_solid,
			pos: Luxe.screen.mid,
			size: new Vector(960, 640),
			depth: 997,
			batcher: lightBatcher
		});

		// load the light shader
		Luxe.loadShader('assets/light.glsl', 'default', function(shader:Shader) {
			// store the shader
			lightShader = shader;
			levelSprite.shader = lightShader;

			// set the ambient colour
			lightShader.set_vector4('ambientColor', ambientColor);

			// and the resolution (for lightmap texture lookup)
			lightShader.set_vector2('resolution', new Vector(1024, 1024));

			// move to the second slot
			lightRenderTexture.slot = 1;
			lightShader.set_texture('lightMap', lightRenderTexture);
		});
	}

	override function onkeyup( e:KeyEvent ) {

		if(e.keycode == Key.escape) {
			Luxe.shutdown();
		}
		// use the up and down keys to control the ambient light strength
		else if(e.keycode == Key.up) {
			ambientColor.w = Math.min(ambientColor.w + 0.1, 1);
			if(lightShader != null) {
				lightShader.set_vector4('ambientColor', ambientColor);
			}
		}
		else if(e.keycode == Key.down) {
			ambientColor.w = Math.max(ambientColor.w - 0.1, 0);
			if(lightShader != null) {
				lightShader.set_vector4('ambientColor', ambientColor);
			}<commit_msg>Figured out how the internal shader naming is defined for find_shader calls<commit_after>import luxe.Color;
import luxe.Input;
import luxe.Log;
import luxe.Rectangle;
import luxe.Sprite;
import luxe.Vector;
import phoenix.Batcher;
import phoenix.RenderTexture;
import phoenix.Texture;
import luxe.Parcel;
import phoenix.Shader;

class Main extends luxe.Game {
	// use a render texture for the "lightmap"
	var lightRenderTexture:RenderTexture;
	// it also needs it's own geometry batcher
	var lightBatcher:Batcher;

	// set the ambient colour to a deep blue for a nice nighttime effect
	var ambientColor:Vector = new Vector(0.3, 0.3, 0.7, 0.7);

	// sprite that will get rendered into the lightmap rendertexture
	var lightSprite:Sprite;
	var campfireLight:Sprite;
	var occluderSprite:Sprite;

	// a shader that all lit entities must use
	var lightShader:Shader;

	// the main background level
	var levelSprite:Sprite;

	// three types of occlusion textures to play with
	var occlusionTexture_solid:Texture;
	var occlusionTexture_rims:Texture;
	var occlusionTexture_gradient:Texture;

	// a timer to make the fire light flicker nicely
	var fireUpdateNextTime:Float = 0;

	override function ready() {
		// load the parcel
		Luxe.loadJSON("assets/parcel.json", function(jsonParcel) {
			var parcel = new Parcel();
			parcel.from_json(jsonParcel.json);

			// show a loading bar
			// use a fancy custom loading bar (https://github.com/FuzzyWuzzie/CustomLuxePreloader)
			new DigitalCircleParcelProgress({
				parcel: parcel,
				oncomplete: assetsLoaded
			});
			
			// start loading!
			parcel.load();
		});
	} //ready

	function assetsLoaded(_) {
		// create a level sprite to display in the background
		levelSprite = new Sprite({
			texture: Luxe.resources.find_texture('assets/level.png'),
			pos: Luxe.screen.mid,
			size: new Vector(960, 640),
			depth: 0
		});
		levelSprite.texture.filter = phoenix.Texture.FilterType.nearest;

		// --- NOW LIGHTS ---

		// create a render texture for the lights
		lightRenderTexture = new RenderTexture(Luxe.resources, new Vector(1024, 1024));

		// and a batcher for all the lights
		lightBatcher = Luxe.renderer.create_batcher({
			name: 'lights_batcher',
			no_add: true
		});
		// set the batcher's viewport to be the same as the main camera
		lightBatcher.view.viewport = Luxe.camera.viewport;

		// create the light sprite which will render to the lightRenderTexture
		lightSprite = new Sprite({
			texture: Luxe.resources.find_texture('assets/light.png'),
			pos: Luxe.screen.mid,
			size: new Vector(128, 128),
			batcher: lightBatcher,
			color: new Color().rgb(0xffe786)
		});
		lightSprite.texture.filter = phoenix.Texture.FilterType.nearest;

		// create the campfire light in the same way as the mouse light
		campfireLight = new Sprite({
			texture: Luxe.resources.find_texture('assets/light.png'),
			pos:Luxe.screen.mid,
			size: new Vector(256, 256),
			batcher: lightBatcher,
			color: new Color().rgb(0xff4d07)
		});

		// load the various occlusion textures
		occlusionTexture_solid = Luxe.resources.find_texture('assets/occlusion_solid.png');
		occlusionTexture_rims = Luxe.resources.find_texture('assets/occlusion_rims.png');
		occlusionTexture_gradient = Luxe.resources.find_texture('assets/occlusion_gradient.png');

		// make em nice and pixely
		occlusionTexture_solid.filter = phoenix.Texture.FilterType.nearest;
		occlusionTexture_rims.filter = phoenix.Texture.FilterType.nearest;
		occlusionTexture_gradient.filter = phoenix.Texture.FilterType.nearest;

		// create the occluder
		occluderSprite = new Sprite({
			texture: occlusionTexture_solid,
			pos: Luxe.screen.mid,
			size: new Vector(960, 640),
			depth: 997,
			batcher: lightBatcher
		});

		// setup the light shader
		lightShader = Luxe.resources.find_shader('assets/light.glsl|default');
		levelSprite.shader = lightShader;

		// set the ambient colour
		lightShader.set_vector4('ambientColor', ambientColor);

		// and the resolution (for lightmap texture lookup)
		lightShader.set_vector2('resolution', new Vector(1024, 1024));

		// move to the second slot
		lightRenderTexture.slot = 1;
		lightShader.set_texture('lightMap', lightRenderTexture);
	}

	override function onkeyup( e:KeyEvent ) {

		if(e.keycode == Key.escape) {
			Luxe.shutdown();
		}
		// use the up and down keys to control the ambient light strength
		else if(e.keycode == Key.up) {
			ambientColor.w = Math.min(ambientColor.w + 0.1, 1);
			if(lightShader != null) {
				lightShader.set_vector4('ambientColor', ambientColor);
			}
		}
		else if(e.keycode == Key.down) {
			ambientColor.w = Math.max(ambientColor.w - 0.1, 0);
			if(lightShader != null) {
				lightShader.set_vector4('ambientColor', ambientColor);
			}
{'fraction_non_alphanumeric': 0.10713529536311667, 'fraction_numerical': 0.015244547956807113, 'mean_word_length': 3.982594936708861, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5642403', 'n_tokens_mistral': 3463, 'n_tokens_neox': 3004, 'n_words': 803}