-
-
Notifications
You must be signed in to change notification settings - Fork 425
There was a bug that existed in open GL ES 2.0 implementations and random textures #239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c3bb035
There was a bug that existed in open GL ES 2.0 implementations
hibengler 3eccb70
Added a fudge for render farming milkdrop where we control the time a…
hibengler f511d1b
User defined time: Got rid of testing code
hibengler 78891d0
Attempt to fix WIN32 compile - it doesnt use or need the ability to c…
hibengler 8049fe7
Got rid of debug - got rid of minor warning
hibengler 32dd14b
Merge branch 'master' of https://github.com/hibengler/projectm
hibengler 5bc9bf0
projectM.hpp - type in ifdef
hibengler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /* | ||
| * PerlinNoiseWithAlpha.cpp | ||
| * | ||
| * Created and based on PerlinNoise.hpp | ||
| * Created on: Sep 14, 2019 | ||
| * Author: hibengler | ||
| */ | ||
|
|
||
| #include "PerlinNoiseWithAlpha.hpp" | ||
| #include <iostream> | ||
| #include <stdlib.h> | ||
|
|
||
| /* The reason for this cousin class is that in Open GLES 2.0 environments, | ||
| the glTexImage2d cannot convert from GL_RGB into GL_RGBA | ||
| so the TextureManager has to use something that is pre-RGBA | ||
| */ | ||
| PerlinNoiseWithAlpha::PerlinNoiseWithAlpha() | ||
| { | ||
| for (int x = 0; x < 256;x++) { | ||
| for (int y = 0; y < 256;y++) { | ||
| noise_lq[x][y][0] = noise(x , y); | ||
| noise_lq[x][y][1] = noise_lq[x][y][0]; | ||
| noise_lq[x][y][2] = noise_lq[x][y][0]; | ||
| noise_lq[x][y][3] = 1.f; | ||
| } | ||
| } | ||
|
|
||
| for (int x = 0; x < 32;x++) { | ||
| for (int y = 0; y < 32;y++) { | ||
| noise_lq_lite[x][y][0] = noise(4*x,16*y); | ||
| noise_lq_lite[x][y][1] = noise_lq_lite[x][y][0]; | ||
| noise_lq_lite[x][y][2] = noise_lq_lite[x][y][0]; | ||
| noise_lq_lite[x][y][3] = 1.f; | ||
| } | ||
| } | ||
|
|
||
| for (int x = 0; x < 256;x++) { | ||
| for (int y = 0; y < 256;y++) { | ||
| noise_mq[x][y][0] = InterpolatedNoise((float)x/(float)2.0,(float)y/(float)2.0); | ||
| noise_mq[x][y][1] = noise_mq[x][y][0]; | ||
| noise_mq[x][y][2] = noise_mq[x][y][0]; | ||
| noise_mq[x][y][3] = 1.f; | ||
| } | ||
| } | ||
|
|
||
| for (int x = 0; x < 256;x++) { | ||
| for (int y = 0; y < 256;y++) { | ||
| noise_hq[x][y][0] = InterpolatedNoise((float)x/(float)3.0,(float)y/(float)3.0); | ||
| noise_hq[x][y][1] = noise_hq[x][y][0]; | ||
| noise_hq[x][y][2] = noise_hq[x][y][0]; | ||
| noise_hq[x][y][3] = 1.f; | ||
| } | ||
| } | ||
|
|
||
| for (int x = 0; x < 32;x++) { | ||
| for (int y = 0; y < 32;y++) { | ||
| for (int z = 0; z < 32;z++) { | ||
| noise_lq_vol[x][y][z][0] = noise(x,y,z); | ||
| noise_lq_vol[x][y][z][1] = noise_lq_vol[x][y][z][0]; | ||
| noise_lq_vol[x][y][z][2] = noise_lq_vol[x][y][z][0]; | ||
| noise_lq_vol[x][y][z][3] = 1.f; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| for (int x = 0; x < 32;x++) { | ||
| for (int y = 0; y < 32;y++) { | ||
| for (int z = 0; z < 32;z++) { | ||
| noise_hq_vol[x][y][z][0] = noise(x,y,z); | ||
| noise_hq_vol[x][y][z][1] = noise_hq_vol[x][y][z][0]; | ||
| noise_hq_vol[x][y][z][2] = noise_hq_vol[x][y][z][0]; | ||
| noise_hq_vol[x][y][z][3] = 1.f; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| PerlinNoiseWithAlpha::~PerlinNoiseWithAlpha() | ||
| { | ||
| // TODO Auto-generated destructor stub | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| /* | ||
| * PerlinNoise.hpp | ||
| * | ||
| * Created and based on PerlinNoise.hpp | ||
| * Created on: Sep 14, 2019 | ||
| * Author: hibengler | ||
| */ | ||
|
|
||
|
|
||
| /* The reason for this cousin class is that in Open GLES 2.0 environments, | ||
| the glTexImage2d cannot convert from GL_RGB into GL_RGBA | ||
| so the TextureManager has to use something that is pre-RGBA | ||
| */ | ||
| #ifndef PERLINNOISEWITHALPHA_HPP_ | ||
| #define PERLINNOISEWITHALPHA_HPP_ | ||
|
|
||
| #include <math.h> | ||
|
|
||
| class PerlinNoiseWithAlpha | ||
| { | ||
| public: | ||
|
|
||
| float noise_lq[256][256][4]; | ||
| float noise_lq_lite[32][32][4]; | ||
| float noise_mq[256][256][4]; | ||
| float noise_hq[256][256][4]; | ||
| float noise_lq_vol[32][32][32][4]; | ||
| float noise_hq_vol[32][32][32][4]; | ||
|
|
||
|
|
||
| PerlinNoiseWithAlpha(); | ||
| virtual ~PerlinNoiseWithAlpha(); | ||
|
|
||
| private: | ||
|
|
||
| static inline float noise( int x) | ||
| { | ||
| x = (x<<13)^x; | ||
| return (((x * (x * x * 15731 + 789221) + 1376312589) & 0x7fffffff) / 2147483648.0); | ||
| } | ||
|
|
||
| static inline float noise(int x, int y) | ||
| { | ||
| int n = x + y * 57; | ||
| return noise(n); | ||
| } | ||
|
|
||
| static inline float noise(int x, int y, int z) | ||
| { | ||
| int n = x + y * 57 + z * 141; | ||
| return noise(n); | ||
| } | ||
|
|
||
| static inline float cubic_interp(float v0, float v1, float v2, float v3, float x) | ||
| { | ||
| float P = (v3 - v2) - (v0 - v1); | ||
| float Q = (v0 - v1) - P; | ||
| float R = v2 - v0; | ||
|
|
||
| return P*pow(x,3) + Q * pow(x,2) + R*x + v1; | ||
| } | ||
|
|
||
| static inline float InterpolatedNoise(float x, float y) | ||
| { | ||
| int integer_X = int(x); | ||
| float fractional_X = x - integer_X; | ||
|
|
||
| int integer_Y = int(y); | ||
| float fractional_Y = y - integer_Y; | ||
|
|
||
| float a0 = noise(integer_X - 1, integer_Y - 1); | ||
| float a1 = noise(integer_X, integer_Y - 1); | ||
| float a2 = noise(integer_X + 1, integer_Y - 1); | ||
| float a3 = noise(integer_X + 2, integer_Y - 1); | ||
|
|
||
| float x0 = noise(integer_X - 1, integer_Y); | ||
| float x1 = noise(integer_X, integer_Y); | ||
| float x2 = noise(integer_X + 1, integer_Y); | ||
| float x3 = noise(integer_X + 2, integer_Y); | ||
|
|
||
| float y0 = noise(integer_X + 0, integer_Y + 1); | ||
| float y1 = noise(integer_X, integer_Y + 1); | ||
| float y2 = noise(integer_X + 1, integer_Y + 1); | ||
| float y3 = noise(integer_X + 2, integer_Y + 1); | ||
|
|
||
| float b0 = noise(integer_X - 1, integer_Y + 2); | ||
| float b1 = noise(integer_X, integer_Y + 2); | ||
| float b2 = noise(integer_X + 1, integer_Y + 2); | ||
| float b3 = noise(integer_X + 2, integer_Y + 2); | ||
|
|
||
| float i0 = cubic_interp(a0 , a1, a2, a3, fractional_X); | ||
| float i1 = cubic_interp(x0 , x1, x2, x3, fractional_X); | ||
| float i2 = cubic_interp(y0 , y1, y2, y3, fractional_X); | ||
| float i3 = cubic_interp(b0 , b1, b2, b3, fractional_X); | ||
|
|
||
| return cubic_interp(i0, i1 , i2 , i3, fractional_Y); | ||
|
|
||
| } | ||
|
|
||
| static inline float perlin_octave_3d(float x,float y, float z,int width, int seed, float period) | ||
| { | ||
| float freq=1/(float)(period); | ||
|
|
||
| int num=(int)(width*freq); | ||
| int step_x=(int)(x*freq); | ||
| int step_y=(int)(y*freq); | ||
| int step_z=(int)(z*freq); | ||
| float zone_x=x*freq-step_x; | ||
| float zone_y=y*freq-step_y; | ||
| float zone_z=z*freq-step_z; | ||
|
|
||
| int boxB=step_x+step_y+step_z*num; | ||
| int boxC=step_x+step_y+step_z*(num+1); | ||
| int boxD=step_x+step_y+step_z*(num+2); | ||
| int boxA=step_x+step_y+step_z*(num-1); | ||
|
|
||
| float u,a,b,v,noisedata,box; | ||
|
|
||
| box = boxA; | ||
| noisedata=(box+seed); | ||
| u=cubic_interp(noise(noisedata-num-1),noise(noisedata-num),noise(noisedata-num+1),noise(noisedata-num+2),zone_x); | ||
| a=cubic_interp(noise(noisedata-1),noise(noisedata),noise(noisedata+1),noise(noisedata+2),zone_x); | ||
| b=cubic_interp(noise(noisedata+num -1),noise(noisedata+num),noise(noisedata+1+num),noise(noisedata+2+num),zone_x); | ||
| v=cubic_interp(noise(noisedata+2*num -1),noise(noisedata+2*num),noise(noisedata+1+2*num),noise(noisedata+2+2*num),zone_x); | ||
| float A=cubic_interp(u,a,b,v,zone_y); | ||
|
|
||
| box = boxB; | ||
| noisedata=(box+seed); | ||
| u=cubic_interp(noise(noisedata-num-1),noise(noisedata-num),noise(noisedata-num+1),noise(noisedata-num+2),zone_x); | ||
| a=cubic_interp(noise(noisedata-1),noise(noisedata),noise(noisedata+1),noise(noisedata+2),zone_x); | ||
| b=cubic_interp(noise(noisedata+num -1),noise(noisedata+num),noise(noisedata+1+num),noise(noisedata+2+num),zone_x); | ||
| v=cubic_interp(noise(noisedata+2*num -1),noise(noisedata+2*num),noise(noisedata+1+2*num),noise(noisedata+2+2*num),zone_x); | ||
| float B=cubic_interp(u,a,b,v,zone_y); | ||
|
|
||
| box = boxC; | ||
| noisedata=(box+seed); | ||
| u=cubic_interp(noise(noisedata-num-1),noise(noisedata-num),noise(noisedata-num+1),noise(noisedata-num+2),zone_x); | ||
| a=cubic_interp(noise(noisedata-1),noise(noisedata),noise(noisedata+1),noise(noisedata+2),zone_x); | ||
| b=cubic_interp(noise(noisedata+num -1),noise(noisedata+num),noise(noisedata+1+num),noise(noisedata+2+num),zone_x); | ||
| v=cubic_interp(noise(noisedata+2*num -1),noise(noisedata+2*num),noise(noisedata+1+2*num),noise(noisedata+2+2*num),zone_x); | ||
| float C=cubic_interp(u,a,b,v,zone_y); | ||
|
|
||
| box = boxD; | ||
| noisedata=(box+seed); | ||
| u=cubic_interp(noise(noisedata-num-1),noise(noisedata-num),noise(noisedata-num+1),noise(noisedata-num+2),zone_x); | ||
| a=cubic_interp(noise(noisedata-1),noise(noisedata),noise(noisedata+1),noise(noisedata+2),zone_x); | ||
| b=cubic_interp(noise(noisedata+num -1),noise(noisedata+num),noise(noisedata+1+num),noise(noisedata+2+num),zone_x); | ||
| v=cubic_interp(noise(noisedata+2*num -1),noise(noisedata+2*num),noise(noisedata+1+2*num),noise(noisedata+2+2*num),zone_x); | ||
| float D=cubic_interp(u,a,b,v,zone_y); | ||
|
|
||
| float value =cubic_interp(A,B,C,D,zone_z); | ||
|
|
||
| return value; | ||
| } | ||
|
|
||
|
|
||
| static inline float perlin_noise_3d(int x, int y, int z, int width, int octaves, int seed, float persistance, float basePeriod) | ||
| { | ||
| float p = persistance; | ||
| float val = 0.0; | ||
|
|
||
| for (int i = 0; i<octaves;i++) | ||
| { | ||
| val += perlin_octave_3d(x,y,z,width,seed,basePeriod) * p; | ||
|
|
||
| basePeriod *= 0.5; | ||
| p *= persistance; | ||
| } | ||
| return val; | ||
| } | ||
|
|
||
|
|
||
|
|
||
| }; | ||
|
|
||
| #endif /* PERLINNOISEWITHALPHA_HPP_ */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i truly actually have no idea what is going on here. comment? make some constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it is generating random noise data used by some of the visualizers.
The noise functions convert the standard random numbers to follow different
ranges, styles, etc.
inline float noise looks to be generating a psuedo random number that is seeded with X.
This file is basically a copy of PerlInNoise.hpp, and does the same thing as PerlInNoise class, except that it generates the noise in an RGBA buffer instead of an RGB buffer.
OpenGL ES 2.0 cannot transform RGB into RGBA in hardware, but it can do RGBA to RGBA. This is why I me the step-sibling class.