ShaderMaterial basic point custom vertex shader

Hi ! I wanted to create a custom shader based on points (using gl_PointSize). But I couldn’t find any example of custom shader. I would need something really simple like three has, probably only the vertex shader. I don’t want to use or extend Babylon shaders.

Here what I’ve tried as vertex shader :

precision highp float;

attribute vec3 position;

//uniform mat4 worldViewProjection;
uniform mat4 viewProjection;

uniform float uRadius;

void main() {
gl_Position = viewProjection * vec4(position, 1.0);
gl_PointSize = 10. * uRadius;
}

I’ve tried every projection possible that babylon gives but none of them gave anything.

Hi Corentin,

To help me understand, are you looking for samples for a particular shader feature, or just for custom shaders in general? There are a few examples using custom shaders in the docs (you can search for “shader” in the bar on the left of that page). If you’re looking for a more specific example, you might try searching the library of Playgrounds; results are by no means curated, but people have made examples of all sorts of cool things.

Also, if you’re looking to make custom shaders, you should definitely check out Babylon’s new Node Material Editor. It might be more than you need right now, as it sounds like you’re just looking to use a simple shader you’ve already written. But if you’re looking to make brand new shaders, this thing is really cool. Deltakosh made a video about how to use materials from there as custom shaders, in case that’d be helpful.