Changeset 1846
- Timestamp:
- Aug 31, 2012, 1:54:18 PM (7 years ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/Makefile.am
r1590 r1846 51 51 \ 52 52 gpu/defaultmaterial.lolfx \ 53 gpu/tile.lolfx \ 53 54 gpu/emptymaterial.lolfx \ 54 55 gpu/testmaterial.lolfx \ -
trunk/src/lolcore.vcxproj
r1610 r1846 621 621 <LolFxCompile Include="gpu\emptymaterial.lolfx" /> 622 622 <LolFxCompile Include="gpu\testmaterial.lolfx" /> 623 <LolFxCompile Include="gpu\tile.lolfx" /> 623 624 </ItemGroup> 624 625 <ItemGroup> -
trunk/src/scene.cpp
r1721 r1846 23 23 #include "lolgl.h" 24 24 25 extern char const *lolfx_tile; 26 25 27 namespace lol 26 28 { … … 151 153 152 154 if (!data->m_shader) 153 { 154 #if !defined _XBOX && !defined __CELLOS_LV2__ && !defined USE_D3D9 155 data->m_shader = Shader::Create( 156 # if !defined HAVE_GLES_2X 157 "#version 130\n" 158 # endif 159 "\n" 160 # if defined HAVE_GLES_2X 161 "attribute vec3 in_Position;\n" 162 "attribute vec2 in_TexCoord;\n" 163 "varying vec2 pass_TexCoord;\n" 164 # else 165 "in vec3 in_Position;\n" 166 "in vec2 in_TexCoord;\n" 167 # endif 168 "uniform mat4 proj_matrix;\n" 169 "uniform mat4 view_matrix;\n" 170 "uniform mat4 model_matrix;\n" 171 "\n" 172 "void main()\n" 173 "{\n" 174 " gl_Position = proj_matrix * view_matrix * model_matrix" 175 " * vec4(in_Position, 1.0);\n" 176 # if defined HAVE_GLES_2X 177 " pass_TexCoord = in_TexCoord;\n" 178 # else 179 " gl_TexCoord[0] = vec4(in_TexCoord, 0.0, 0.0);\n" 180 # endif 181 "}\n", 182 183 # if !defined HAVE_GLES_2X 184 "#version 130\n" 185 # else 186 "precision mediump float;\n" 187 # endif 188 "\n" 189 "uniform sampler2D in_Texture;\n" 190 # if defined HAVE_GLES_2X 191 "varying vec2 pass_TexCoord;\n" 192 # endif 193 "\n" 194 "void main()\n" 195 "{\n" 196 # if defined HAVE_GLES_2X 197 " vec4 col = texture2D(in_Texture, pass_TexCoord);\n" 198 //" vec4 col = vec4(0.5, 1.0, 0.0, 0.5);\n" 199 //" vec4 col = vec4(pass_TexCoord * 4.0, 0.0, 0.25);\n" 200 # else 201 " vec4 col = texture2D(in_Texture, vec2(gl_TexCoord[0]));\n" 202 # endif 203 # if 0 204 " float mul = 2.0;\n" 205 # if 1 206 " vec2 d1 = mod(vec2(gl_FragCoord), vec2(2.0, 2.0));\n" 207 " float t1 = mod(3.0 * d1.x + 2.0 * d1.y, 4.0);\n" 208 " float dx2 = mod(floor(gl_FragCoord.x * 0.5), 2.0);\n" 209 " float dy2 = mod(floor(gl_FragCoord.y * 0.5), 2.0);\n" 210 " float t2 = mod(3.0 * dx2 + 2.0 * dy2, 4.0);\n" 211 " float dx3 = mod(floor(gl_FragCoord.x * 0.25), 2.0);\n" 212 " float dy3 = mod(floor(gl_FragCoord.y * 0.25), 2.0);\n" 213 " float t3 = mod(3.0 * dx3 + 2.0 * dy3, 4.0);\n" 214 " t1 = (1.0 + 16.0 * t1 + 4.0 * t2 + t3) / 65.0;\n" 215 " t2 = t1;\n" 216 " t3 = t1;\n" 217 # else 218 " float rand = sin(gl_FragCoord.x * 1.23456) * 123.456\n" 219 " + cos(gl_FragCoord.y * 2.34567) * 789.012;\n" 220 " float t1 = mod(sin(rand) * 17.13043, 1.0);\n" 221 " float t2 = mod(sin(rand) * 27.13043, 1.0);\n" 222 " float t3 = mod(sin(rand) * 37.13043, 1.0);\n" 223 # endif 224 " float fracx = fract(col.x * mul);\n" 225 " float fracy = fract(col.y * mul);\n" 226 " float fracz = fract(col.z * mul);\n" 227 " fracx = fracx > t1 ? 1.0 : 0.0;\n" 228 " fracy = fracy > t2 ? 1.0 : 0.0;\n" 229 " fracz = fracz > t3 ? 1.0 : 0.0;\n" 230 " col.x = (floor(col.x * mul) + fracx) / mul;\n" 231 " col.y = (floor(col.y * mul) + fracy) / mul;\n" 232 " col.z = (floor(col.z * mul) + fracz) / mul;\n" 233 # endif 234 " gl_FragColor = col;\n" 235 "}\n"); 236 #else 237 data->m_shader = Shader::Create( 238 "void main(float4 in_Position : POSITION," 239 " float2 in_TexCoord : TEXCOORD0," 240 " uniform float4x4 proj_matrix," 241 " uniform float4x4 view_matrix," 242 " uniform float4x4 model_matrix," 243 " out float2 out_TexCoord : TEXCOORD0," 244 " out float4 out_Position : POSITION)" 245 "{" 246 " out_Position = mul(proj_matrix, mul(view_matrix, mul(model_matrix, in_Position)));" 247 " out_TexCoord = in_TexCoord;" 248 "}", 249 250 "void main(float2 in_TexCoord : TEXCOORD0," 251 # if 0 252 " float4 in_FragCoord : WPOS," 253 # endif 254 " uniform sampler2D tex," 255 " out float4 out_FragColor : COLOR)" 256 "{" 257 " float4 col = tex2D(tex, in_TexCoord);" 258 # if 0 259 " float mul = 2.0;\n" 260 " float t1, t2, t3;\n" 261 # if 1 262 " float dx1 = frac(in_FragCoord.x * 0.5) * 2.0;\n" 263 " float dy1 = frac(in_FragCoord.y * 0.5) * 2.0;\n" 264 " t1 = frac((3.0 * dx1 + 2.0 * dy1) / 4.0) * 4.0;\n" 265 " float dx2 = frac(floor(in_FragCoord.x * 0.5) * 0.5) * 2.0;\n" 266 " float dy2 = frac(floor(in_FragCoord.y * 0.5) * 0.5) * 2.0;\n" 267 " t2 = frac((3.0 * dx2 + 2.0 * dy2) / 4.0) * 4.0;\n" 268 " float dx3 = frac(floor(in_FragCoord.x * 0.25) * 0.5) * 2.0;\n" 269 " float dy3 = frac(floor(in_FragCoord.y * 0.25) * 0.5) * 2.0;\n" 270 " t3 = frac((3.0 * dx3 + 2.0 * dy3) / 4.0) * 4.0;\n" 271 " t1 = (1.0 + 4.0 * t1 + t2) / 17.0;\n" 272 " t2 = t1;\n" 273 " t3 = t1;\n" 274 # else 275 " float rand = sin(in_FragCoord.x * 1.23456) * 123.456\n" 276 " + cos(in_FragCoord.y * 2.34567) * 789.012;\n" 277 " t1 = frac(sin(rand) * 17.13043);\n" 278 " t2 = frac(sin(rand) * 27.13043);\n" 279 " t3 = frac(sin(rand) * 37.13043);\n" 280 # endif 281 " float fracx = frac(col.x * mul);\n" 282 " float fracy = frac(col.y * mul);\n" 283 " float fracz = frac(col.z * mul);\n" 284 " fracx = fracx > t1 ? 1.0 : 0.0;\n" 285 " fracy = fracy > t2 ? 1.0 : 0.0;\n" 286 " fracz = fracz > t3 ? 1.0 : 0.0;\n" 287 " col.x = (floor(col.x * mul) + fracx) / mul;\n" 288 " col.y = (floor(col.y * mul) + fracy) / mul;\n" 289 " col.z = (floor(col.z * mul) + fracz) / mul;\n" 290 # endif 291 " out_FragColor = col;" 292 "}"); 293 #endif 294 } 155 data->m_shader = Shader::Create(lolfx_tile); 295 156 296 157 #if 0
Note: See TracChangeset
for help on using the changeset viewer.