Skip to content

Commit 185aadc

Browse files
GL_LUMINANCE is deprecated, replacement by GL_RGB
1 parent ae242a5 commit 185aadc

File tree

3 files changed

+58
-112
lines changed

3 files changed

+58
-112
lines changed

src/libprojectM/Renderer/PerlinNoise.cpp

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,57 @@
1111

1212
PerlinNoise::PerlinNoise()
1313
{
14-
for (int x = 0; x < 256;x++)
15-
for (int y = 0; y < 256;y++)
16-
noise_lq[x][y] = noise(x , y);
14+
for (int x = 0; x < 256;x++) {
15+
for (int y = 0; y < 256;y++) {
16+
noise_lq[x][y][0] = noise(x , y);
17+
noise_lq[x][y][1] = noise_lq[x][y][0];
18+
noise_lq[x][y][2] = noise_lq[x][y][0];
19+
}
20+
}
1721

18-
for (int x = 0; x < 32;x++)
19-
for (int y = 0; y < 32;y++)
20-
noise_lq_lite[x][y] = noise(4*x,16*y);
22+
for (int x = 0; x < 32;x++) {
23+
for (int y = 0; y < 32;y++) {
24+
noise_lq_lite[x][y][0] = noise(4*x,16*y);
25+
noise_lq_lite[x][y][1] = noise_lq_lite[x][y][0];
26+
noise_lq_lite[x][y][2] = noise_lq_lite[x][y][0];
27+
}
28+
}
2129

22-
for (int x = 0; x < 256;x++)
23-
for (int y = 0; y < 256;y++)
24-
noise_mq[x][y] = InterpolatedNoise((float)x/(float)2.0,(float)y/(float)2.0);
30+
for (int x = 0; x < 256;x++) {
31+
for (int y = 0; y < 256;y++) {
32+
noise_mq[x][y][0] = InterpolatedNoise((float)x/(float)2.0,(float)y/(float)2.0);
33+
noise_mq[x][y][1] = noise_mq[x][y][0];
34+
noise_mq[x][y][2] = noise_mq[x][y][0];
35+
}
36+
}
2537

26-
for (int x = 0; x < 256;x++)
27-
for (int y = 0; y < 256;y++)
28-
noise_hq[x][y] = InterpolatedNoise((float)x/(float)3.0,(float)y/(float)3.0);
38+
for (int x = 0; x < 256;x++) {
39+
for (int y = 0; y < 256;y++) {
40+
noise_hq[x][y][0] = InterpolatedNoise((float)x/(float)3.0,(float)y/(float)3.0);
41+
noise_hq[x][y][1] = noise_hq[x][y][0];
42+
noise_hq[x][y][2] = noise_hq[x][y][0];
43+
}
44+
}
2945

30-
for (int x = 0; x < 32;x++)
31-
for (int y = 0; y < 32;y++)
32-
for (int z = 0; z < 32;z++)
33-
noise_lq_vol[x][y][z] = noise(x,y,z);
46+
for (int x = 0; x < 32;x++) {
47+
for (int y = 0; y < 32;y++) {
48+
for (int z = 0; z < 32;z++) {
49+
noise_lq_vol[x][y][z][0] = noise(x,y,z);
50+
noise_lq_vol[x][y][z][1] = noise_lq_vol[x][y][z][0];
51+
noise_lq_vol[x][y][z][2] = noise_lq_vol[x][y][z][0];
52+
}
53+
}
54+
}
3455

35-
for (int x = 0; x < 32;x++)
36-
for (int y = 0; y < 32;y++)
37-
for (int z = 0; z < 32;z++)
38-
noise_hq_vol[x][y][z] = noise(x,y,z);//perlin_noise_3d(x,y,z,6121,7,seed3,0.5,64);
39-
40-
int seed = rand()%1000;
41-
42-
int size = 512;
43-
int octaves = sqrt((double)size);
44-
45-
for (int x = 0; x < size;x++)
46-
for (int y = 0; y < size;y++)
47-
noise_perlin[x][y] = perlin_noise_2d(x,y,6321,octaves,seed,0.5,size/4);
56+
for (int x = 0; x < 32;x++) {
57+
for (int y = 0; y < 32;y++) {
58+
for (int z = 0; z < 32;z++) {
59+
noise_hq_vol[x][y][z][0] = noise(x,y,z);
60+
noise_hq_vol[x][y][z][1] = noise_hq_vol[x][y][z][0];
61+
noise_hq_vol[x][y][z][2] = noise_hq_vol[x][y][z][0];
62+
}
63+
}
64+
}
4865
}
4966

