Skip to main content

Posts

Showing posts from September, 2016

Procedural Cactus

I have been trying to procedurally generate cactuses. You can see the results  here  (refresh the page to get a new cactus). This was made mostly as a learning experience but it could have applications in a game. If a game had a dessert and needed a large amount of cactus models for example. It was made with three.js and WebGl. The source code is available here . To make the cactus we start with a UV sphere. The actual sphere has a lot more vertices, but mostly looks like the picture below. Next we have to rough it up a bit. We loop through the vertices with 3 things to do. First, make the vertical knots going down the cactus. Second is to save the vertices were we want to add spines. Finally we want to add a bit of randomness to our cactus as we go down it. To make the knots we just pull out all of the vertices that have an index that is a multiple of 4. Because of the way we ordered the vertices these will be in vertical lines going down. As we are pullin...

Chromatic Aberration

I made a chromatic aberration shader after not finding one I liked online. You can see the effect above on the sprite bottle to the right. My goal was to make a stylized chromatic aberration effect that I could apply to any sprite. The effect works by separating the rgb channels and displacing them in different directions. Below you can see the blue and red channels getting displaced in opposite directions on the x axis.  You can control the displacement easily with a script to change how extreme the effect is. I personally think the effect looks best when used subtlety but I could see some cool applications were it is controlled dynamically and combined with a screen shake or something to show a large impact. Here is the effect applied more subtlety on a cool rogue sprite Here is a link to the shader Here is an example C# script to control it