@latel88/pixel

1.3.0 • Public • Published

Pixel

install

npm install @latel88/pixel
  • cjs
const Pixel = require( "@latel88/pixel" ).default;
  • mjs
import Pixel from "@latel88/pixel";

exsample

const canvas = document.createElement( "canvas" );
const gl = canvas.getContext( "webgl2" );

const width = 200;
const height = 300;

const hour = 3.14;

const static_texture = new Uint8Array( width * height * 4 );
const animation_texture = new Float32Array( width * height );
const normal = new Uint8Array( width * height * 4);
const depth = new Uint8Array( width * height * 4);

const pixel = new Pixel(
{
	"geometory": `#version 300 es

		uniform ivec2: screen_size;
		uniform sampler2D static_texture_data;

		location (layout = 0) vec4 normal;

		void main ()
		{
			normal = vec4(vec3(1., 0., 0.), 1.);

		}

	`,

	"lighting": `#version 300 es

		uniform ivec2: screen_size;
		uniform sampler2D animation_texture_data;
		uniform sampler2D normal;

		location (layout = 0) vec4 screen;

		void main ()
		{
			screen = dot( normal, vec3(0.1, 0.5, 0.25) );

		}

	`,

	"color": `#version 300 es

		uniform ivec2: screen_size;
		uniform sampler2D screen;
		uniform float hour;

		out vec4 color;

		void main ()
		{
			color = vec4(1, 1, 1, 1) * (screen.r * 2. - 1.);

		}

	`
	
 }, `#version 300 es
	precision highp float;
	precision highp int;

	layout(location = 0) in vec2 pos;

	void main()
	{
		gl_Position = vec4(pos, 0.0, 1.0);
		
	}

` );

pixel.rendering( gl,
{
	0: {
		format: 4,
		data: static_texture.buffer,

		width,
		height,

		sync: false

	},

	1: {
		type: "32f",
		format: 1,
		data: animation_texture.buffer,

		width,
		height,

		sync: true

	},

	2: {
		attachment: { geometory: 0 },
		type: "32f",
		format: 4,
		data: depth.buffer,

		width,
		height,

	}

},
{
	screen_size: {
		type: "2i",
		value: [ canvas.width, canvas.height ]

	},

	hour: {
		type: "1f",
		value: [ hour ]

	},

	static_texture_data: {
		unit: 0

	},

	animation_texture_data: {
		unit: 1

	},

	normal: {
		unit 2

	}

} );

Readme

Keywords

none

Package Sidebar

Install

npm i @latel88/pixel

Weekly Downloads

0

Version

1.3.0

License

MIT

Unpacked Size

75.8 kB

Total Files

11

Last publish

Collaborators

  • latel88