5067
PerlinNoise::~PerlinNoise()

src/libprojectM/Renderer/PerlinNoise.hpp

Lines changed: 6 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ class PerlinNoise
1414
{
1515
public:
1616

17-
float noise_lq[256][256];
18-
float noise_lq_lite[32][32];
19-
float noise_mq[256][256];
20-
float noise_hq[256][256];
21-
float noise_perlin[512][512];
22-
float noise_lq_vol[32][32][32];
23-
float noise_hq_vol[32][32][32];
17+
float noise_lq[256][256][3];
18+
float noise_lq_lite[32][32][3];
19+
float noise_mq[256][256][3];
20+
float noise_hq[256][256][3];
21+
float noise_lq_vol[32][32][32][3];
22+
float noise_hq_vol[32][32][32][3];
2423

2524

2625
PerlinNoise();
@@ -46,14 +45,6 @@ class PerlinNoise
4645
return noise(n);
4746
}
4847

49-
static inline float cos_interp(float a, float b, float x)
50-
{
51-
float ft = x * 3.1415927;
52-
float f = (1 - cos(ft)) * .5;
53-
54-
return a*(1-f) + b*f;
55-
}
56-
5748
static inline float cubic_interp(float v0, float v1, float v2, float v3, float x)
5849
{
5950
float P = (v3 - v2) - (v0 - v1);
@@ -100,53 +91,6 @@ class PerlinNoise
10091

10192
}
10293

103-
static inline float perlin_octave_2d(float x,float y, int width, int seed, float period)
104-
{
105-
106-
float freq=1/(float)(period);
107-
108-
int num=(int)(width*freq);
109-
int step_x=(int)(x*freq);
110-
int step_y=(int)(y*freq);
111-
float zone_x=x*freq-step_x;
112-
float zone_y=y*freq-step_y;
113-
int box=step_x+step_y*num;
114-
int noisedata=(box+seed);
115-
116-
float u=cubic_interp(noise(noisedata-num-1),noise(noisedata-num),noise(noisedata-num+1),noise(noisedata-num+2),zone_x);
117-
float a=cubic_interp(noise(noisedata-1),noise(noisedata),noise(noisedata+1),noise(noisedata+2),zone_x);
118-
float b=cubic_interp(noise(noisedata+num -1),noise(noisedata+num),noise(noisedata+1+num),noise(noisedata+2+num),zone_x);
119-
float v=cubic_interp(noise(noisedata+2*num -1),noise(noisedata+2*num),noise(noisedata+1+2*num),noise(noisedata+2+2*num),zone_x);
120-
121-
float value=cubic_interp(u,a,b,v,zone_y);
122-
123-
return value;
124-
}
125-
126-
127-
static inline float perlin_octave_2d_cos(float x,float y, int width, int seed, float period)
128-
{
129-
130-
float freq=1/(float)(period);
131-
132-
int num=(int)(width*freq);
133-
int step_x=(int)(x*freq);
134-
int step_y=(int)(y*freq);
135-
float zone_x=x*freq-step_x;
136-
float zone_y=y*freq-step_y;
137-
int box=step_x+step_y*num;
138-
int noisedata=(box+seed);
139-
140-
float a=cos_interp(noise(noisedata),noise(noisedata+1),zone_x);
141-
float b=cos_interp(noise(noisedata+num),noise(noisedata+1+num),zone_x);
142-
143-
float value=cos_interp(a,b,zone_y);
144-
145-
return value;
146-
}
147-
148-
149-
15094
static inline float perlin_octave_3d(float x,float y, float z,int width, int seed, float period)
15195
{
15296
float freq=1/(float)(period);
@@ -204,21 +148,6 @@ class PerlinNoise
204148
}
205149

206150

