Jump to content

How to make a mobile shader


Josh
 Share

Recommended Posts

  1. Open the shader in the script editor by double-clicking its icon in the Asset Browser.
  2. When the shader is first opened, by default the OpenGL2 fragment shader source code will be displayed. Right-click in the code area to display the popup context menu and choose the Select All menu item.
  3. Copy the entire text, then select the OpenGLES2 fragment shader source in the left-hand tree display. Clear the code area of any text, then type the following at the top of the code area:
    precision highp float;


  4. Paste the clipboard contents from the OpenGL 2 fragment shader below this line.
  5. Repeat the same process, copying the OpenGL 2 vertex shader source to the OpenGL ES 2 vertex shader. Don't forget to add the precision qualifier at the top of the code.
  6. You can test your shader by selecting the Debug > Run menu item while one of the OpenGL ES 2 shader sources is displayed.
  7. Re-publish your project for mobile and it will run.

  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • 4 weeks later...

can we use the pre-processor definitions in the shadder to determine if we are compiling for desktop or mobile, like we do in lua or C++?

bool Life()
{
 while(death=false)
 {
   if(death==true)
   return death;
 }
}

 

I have found the secret to infinite life

 

Did I help you out? Like my post!

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...