This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

Curved World Shader (code included)

1000h1000h Posts: 133Member
edited April 2017 in Shaders

The Animal Crossing Shader has an article on how to do it online by someone named Alastair.
https://alastaira.wordpress.com/2013/10/25/animal-crossing-curved-world-shader/

I had never done anything with shaders before, but I wanted to give this a shot after seeing it in Four Warriors of Light, so here is his code in a manner that works for me in Godot:

If anyone was a noob like me, notice that in order for whatever code to take effect on the desired built-in, you need to set that built in to your manipulated variable, as in the last line VERTEX = v;

Also, it took forever for me to find this link, so here it is:
http://docs.godotengine.org/en/stable/learning/features/shading/shading_language.html?highlight=shader

float curve = -.001;
vec3 v = VERTEX;
mat4 mv = MODELVIEW_MATRIX;
mat4 wv = WORLD_MATRIX;
mat4 cv = INV_CAMERA_MATRIX;

//v*= vec3(1,1,1);

vec4 vv = mv * vec4(v,0.0);

vv -= cv.x;
vv -= cv.y;
vv -= cv.z;

vv = vec4(0.0,pow(vv.z,2)*curve,0.0,0.0);
vv*=wv;
vec3 vvp = vv.xyz;

v+=vvp;

VERTEX = v;

Tags :

Comments

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.