207-
static inline float perlin_noise_2d(int x, int y, int width, int octaves, int seed, float persistance, float basePeriod)
208-
{
209-
float p = persistance;
210-
float val = 0.0;
211-
212-
for (int i = 0; i<octaves;i++)
213-
{
214-
val += perlin_octave_2d_cos(x,y,width,seed,basePeriod) * p;
215-
216-
basePeriod *= 0.5;
217-
p *= persistance;
218-
}
219-
return val;
220-
}
221-
222151
static inline float perlin_noise_3d(int x, int y, int z, int width, int octaves, int seed, float persistance, float basePeriod)
223152
{
224153
float p = persistance;

src/libprojectM/Renderer/TextureManager.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,47 +82,47 @@ TextureManager::TextureManager(const std::string _presetsURL, const int texsizeX
8282
GLuint noise_texture_lq_lite;
8383
glGenTextures(1, &noise_texture_lq_lite);
8484
glBindTexture(GL_TEXTURE_2D, noise_texture_lq_lite);
85-
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_LUMINANCE, GL_FLOAT, noise.noise_lq_lite);
85+
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGB, GL_FLOAT, noise.noise_lq_lite);
8686
Texture * textureNoise_lq_lite = new Texture(noise_texture_lq_lite, GL_TEXTURE_2D, 32, 32, false);
8787
textureNoise_lq_lite->getSampler(GL_REPEAT, GL_LINEAR);
8888
textures["noise_lq_lite"] = textureNoise_lq_lite;
8989

9090
GLuint noise_texture_lq;
9191
glGenTextures(1, &noise_texture_lq);
9292
glBindTexture(GL_TEXTURE_2D, noise_texture_lq);
93-
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_LUMINANCE, GL_FLOAT, noise.noise_lq);
93+
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGB, GL_FLOAT, noise.noise_lq);
9494
Texture * textureNoise_lq = new Texture(noise_texture_lq, GL_TEXTURE_2D, 256, 256, false);
9595
textureNoise_lq->getSampler(GL_REPEAT, GL_LINEAR);
9696
textures["noise_lq"] = textureNoise_lq;
9797

9898
GLuint noise_texture_mq;
9999
glGenTextures(1, &noise_texture_mq);
100100
glBindTexture(GL_TEXTURE_2D, noise_texture_mq);
101-
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_LUMINANCE, GL_FLOAT, noise.noise_mq);
101+
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGB, GL_FLOAT, noise.noise_mq);
102102
Texture * textureNoise_mq = new Texture(noise_texture_mq, GL_TEXTURE_2D, 256, 256, false);
103103
textureNoise_mq->getSampler(GL_REPEAT, GL_LINEAR);
104104
textures["noise_mq"] = textureNoise_mq;
105105

106106
GLuint noise_texture_hq;
107107
glGenTextures(1, &noise_texture_hq);
108108
glBindTexture(GL_TEXTURE_2D, noise_texture_hq);
109-
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_LUMINANCE, GL_FLOAT, noise.noise_hq);
109+
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGB, GL_FLOAT, noise.noise_hq);
110110
Texture * textureNoise_hq = new Texture(noise_texture_hq, GL_TEXTURE_2D, 256, 256, false);
111111
textureNoise_hq->getSampler(GL_REPEAT, GL_LINEAR);
112112
textures["noise_hq"] = textureNoise_hq;
113113

114114
GLuint noise_texture_lq_vol;
115115
glGenTextures( 1, &noise_texture_lq_vol );
116116
glBindTexture( GL_TEXTURE_3D, noise_texture_lq_vol );
117-
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 32 ,32 ,32 ,0 ,GL_LUMINANCE ,GL_FLOAT ,noise.noise_lq_vol);
117+
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 32 ,32 ,32 ,0 ,GL_RGB ,GL_FLOAT ,noise.noise_lq_vol);
118118
Texture * textureNoise_lq_vol = new Texture(noise_texture_lq_vol, GL_TEXTURE_3D, 32, 32, false);
119119
textureNoise_lq_vol->getSampler(GL_REPEAT, GL_LINEAR);
120120
textures["noisevol_lq"] = textureNoise_lq_vol;
121121

122122
GLuint noise_texture_hq_vol;
123123
glGenTextures( 1, &noise_texture_hq_vol );
124124
glBindTexture( GL_TEXTURE_3D, noise_texture_hq_vol );
125-
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 32, 32, 32, 0, GL_LUMINANCE, GL_FLOAT, noise.noise_hq_vol);
125+
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 32, 32, 32, 0, GL_RGB, GL_FLOAT, noise.noise_hq_vol);
126126
Texture * textureNoise_hq_vol = new Texture(noise_texture_hq_vol, GL_TEXTURE_3D, 32, 32, false);
127127
textureNoise_hq_vol->getSampler(GL_REPEAT, GL_LINEAR);
128128
textures["noisevol_hq"] = textureNoise_hq_vol;

0 commit comments

Comments
 (0)