diff --git a/Shaders-in-Android.md b/Shaders-in-Android.md index 4891833..388ca8c 100644 --- a/Shaders-in-Android.md +++ b/Shaders-in-Android.md @@ -9,22 +9,22 @@ love.graphics.newShader[[ ]] ``` -The reason the shader code doesn't work is that desktop machines use OpenGL and Android devices use OpenGLES, and the shader language implementation is different in some aspects. This guide details the differences that you should take into account when writing shader code for Android. +The reason the shader code doesn't work is that desktop machines use OpenGL and Android devices use OpenGL ES, and the shader language implementation is different in some aspects. This guide details the differences that you should take into account when writing shader code for Android. The problems that may arise are: * [No acceptable conversion](#no-acceptable-conversion) * [Field selection out of range](#field-selection-out-of-range) -* [Uniform couldn´t be initialized](#uniform-couldn-t-be-initialized) +* [Uniform couldn't be initialized](#uniform-couldnt-be-initialized) -If you stuck on desktops without OpenGLES driver support, you can use ANGLE, or since 11.0, [`love.graphics.validateShader(true, shaderCode)`](https://love2d.org/wiki/love.graphics.validateShader). +If you stuck on desktops without OpenGL ES driver support, you can use ANGLE, or since 11.0, [`love.graphics.validateShader(true, shaderCode)`](https://love2d.org/wiki/love.graphics.validateShader). ------------------ No acceptable conversion ----- -OpenGLES doesn´t handle float and int conversions by default, instead every float or int should be manually converted. For example: +OpenGL ES doesn't handle float and int conversions by default, instead every float or int should be manually converted. For example: ```glsl float foo; @@ -63,7 +63,7 @@ This error occurs when creating arrays, in OpenGL you would use the following co uniform vec2[4] array; ``` -Generating an array with 4 `vec2` elements. But OpenGLES doesn´t use this notation. Instead you should write it like this: +Generating an array with 4 `vec2` elements. But OpenGL ES doesn't use this notation. Instead you should write it like this: ```glsl uniform vec2 array[4]; @@ -71,16 +71,16 @@ uniform vec2 array[4]; The length must be specified in the identifier and not in the type -Uniform couldn´t be initialized +Uniform couldn't be initialized ----- -Well this took me a while to find but it´s rather simple. In [LÖVE Shader Language](http://www.love2d.org/wiki/love.graphics.newShader#Shader_Language) you can use `extern` as you would use `uniform` in OpenGLSL so that you can then send data to the shader using `Shader:send()`. The problem comes when you need to have a default value in the variable. In OpenGL you would normally do +Well this took me a while to find but it´s rather simple. In [LÖVE Shader Language](http://www.love2d.org/wiki/love.graphics.newShader#Shader_Language) you can use `extern` as you would use `uniform` in GLSL so that you can then send data to the shader using `Shader:send()`. The problem comes when you need to have a default value in the variable. In OpenGL you would normally do ```glsl uniform float foo = 5; ``` -So if you pass a number to `foo` it will take that value, but if you don´t send anything it would take 5 as it´s own value. This was added in OpenGLSL 1.2 (The one used in desktop environments), Android uses an OpenGLSL based on it it doesn´t include this feature. +So if you pass a number to `foo` it will take that value, but if you don't send anything it would take 5 as it's own value. This was added in GLSL 1.2 (The one used in desktop environments), but ESSL doesn't support this feature. Instead you could just use: @@ -89,7 +89,7 @@ uniform float foo; float bar = 5; ``` -And in your shader code check if it´s `0.0` +And in your shader code check if it's `0.0` ```glsl if (foo == 0.0) { @@ -99,7 +99,7 @@ if (foo == 0.0) { } ``` -This code doesn´t allow you to have `bar == 0.0`. If you don´t like that then there is another alternative, you can just store the variable value in Lua and send it before running the shader. +This code doesn't allow you to have `bar == 0.0`. If you don't like that then there is another alternative, you can just store the variable value in Lua and send it before running the shader. ```lua shader = love.graphics.newShader[[ @@ -126,5 +126,5 @@ This file is based in the [Modifying your shaders to work with LÖVELINESS](http Look at this links for more information on shaders in Android: * [OpenGL Wiki](http://www.opengl.org/wiki/Main_Page) Not everything works in OpenGL ES -* [OpenGLES Shading Language PDF](http://www.khronos.org/files/opengles_shading_language.pdf) This file tells you what you can and can´t do, plus it list the differences with OpenGLSL. -* [OpenGL 2.0 Spec](http://www.khronos.org/files/opengles_shading_language.pdf) OpenGLES 2.0 Shading Language is based on this OpenGLSL implemantation. It still differs. \ No newline at end of file +* [OpenGL ES Shading Language PDF](http://www.khronos.org/files/opengles_shading_language.pdf) This file tells you what you can and can't do, plus it list the differences with OpenGLSL. +* [OpenGL 2.0 Spec](http://www.khronos.org/files/opengles_shading_language.pdf) OpenGL ES 2.0 Shading Language is based on this OpenGLSL implemantation. It still differs. \ No newline at end of file