- Home /
Replicating the Minecraft Acid Mod
Hi! I'm curious to know how this effect was achieved. http://www.youtube.com/watch?v=JpksyojwqzE I've had a look into projection matricies and post-processing effects, and I wondered if this could perhaps be how this was achieved.
It seems to have an ever-changing screen-space distortion map which affects items based on their distance, I thought might be a more complicated projection matrix, if such a thing exists. They claim to use a shader on their video, but that doesn't make sense to me - are shaders not material specific? This seems to work on the entire world.
Can anyone shed any light?
Answer by tanoshimi · Sep 14, 2013 at 11:07 PM
It is done with a GLSL shader, as stated in the link in the video description.
Note that "shader" can have slightly different meanings in different contexts - in Unity, "Shaders" are implemented through materials, which are then attached to individual gameobjects to define how they should be drawn to the screen. A "shader" in the general sense is a program executed on the graphics card to determine what pixel values should be displayed on the screen - they can apply to individual objects, parts of a scene, or the full world. Unity's "Image Effects" are basically just types of shader that affect the entire scene (rendered to a texture) rather than just objects in the scene. To make it more confusing, "Shaders" themselves are composed of one or more "Subshaders", which in turn contain a "Pixel Shader", "Fragment Shader", or "Surface Shader". It's not exactly the best nomenclature in the world :)
The particular shader used here looks to use a vertex modifier that uses a sinewave distortion over time multiplied by the distance to the vertex in x/z planes calculated in view space. It would certainly be possible to recreate this effect in Unity.
That's so helpful, thanks! So to replicate this I'm going to need Unity Pro? From what I read GLSL isn't too compatible with Unity, so I suppose I'll need to look into writing shaders for a bit. How intensive might you estimate this effect? I was hoping to get it running on mobile.
Just the effect I was looking for. Now my last subquestion - to avoid putting that shader on all my gameobjects, would I need to look into building an post-processing image effect so to apply it to the whole world?
Not necessarily - you could create "warped" versions of each of the shaders you used in the game, and then just swap them in via a script. Remember that although each of your gameobjects have their own material, many of those materials share the same shader, so you don't necessarily need that many shaders.
So, let's say all the materials in your game used either a Diffuse shader, a Bumped Diffuse shader, or a Specular shader. To warp the entire game world, you could create versions of each of these shaders based on their existing shader code and additionally incorporated the warping code. Then you could run a script that changed objects' shaders to their warped versions, as in the following (pseudo)code:
if(renderer.material.shader = Shader.Find ("Diffuse")){
// Switch to the warped diffuse shader
renderer.material.shader = Shader.Find ("Warped/Diffuse");
}
else if(renderer.material.shader = Shader.Find ("Specular")){
// Switch to the warped specular shader
renderer.material.shader = Shader.Find ("Warped/Specular");
}
...
I'm not saying this is the best way to do it, but it should work and it doesn't require any Pro features.
Sounds like a great solution, I'll have a peek into it. I'd quite like to explore making it a post-effect too - would you have any advice for where to start hunting? Doesn't seem to be much documentation on building your own. Thanks, by the way, I love this community! :D
Your answer
Follow this Question
Related Questions
Change projection matrix for each objects 0 Answers
_WorldSpaceCameraPos and converting to object space 1 Answer
Is it possible to use a single function for OnRenderImage AND [ImageEffectOpaque]OnRenderImage? 0 Answers
How to set ortho projection / model view matrix without a camera? 2 Answers
Previous Model*View*Projection Matrix 0 Answers