Переглянути джерело

Merge pull request #838 from eggmund/master

Update julia set example.
pull/841/head
Ray 6 роки тому
committed by GitHub
джерело
коміт
84fb2e00df
Не вдалося знайти GPG ключ що відповідає даному підпису Ідентифікатор GPG ключа: 4AEE18F83AFDEB23
2 змінених файлів з 10 додано та 10 видалено
  1. +6
    -6
      examples/shaders/resources/shaders/glsl330/julia_shader.fs
  2. +4
    -4
      examples/shaders/shaders_julia_set.c

+ 6
- 6
examples/shaders/resources/shaders/glsl330/julia_shader.fs Переглянути файл

@ -15,10 +15,10 @@ const int MAX_ITERATIONS = 255; // Max iterations to do.
// Square a complex number // Square a complex number
vec2 complexSquare(vec2 z) vec2 complexSquare(vec2 z)
{ {
return vec2(
z.x * z.x - z.y * z.y,
z.x * z.y * 2.0
);
return vec2(
z.x * z.x - z.y * z.y,
z.x * z.y * 2.0
);
} }
// Convert Hue Saturation Value color into RGB // Convert Hue Saturation Value color into RGB
@ -33,8 +33,8 @@ vec3 hsv2rgb(vec3 c)
void main() void main()
{ {
// The pixel coordinates scaled so they are on the mandelbrot scale. // The pixel coordinates scaled so they are on the mandelbrot scale.
vec2 z = vec2(((gl_FragCoord.x + offset.x)/screenDims.x) * 2.5 * zoom,
((screenDims.y - gl_FragCoord.y + offset.y)/screenDims.y) * 1.5 * zoom); // y also flipped due to opengl
vec2 z = vec2((((gl_FragCoord.x + offset.x)/screenDims.x) * 2.5)/zoom,
(((screenDims.y - gl_FragCoord.y + offset.y)/screenDims.y) * 1.5)/zoom); // y also flipped due to opengl
int iterations = 0; int iterations = 0;
/* /*

+ 4
- 4
examples/shaders/shaders_julia_set.c Переглянути файл

@ -45,9 +45,9 @@ int main()
// c constant to use in z^2 + c // c constant to use in z^2 + c
float c[2] = { POINTS_OF_INTEREST[0][0], POINTS_OF_INTEREST[0][1] }; float c[2] = { POINTS_OF_INTEREST[0][0], POINTS_OF_INTEREST[0][1] };
// Offset and zoom to draw the julia set at. (centered on screen and mf">1.6 times smaller)
// Offset and zoom to draw the julia set at. (centered on screen and k">default size)
float offset[2] = { -(float)screenWidth/2, -(float)screenHeight/2 }; float offset[2] = { -(float)screenWidth/2, -(float)screenHeight/2 };
float zoom = 1.6f;
float zoom = 1.0f;
Vector2 offsetSpeed = { 0.0f, 0.0f }; Vector2 offsetSpeed = { 0.0f, 0.0f };
@ -111,8 +111,8 @@ int main()
// Probably offset movement should be proportional to zoom level // Probably offset movement should be proportional to zoom level
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON) || IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) if (IsMouseButtonDown(MOUSE_LEFT_BUTTON) || IsMouseButtonDown(MOUSE_RIGHT_BUTTON))
{ {
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) zoom -= 0.003f;
if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) zoom += 0.003f;
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) zoom += zoom * 0.003f;
if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) zoom -= zoom * 0.003f;
Vector2 mousePos = GetMousePosition(); Vector2 mousePos = GetMousePosition();

Завантаження…
Відмінити
Зберегти