Notifications
Article
How we created Immortal Redneck's sand rendering
Published 3 years ago
513
0
Creating sand is not easy and we ran into some problems while doing it – this is how we overcame them
Hi there. I'm Bruno Louviers, Community Manager of CremaGames, and I'm here to talk about sand. Yes, I know it sounds strange, but you see: Immortal Redneck is a game set in Egypt, so it's unavoidable to have sand almost everywhere. Even if the main scenarios are indoors, we needed beautiful, fine sand, and that’s exactly what we have created. 
Let’s take a look.

WHAT WE WANTED

While designing the rooms of Immortal Redneck, we wanted to create sand piles based on the terrain. It was a easy task, but we also wanted these piles of sand to be meshes we could bring into each particular scene very easily. Here two examples of our first attempts.
As you can imagine, we didn’t fancy how the mesh and the terrain mixed together. It seemed outdated and didn’t look like sand at all once it was on the floor, so we had to create a specific shader so we could make very detailed and soft transitions between the sand piles and the floor.

ABOUT THAT SHADER

We really wanted the ability to ‘paint’ some surfaces with sand, and to achieve this, we developed a shader that uses the vertex colors to show the correct amout of floor and/or sand. We hated the idea of using the typical blend, so the shader is configured to show the sand texture according to the floor heightmap. Obviously, the texture has a planar projection to ignore the UV mapping so it can tile correctly.
Here’s how the shader looks in shader forge, if you are curious
And here’s a little demo so you can see how it works. This is how we paint sand…
And this is how we ‘erase’ it. Actually, we are just playing with opposed values: black for painting, white for erasing.
We had a little problem with the shader, though. When the terrain mesh and the painted shader mixed, the transition was a little too obvious. Like this, actually:
The problem was caused by the vertex normals, you know, those vectors that are perpendicular to a given face. The way they worked, the sand’s and the terrain’s normals were not aligned in the intersections: the first one pointed in whatever direction the geometry was pointing and the other one was just vertical, since the floor is a horizontal plane. This was an issue since we needed both meshes working together, so the solution was to create a specific tool to match the normals. This way, they would be pointing vertically in the intersection.

ABOUT THE TOOL

Carlos, our programmer, created the tool we needed, but since he is such a great, awesome programmer – and a true Simpsons fan, too –, he ended up creating two modes in the tool: one that changed all the vertices and another that only affected the edges. The last one is the one we are using at the moment.
We first tried to change all the normals’ vertices, but even if the transition was smooth this time, the light was acting a little weird. After all, the camera ‘saw’ every surface flat because all the normals in the mesh we were pointing vertically. So now, we needed to adapt it again, and that’s why the tool can also only change the vertexes in the edges of the mesh. Since this is a bit technical, it’s easier just to see what we mean.
In this image, you have the mesh normals, unaffected by our tool. See those lines in the edge of the mesh? That’s what made the cut so abrupt.
Now, when we apply the tool to all vertex, the normals end up like this. See how the light is strange?
And finally, we use tool only on the edges, so the floor and the sand point in the same direction only when needed, but the rest of the mesh acts normally, unaffected.
Also, here you can see our problem with the light. Shadows were just wrong and didn’t look natural at all in the first place, but in the end, everything looked great.

SANDPAINTING

With all of this already explained, I can just show you how cool it looks when you ‘paint’ with sand. It's not actually painting at all, but you know...
And that’s all for now, folks. 
We believe overcoming obstacles without expending much development time is crucial when you are a small indie team, and thankfully, we are achieving our goals and Immortal Redneck is growing fast. We wanted to share with everyone how we created a cool rendering and solved the problems of pulling it out, so we hope you find this post interesting. 
Thanks for reading!

ABOUT US

CremaGames is a young studio located in Madrid, Spain. We've been developing for three years now and we have achieved some success of our own thanks to apps like Instant Buttons and smartphones games like Oh My Goat, Ridiculous Triathlon and Ridiculous Marathon. Immortal Redneck is our first PC game ever and it's going to be a huge challenge, but we are grateful we can give it a try in a new environment. We are self-publishing it at the moment.
If you've read Immortal Redneck description in our profile, you'll already know that it's an arcade FPS set in Epygt with roguelite elements like permadeath, randomly generated rooms, skills and guns you can improve with gold and a very particular twist: the money you earn playing can only be spent after you die and before a new run, so you can't save it. Oh, and the main character is a very wacky folk that somehow has ended up being a immortal mummy that fights demons and fantasy creatures inside three colossal pyramids. A very normal situation, if you ask me.
So, like it already? Hope so!
Nathaniel Ventura
Product Marketing Manager - Marketer
38
Comments