Skip to content

[Feature request] Allow engine-managed extra textures for custom shaders #1532

Description

@Vareniel

Is your feature request related to a problem? Please describe.

I’d like to use NoiseTexture2d or other engine textures as extra samplers in custom shaders. Right now it works nicely as Sprite.image or normalMap, but for custom shader effects like distortion I still need to manually create/bind WebGL textures.
Describe the solution you'd like

A small engine-managed API for passing extra textures into custom shaders, for example:
sprite.setShaderTexture("uNoise", noiseTexture);

or:

sprite.shaderTextures = {
	uNoise: noiseTexture,
};

Then melonJS could handle upload/cache/bind and sampler uniforms internally, instead of user code touching raw WebGL texture units.

Describe alternatives you've considered

The current workaround is manually creating WebGL textures, binding them to texture units, and setting sampler uniforms by hand. It works, but it feels outside the normal melonJS texture pipeline and can get messy with custom shader/editor workflows.

Additional context

This would make procedural textures like NoiseTexture2d easier to use in custom shaders, not only as Sprite.image or normalMap, but also as extra inputs for effects like UV distortion, dissolve masks, flow maps, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions