# Fun with Shaders and Maths

## Recommended Posts

Have been playing around with CYOS and shaders to see how the ground can be transformed into different shapes and came across these 3D equations on Ben Joffe's site, so played around with some on this playground

http://www.babylonjs-playground.com/#TWH8K#1

Thanks to DK for CYOS and the documentation.

Given the danger of teaching my Grandmother to suck eggs I will still go ahead and state some obvious things:-

Lines 31, 32 and 33 in the PG contain the functions to determine the height of the ground (v.y) based on the x and z positions on the ground. Comment any two of these out or replace with your own function.

Line 34 sets the movement within the shader comment out to stop this.

You can see just the effect the shader has on the height of the ground by swapping which of lines 82 and 83 are commented out. (Just using CreateGround is less fun than CreateGroundFromHeightMap imho.)

• Do not use integers, ie write 2.0 not 2
• Maths functions are not methods of a Math object as in JS so write sin not Math.sin

The available maths function can be found on page 11 of this OpenGL pdf document

Enjoy

##### Share on other sites

Hi John,

For me, shaders are really complex and difficult to understand. However, I did give it a try several month ago, and I did these below. Maybe it will be useful for someone (but I really doubt it )

cross-stitch : http://www.babylonjs.com/cyos/#1G3RU

Colorify : http://www.babylonjs.com/cyos/#USC12

Lens post-process: http://www.babylonjs-playground.com/#EKICU#2

##### Share on other sites

Given the danger of teaching my Grandmother to suck eggs

hahahaha.  I had to go to the dictionary of comedy with that one.  No entry.  hmm.

"Tie shoes" or "sweep floors"... those were in the dictionary... but not "suck eggs".    That blew everyone's mind!

##### Share on other sites

Oooww JohnK you've just created a wormhole in space and time !

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.