Yeah. I like to convert the current ones to files by going to ideone.com
and pasting in short programs like this:
import java.util.*;
import java.lang.*;
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
String m =
"precision mediump float;\n" +
"uniform sampler2D tex_sampler_0;\n" +
"uniform float scale;\n" +
"uniform float stepsizeX;\n" +
"uniform float stepsizeY;\n" +
"varying vec2 v_texcoord;\n" +
"void main() {\n" +
" vec3 nbr_color = vec3(0.0, 0.0, 0.0);\n" +
" vec2 coord;\n" +
" vec4 color = texture2D(tex_sampler_0, v_texcoord);\n" +
" coord.x = v_texcoord.x - 0.5 * stepsizeX;\n" +
" coord.y = v_texcoord.y - stepsizeY;\n" +
" nbr_color += texture2D(tex_sampler_0, coord).rgb -
color.rgb;\n" +
" coord.x = v_texcoord.x - stepsizeX;\n" +
" coord.y = v_texcoord.y + 0.5 * stepsizeY;\n" +
" nbr_color += texture2D(tex_sampler_0, coord).rgb -
color.rgb;\n" +
" coord.x = v_texcoord.x + stepsizeX;\n" +
" coord.y = v_texcoord.y - 0.5 * stepsizeY;\n" +
" nbr_color += texture2D(tex_sampler_0, coord).rgb -
color.rgb;\n" +
" coord.x = v_texcoord.x + stepsizeX;\n" +
" coord.y = v_texcoord.y + 0.5 * stepsizeY;\n" +
" nbr_color += texture2D(tex_sampler_0, coord).rgb -
color.rgb;\n" +
" gl_FragColor = vec4(color.rgb - 2.0 * scale * nbr_color,
color.a);\n" +
"}\n";
System.out.println(m);
}
}
On Tuesday, December 11, 2012 12:38:59 AM UTC-6, Harri Smått wrote:
>
> I've been putting shader code into assets or raw resources for a long
> while. Writing your shaders as strings is a pain.
>
> --
> H
> On Dec 11, 2012 12:29 AM, "bob" <[email protected] <javascript:>>
> wrote:
>
>> I'm looking at the BasicGLSurfaceView example, and I'm thinking maybe the
>> vertex shader and fragment shader ought to be stored as assets for
>> readability.
>>
>> Right now they are like this:
>>
>> private final String mVertexShader =
>> "uniform mat4 uMVPMatrix;\n" +
>> "attribute vec4 aPosition;\n" +
>> "attribute vec2 aTextureCoord;\n" +
>> "varying vec2 vTextureCoord;\n" +
>> "void main() {\n" +
>> " gl_Position = uMVPMatrix * aPosition;\n" +
>> " vTextureCoord = aTextureCoord;\n" +
>> "}\n";
>>
>> private final String mFragmentShader =
>> "precision mediump float;\n" +
>> "varying vec2 vTextureCoord;\n" +
>> "uniform sampler2D sTexture;\n" +
>> "void main() {\n" +
>> " gl_FragColor = texture2D(sTexture, vTextureCoord);\n" +
>> "}\n";
>>
>>
>>
>> On iOS, they are stored in .vsh and .fsh files. I think we should do
>> something like that. What do you guys think?
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to
>> [email protected]<javascript:>
>> To unsubscribe from this group, send email to
>> [email protected] <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en