Three.js sprites and custom shaders?

Do three.js sprites support custom shaders?

No. They have SpriteMaterial thing that holds your beer parameters for this shader. You can see that this shader is compiled once and is totally inaccessible from outside of SpritePlugin.

What do I do about this?

I just don't give a fuck

When I need to paint sprites with custom shader, I do it. How? Obviously, I have to overwrite whole original SpritePlugin code at some point before WebGLRenderer is created. This code is fairly stable, but changes do happen from time to time, so I would need to merge those changes whenever I switch to new three.js revision. Generally, I could just use the latest one, and leave update task for someone else to handle in the future.

But today I decided to do something different. I used whatever code was there in the engine and applied only small necessary changes to it on the fly. How? SpritePlugin.toString() → eval(). Here, check out the example:

click me

2 Responses to “Three.js sprites and custom shaders?”


  1. 1 Felix Turner (@felixturner) May 22, 2015 at 21:13

    That’s crazy but I guess it works :)


  1. 1 Three.js and 2D overlays | Coding on acid. Trackback on April 4, 2015 at 20:59

Ask a Question

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Old stuff

March 2015
M T W T F S S
« Jan   Apr »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Oh, btw…


%d bloggers like this: