Skip to content

Commit

Permalink
Merge pull request #15 from CedricGuillemet/dev-0.3.0
Browse files Browse the repository at this point in the history
Imogen 0.3 - codename Cygnus Hyoga
  • Loading branch information
CedricGuillemet authored Oct 8, 2018
2 parents 66ed2cd + c780a02 commit bcc02b8
Show file tree
Hide file tree
Showing 25 changed files with 1,088 additions and 251 deletions.
29 changes: 28 additions & 1 deletion bin/C/Imogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,33 @@ typedef struct Image_t
typedef struct Evaluation_t
{
int targetIndex;
int inputIndices[8];
int forcedDirty;
int uiPass;
int padding;
float mouse[4];
int inputIndices[8];
} Evaluation;

enum BlendOp
{
ZERO,
ONE,
SRC_COLOR,
ONE_MINUS_SRC_COLOR,
DST_COLOR,
ONE_MINUS_DST_COLOR,
SRC_ALPHA,
ONE_MINUS_SRC_ALPHA,
DST_ALPHA,
ONE_MINUS_DST_ALPHA,
CONSTANT_COLOR,
ONE_MINUS_CONSTANT_COLOR,
CONSTANT_ALPHA,
ONE_MINUS_CONSTANT_ALPHA,
SRC_ALPHA_SATURATE,
BLEND_LAST
};

// call FreeImage when done
int ReadImage(char *filename, Image *image);
// writes an allocated image
Expand All @@ -35,5 +58,9 @@ int SetThumbnailImage(Image *image);
// no guarantee that the resulting Image will have that size.
int Evaluate(int target, int width, int height, Image *image);

void SetBlendingMode(int target, int blendSrc, int blendDst);
int GetEvaluationSize(int target, int *imageWidth, int *imageHeight);
int SetEvaluationSize(int target, int imageWidth, int imageHeight);

#define EVAL_OK 0
#define EVAL_ERR 1
13 changes: 13 additions & 0 deletions bin/C/Paint2D.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "Imogen.h"

typedef struct Paint2D_t
{
int size;
} Paint2D;

int main(Paint2D *param, Evaluation *evaluation)
{
SetEvaluationSize(evaluation->targetIndex, 256<<param->size, 256<<param->size);
SetBlendingMode(evaluation->targetIndex, ONE, ONE_MINUS_SRC_ALPHA);
return EVAL_OK;
}
23 changes: 23 additions & 0 deletions bin/GLSL/Crop.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
layout (std140) uniform CropBlock
{
vec4 quad;
} CropParam;

vec4 Crop()
{
if (EvaluationParam.uiPass == 1)
{
vec4 q = vec4(min(CropParam.quad.x, CropParam.quad.z),
min(CropParam.quad.y, CropParam.quad.w),
max(CropParam.quad.x, CropParam.quad.z),
max(CropParam.quad.y, CropParam.quad.w));
float barx = min(step(q.x, vUV.x), step(vUV.x, q.z));
float bary = min(step(q.y, vUV.y), step(vUV.y, q.w));
float colFactor = min(barx, bary);
return texture(Sampler0, vUV) * max(colFactor, 0.5);
}

vec4 q = CropParam.quad;
vec2 uv = vec2(mix(min(q.x, q.z), max(q.x, q.z), vUV.x), mix(min(q.y, q.w), max(q.y, q.w), vUV.y));
return texture(Sampler0, uv);
}
2 changes: 1 addition & 1 deletion bin/GLSL/LambertMaterial.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ layout (std140) uniform LambertMaterialBlock

vec4 LambertMaterial()
{
vec2 p = vUV *vec2(2.0,-2.0) +vec2(- 1.0, 1.0);
vec2 p = vUV * 2.0 - 1.0;

// camera movement
float an = LambertMaterialParam.view.x * PI * 2.0;
Expand Down
2 changes: 1 addition & 1 deletion bin/GLSL/PBR.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ layout (std140) uniform PBRBlock

vec4 PBR()
{
vec2 p = vUV *vec2(2.0,-2.0) +vec2(- 1.0, 1.0);
vec2 p = vUV * 2.0 - 1.0;

// camera movement
float an = PBRParam.view.x * PI * 2.0;
Expand Down
33 changes: 33 additions & 0 deletions bin/GLSL/Paint2D.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
layout (std140) uniform Paint2DBlock
{
int size; // 1<<(size+8)
} Paint2DParam;

vec4 brushSample(vec2 uv, float radius)
{
vec2 nuv = (uv) / radius + vec2(0.5);
float alphaMul = min(min(step(0.0, nuv.x), step(nuv.x, 1.0)), min(step(0.0, nuv.y), step(nuv.y, 1.0)));
return texture(Sampler0, nuv) * alphaMul;
}
vec4 Paint2D()
{
vec4 res = vec4(0.0);
float brushRadius = 0.25;
vec4 brush = brushSample(vUV-EvaluationParam.mouse.xy, brushRadius);
if (EvaluationParam.uiPass == 1)
{
res = brush;
}
// paint pass
if (EvaluationParam.mouse.z > 0.0)
{
res = brush;
}
if (EvaluationParam.mouse.w > 0.0)
{
res = brush;
res.xyz = vec3(0.0);
}

return vec4(res.xyz*res.w, res.w);
}
2 changes: 1 addition & 1 deletion bin/GLSL/Pixelize.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ layout (std140) uniform PixelizeBlock

vec4 Pixelize()
{
vec4 tex = texture(Sampler0, floor(vUV*PixelizeParam.scale)/PixelizeParam.scale);
vec4 tex = texture(Sampler0, floor(vUV*PixelizeParam.scale+0.5)/PixelizeParam.scale);
return tex;
}
12 changes: 5 additions & 7 deletions bin/GLSL/PolarCoords.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,22 @@ layout (std140) uniform PolarCoordsBlock
int op;
} PolarCoordsParam;

#define M_PI 3.1415926535897932384626433832795

vec4 PolarCoords()
{
vec2 uvin = vUV - vec2(0.5,0.5);
vec2 uv;
if (PolarCoordsParam.op == 1)
{
uv.x = cos(uvin.x * M_PI * 2 + M_PI / 2) * (1 - (uvin.y + 0.5)) / 2 + 0.5;
uv.y = sin(uvin.x * M_PI * 2 + M_PI / 2) * (1 - (uvin.y + 0.5)) / 2 + 0.5;
uv.x = cos(uvin.x * PI * 2 + PI / 2) * (1 - (uvin.y + 0.5)) / 2 + 0.5;
uv.y = sin(uvin.x * PI * 2 + PI / 2) * (1 - (uvin.y + 0.5)) / 2 + 0.5;
}
else
{
uv.x = atan(uvin.y, uvin.x);
uv.x += M_PI / 2;
uv.x += PI / 2;
if (uv.x < 0)
uv.x += M_PI * 2;
uv.x /= M_PI * 2;
uv.x += PI * 2;
uv.x /= PI * 2;
uv.y = 1 - length(uvin) * 2;
}
vec4 tex = texture(Sampler0, uv);
Expand Down
15 changes: 14 additions & 1 deletion bin/GLSL/Shader.glsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#define PI 3.14159265359
#define SQRT2 1.414213562373095

#define TwoPI (PI*2)

#ifdef VERTEX_SHADER
Expand All @@ -17,6 +19,18 @@ void main()

#ifdef FRAGMENT_SHADER

layout (std140) uniform EvaluationBlock
{
int targetIndex;
int forcedDirty;
int uiPass;
int padding;
vec4 mouse; // x,y, lbut down, rbut down
int inputIndices[8];

} EvaluationParam;


layout(location=0) out vec4 outPixDiffuse;
in vec2 vUV;

Expand Down Expand Up @@ -75,7 +89,6 @@ __NODE__
void main()
{
outPixDiffuse = vec4(__FUNCTION__);
outPixDiffuse.a = 1.0;
}

#endif
15 changes: 15 additions & 0 deletions bin/GLSL/Swirl.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
layout (std140) uniform SwirlBlock
{
vec2 angles;
} SwirlParam;

vec4 Swirl()
{
vec2 uv = vUV - vec2(0.5);
float len = length(uv) / (SQRT2 * 0.5);
float angle = mix(SwirlParam.angles.x, SwirlParam.angles.y, len);
vec2 nuv = Rotate2D(uv, angle) + vec2(0.5);
vec4 tex = texture(Sampler0, nuv);

return tex;
}
Binary file modified bin/Imogen.exe
Binary file not shown.
Binary file added bin/Pictures/saint-seiya.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified bin/library.dat
Binary file not shown.
28 changes: 28 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
-------------------------------------------------------------------------------
Imogen 0.4 - Andromeda Shun

New:

Changed:

Fixed:

-------------------------------------------------------------------------------
Imogen 0.3 - codename Cygnus Hyoga

New:
- C nodes can change the size and blending mode of the texture target
- Nodes can mix C and GLSL
- Paint2D node
- Swirl node
- Crop node
- UI mode for nodes : nodes can display user information
- Nodes can handle mouse pos and buttons
- openGL debug output in the console
- image ratio support
- better image resize in the NodeEdit panel

Changed:
- more consistent texV management
- Threaded decoding and loading of node textures (paint2d Surface)

-------------------------------------------------------------------------------
Imogen 0.2 - codename Dragon Shiryu

Expand Down
Loading

0 comments on commit bcc02b8

Please sign in to comment.