Skip to content
Snippets Groups Projects
Commit 9463c46a authored by dg's avatar dg
Browse files

test

git-svn-id: http://svn.net-core.org/repos/t-engine4@1402 51575b47-30f0-44d4-a5cc-537603b46e54
parent 83f512e4
No related branches found
No related tags found
No related merge requests found
......@@ -448,7 +448,7 @@ function _M:display()
self.level.map:display(0, 0)
self.target:display(0, 0)
self.fbo:use(false)
_3DNoise:bind(1, true)
_2DNoise:bind(1, false)
self.fbo:toScreen(
self.level.map.display_x, self.level.map.display_y,
self.level.map.viewport.width, self.level.map.viewport.height,
......
......@@ -2,26 +2,21 @@ uniform float hp_warning;
uniform float motionblur;
uniform float blur;
uniform float tick;
uniform sampler3D noisevol;
uniform sampler2D noisevol;
uniform vec2 texSize;
uniform sampler2D tex;
uniform vec3 colorize;
void main(void)
{
gl_FragColor = texture2D(tex, gl_TexCoord[0].xy);
if (motionblur > 0.0)
{
int blursize = int(motionblur);
vec2 offset = 1.0/texSize;
float fTime0_X = tick / 40000.0;
vec2 coord = gl_TexCoord[0].xy;
float noisy = texture3D(noisevol,vec3(coord,fTime0_X)).r;
// float noisy2 = texture3D(noisevol,vec3(coord/5.0,fTime0_X)).r;
// float noisy3 = texture3D(noisevol,vec3(coord/7.0,fTime0_X)).r;
// float noise = (noisy+noisy2+noisy3)/3.0;
float coord = gl_TexCoord[0].x ;
float noisy = texture2D(noisevol,vec2(coord,fTime0_X)).r;
// Center Pixel
vec4 sample = vec4(0.0,0.0,0.0,0.0);
......@@ -92,6 +87,10 @@ void main(void)
sample /= float((blur*2.0) * (blur*2.0));
gl_FragColor = sample;
}
else
{
gl_FragColor = texture2D(tex, gl_TexCoord[0].xy);
}
if (colorize.r > 0.0 || colorize.g > 0.0 || colorize.b > 0.0)
{
......
......@@ -44,7 +44,9 @@ profile.mod.allow_build = profile.mod.allow_build or {}
-- Create some noise textures
local n = core.noise.new(3)
_3DNoise = n:makeTexture3D(64, 64, 64, 0, 0, 0)
_3DNoise = n:makeTexture3D(64, 64, 64)
local n = core.noise.new(2)
_2DNoise = n:makeTexture2D(64, 64)
-- Achievements
WorldAchievements:loadDefinition("/data/achievements/")
......
......@@ -174,15 +174,15 @@ static int noise_turbulence_wavelet(lua_State *L)
#define TEXEL2(s, t) (BYTES_PER_TEXEL * (s * w + t))
// 3->1 dimension mapping function
#define TEXEL3(s, t, r) (TEXEL2(s, t) + LAYER(r))
/*
static int noise_texture2d(lua_State *L)
{
noise_t *n = (noise_t*)auxiliar_checkclass(L, "noise{core}", 1);
int w = luaL_checknumber(L, 3);
int h = luaL_checknumber(L, 4);
float zoom = luaL_checknumber(L, 5);
float x = luaL_checknumber(L, 6);
float y = luaL_checknumber(L, 7);
int w = luaL_checknumber(L, 2);
int h = luaL_checknumber(L, 3);
float zoom = luaL_checknumber(L, 4);
float x = luaL_checknumber(L, 5);
float y = luaL_checknumber(L, 6);
GLubyte *map = malloc(w * h * 3 * sizeof(GLubyte));
float p[2];
......@@ -215,7 +215,7 @@ static int noise_texture2d(lua_State *L)
return 1;
}
*/
inline static float noise3d(noise_t *n, float x, float y, float z) ALWAYS_INLINE;
static float noise3d(noise_t *n, float x, float y, float z)
{
......@@ -284,6 +284,41 @@ static int noise_texture3d(lua_State *L)
return 1;
}
static int noise_texture2d(lua_State *L)
{
if (!shaders_active) return 0;
noise_t *n = (noise_t*)auxiliar_checkclass(L, "noise{core}", 1);
int w = luaL_checknumber(L, 2);
int h = luaL_checknumber(L, 3);
GLubyte *map = malloc(w * h * 3 * sizeof(GLubyte));
int i, j;
for (i = 0; i < w; i++)
{
for (j = 0; j < h; j++)
{
float v = tilablenoise3d(n, i*4, j*4, 0*4, w*4, h*4, 1*4) * 255;
map[TEXEL2(i, j)] = (GLubyte)v;
map[TEXEL2(i, j)+1] = (GLubyte)v;
map[TEXEL2(i, j)+2] = (GLubyte)v;
}
}
GLuint *t = (GLuint*)lua_newuserdata(L, sizeof(GLuint));
auxiliar_setclass(L, "gl{texture}", -1);
glGenTextures(1, t);
glBindTexture(GL_TEXTURE_2D, *t);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, map);
free(map);
return 1;
}
static const struct luaL_reg noiselib[] =
{
{"new", noise_new},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment