Skip to content

Commit

Permalink
Merge pull request #23 from CedricGuillemet/dev-0.6.0
Browse files Browse the repository at this point in the history
start of 0.6.0 branch
  • Loading branch information
CedricGuillemet authored Dec 2, 2018
2 parents c26e698 + 6e375ec commit 45a3b95
Show file tree
Hide file tree
Showing 232 changed files with 32,511 additions and 978 deletions.
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ set(PLATFORM_LIBS dl pthread ${GTK3_LIBRARIES} libtcc.a)
endif()

set(FFMPEG_LIBS avcodec.lib avdevice.lib avfilter.lib avformat.lib avutil.lib swscale.lib swresample.lib postproc.lib)
set(PYTHON37_LIBS python3.lib python37.lib)

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/src
Expand All @@ -52,12 +53,14 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/ext/NativeFileDialog/src/include/
${CMAKE_CURRENT_SOURCE_DIR}/ext/enkiTS-C-11/src/
${CMAKE_CURRENT_SOURCE_DIR}/ext/ffmpeg/include
${CMAKE_CURRENT_SOURCE_DIR}/ext/python37/include
)

link_directories(
${CMAKE_CURRENT_SOURCE_DIR}/ext/SDL2-2.0.8/lib/x64
${CMAKE_CURRENT_SOURCE_DIR}/ext/tcc-0.9.27/libtcc
${CMAKE_CURRENT_SOURCE_DIR}/ext/ffmpeg/lib
${CMAKE_CURRENT_SOURCE_DIR}/ext/python37/libs
)
find_package(OpenGL)

Expand Down Expand Up @@ -112,7 +115,7 @@ SET(EXE_NAME "Imogen")

ADD_EXECUTABLE(${EXE_NAME} ${SRC_FILES} ${EXT_FILES} ${NFD_FILES})

TARGET_LINK_LIBRARIES(${EXE_NAME} ${SDL2_LIBS} ${OPENGL_LIBRARIES} ${PLATFORM_LIBS} ${FFMPEG_LIBS})
TARGET_LINK_LIBRARIES(${EXE_NAME} ${SDL2_LIBS} ${OPENGL_LIBRARIES} ${PLATFORM_LIBS} ${FFMPEG_LIBS} ${PYTHON37_LIBS})

#--------------------------------------------------------------------
# preproc
Expand All @@ -123,9 +126,10 @@ add_definitions(-DBX_CONFIG_ENABLE_MSVC_LEVEL4_WARNINGS=1)
add_definitions(-D__STDC_LIMIT_MACROS)
add_definitions(-D__STDC_CONSTANT_MACROS)
add_definitions(-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS)
if(WINDOWS)
if(MSVC)
add_definitions(-DWIN32)
add_definitions(-D_WIN32)
add_definitions(-DNOMINMAX)
endif()
add_definitions(-DUSE_DL_PREFIX)
#--------------------------------------------------------------------
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ GPU/CPU Texture Generator

WIP of a GPU Texture generator using dear imgui for UI. Not production ready and a bit messy but really fun to code.
Basically, add GPU and CPU nodes in a graph to manipulate and generate images. Nodes are hardcoded now but a discovery system is planned.
Currently nodes can be written in GLSL or C. Python is coming next.
Currently nodes can be written in GLSL or C or Python.

![Image of Imogen 0.4](https://i.imgur.com/pmliWGl.png)
![Image of Imogen 0.4](https://i.imgur.com/jNWsXD6.png)

Expand All @@ -13,7 +14,7 @@ Features:
- Node based texture editing
- material library browser
- edit/change node shaders inside the app
- bake textures to .png, .jpg, .tga, .bmp, .hdr
- bake textures to .png, .jpg, .tga, .bmp, .hdr, mp4
- PBR preview

Currently implemented nodes
Expand Down Expand Up @@ -65,3 +66,7 @@ cmft - cubemap filtering tool - Dario Manesku https://github.com/dariomanesku/cm
dear imgui color scheme - codz01 https://github.com/ocornut/imgui/issues/1902#issuecomment-429445321

FFMPEG - Fabrice Bellard

Python 3 - Python.org

pybind 11 - https://github.com/pybind/pybind11
31 changes: 0 additions & 31 deletions bin/GLSL/Tile.glsl

This file was deleted.

Binary file modified bin/Imogen.exe
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions bin/Nodes/C/GradientBuilder.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "Imogen.h"

int main(void *param, Evaluation *evaluation)
{
SetEvaluationSize(evaluation->targetIndex, 512, 64);
return EVAL_OK;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions bin/GLSL/CubemapView.glsl → bin/Nodes/GLSL/CubemapView.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ vec4 Projection(vec2 uv)
return texture(CubeSampler0, normalize(vec3(a.x*a.y, -b.y, b.x*a.y)));
}

vec4 Camera(vec2 uv)
vec4 CameraView(vec2 uv)
{
float an = CubemapViewParam.view.x * PI * 2.0;
float dn = CubemapViewParam.view.y * PI * 0.5;
Expand Down Expand Up @@ -101,6 +101,6 @@ vec4 CubemapView()
case 2:
return CrossView(uv);
case 3:
return Camera(uv);
return CameraView(uv);
}
}
File renamed without changes.
26 changes: 26 additions & 0 deletions bin/Nodes/GLSL/GradientBuilder.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
vec4 GetRamp(float v, vec4 arr[8])
{
for (int i = 0;i<(arr.length()-1);i++)
{
if (v >= arr[i].w && v <= arr[i+1].w)
{
// linear
float t = (v-arr[i].w)/(arr[i+1].w-arr[i].w);
// smooth
//float t = smoothstep(arr[i].w, arr[i+1].w, v);
return sqrt(mix(arr[i]*arr[i], arr[i+1]*arr[i+1], t));
}
}

return vec4(0.0);
}

layout (std140) uniform GradientBuilderBlock
{
vec4 ramp[8];
} GradientBuilderParam;

vec4 GradientBuilder()
{
return vec4(GetRamp(vUV.x, GradientBuilderParam.ramp).xyz, 1.0);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions bin/Nodes/GLSL/NGon.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

layout (std140) uniform NGonBlock
{
int sides;
float radius;
float t;
};

vec4 NGon()
{
vec2 p = vUV - vec2(0.5);

vec2 d = vec2(0.0, 1.0);
float ng = 0.0;
float col = 0.0;

for(int i = 0;i<sides;i++)
{
vec2 rd = Rotate2D(d, ng);
ng += 3.14159*2.0 / float(sides);
float d = smoothstep(mix(-radius, 0.0, t), 0.001, dot(p,rd)-radius);
col = max(col, d);
}
col = 1.0 - col;
return vec4(col);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 4 additions & 1 deletion bin/GLSL/Ramp.glsl → bin/Nodes/GLSL/Ramp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ layout (std140) uniform RampBlock
vec4 Ramp()
{
vec4 tex = texture(Sampler0, vUV);
return tex * GetRamp(tex.x, RampParam.ramp);
if (EvaluationParam.inputIndices[0].y > -1.)
return texture(Sampler1, vec2(tex.x, 0.5));
else
return tex * GetRamp(tex.x, RampParam.ramp);
}
9 changes: 8 additions & 1 deletion bin/GLSL/Shader.glsl → bin/Nodes/GLSL/Shader.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@ layout (std140) uniform EvaluationBlock
int uiPass;
int padding;
vec4 mouse; // x,y, lbut down, rbut down
int inputIndices[8];
ivec4 inputIndices[2];

vec2 viewport;
} EvaluationParam;

struct Camera
{
vec4 pos;
vec4 dir;
vec4 up;
vec4 lens;
};

layout(location=0) out vec4 outPixDiffuse;
in vec2 vUV;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
49 changes: 49 additions & 0 deletions bin/Nodes/GLSL/Tile.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
layout (std140) uniform TileBlock
{
vec2 offset0;
vec2 offset1;
vec2 overlap;
float scale;
} TileParam;

vec4 GetTile0(vec2 uv)
{
if (uv.x > 1.0 || uv.y > 1.0 || uv.x <0.0 || uv.y<0.0)
return vec4(0.0);

return texture(Sampler0, uv);
}

vec2 GetOffset(vec2 uv)
{
float o = float(int(floor(uv.y))&1) * TileParam.offset0.x;
return vec2(o,0.);
}

vec4 GetTile(vec2 uv)
{
vec2 cellSize = vec2(1.0) - TileParam.overlap;

vec4 c = vec4(0.0);

for (int y = -1;y<2;y++)
{
for (int x = -1;x<2;x++)
{
vec2 cell0 = uv - (fract(uv/cellSize) + vec2(float(x), float(y))) * cellSize;
vec2 cell1 = (floor(uv/cellSize) + vec2(float(x), float(y)));// * cellSize;
vec4 multiplier = vec4(1.0);
if (EvaluationParam.inputIndices[0].y > -1.)
multiplier = texture(Sampler1, cell0/TileParam.scale);
c += GetTile0(uv - cell0 + GetOffset(cell1)) * multiplier;
}
}

return c;
}

vec4 Tile()
{
vec2 nuv = vUV * TileParam.scale;
return GetTile(nuv);
}
File renamed without changes.
18 changes: 18 additions & 0 deletions bin/Nodes/GLSL/Warp.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
layout (std140) uniform WarpBlock
{
float strength;
int mode;
} WarpParam;

vec4 Warp()
{
vec4 texOffset = texture(Sampler1, vUV);
vec2 nuv = vUV;
if (WarpParam.mode == 0)
nuv += (texOffset.xy-0.5) * WarpParam.strength;
else
nuv += vec2(cos(texOffset.x * PI * 2.0), sin(texOffset.x * PI * 2.0)) * WarpParam.strength;
vec4 tex = texture(Sampler0, nuv);

return tex;
}
File renamed without changes.
17 changes: 17 additions & 0 deletions bin/Nodes/Python/testnode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import imo

def test(a, b, e):
res = imo.add(a,b)
res2 = imo.add2(a, b)
#e = imo.accessor_api()
print ("result = {}".format(res))
print ("result2 = {}".format(res2))
print ("target is {}".format(e["target"]))
print ("inputs is {}".format(e["inputs"]))
img = imo.GetImage()
print (img)
imo.SaveImage(img)
print (imo.add)
#help(imo)
return 1

31 changes: 31 additions & 0 deletions bin/Stock/NodeError.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifdef VERTEX_SHADER

layout(location = 0)in vec2 inUV;
out vec2 vUV;

void main()
{
gl_Position = vec4(inUV.xy*2.0 - 1.0,0.5,1.0); vUV = inUV;
}

#endif

#ifdef FRAGMENT_SHADER

uniform float time;
#define PI 3.1415926
layout(location = 0) out vec4 outPixDiffuse;
in vec2 vUV;

void main()
{
// base of shader by FabriceNeyret2 https://www.shadertoy.com/view/XlfBW7
vec2 U = vUV*2.5-1.25;
U.x = asin( U.x / cos( U.y = asin(U.y) )) - time;
U = 6.* sin(8.*U);
outPixDiffuse = vec4(0.5,0.0,0.0,1.0);
outPixDiffuse.r = max(outPixDiffuse.r, outPixDiffuse.r+U.x/U.x);
outPixDiffuse.gb += U.x*U.y;
}

#endif
Binary file modified bin/library.dat
Binary file not shown.
Binary file added bin/python3.dll
Binary file not shown.
Binary file added bin/python37.dll
Binary file not shown.
Binary file added bin/vcruntime140.dll
Binary file not shown.
22 changes: 22 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
-------------------------------------------------------------------------------
Imogen 0.6 - codename Saori Kido

New:
- Python 3.7 node evaluators (experimental)
- warp transform node
- NGon generator node
- Gradient builder node
- Camera parameter type
- Amiga ball displayed when there is compilation error
- Gradient builder parameter widget
- undo/redo (beta)

Changed:
- fixed tile node
- Ramp node can use an optional input texture
- dear imgui version bump

Known issue:
- Japanese tile sample is broken
- Cubemap filtering doesn't work and may use a lot of CPU/RAM

-------------------------------------------------------------------------------
Imogen 0.5 - codename Phoenix Ikki

Expand Down
Loading

0 comments on commit 45a3b95

Please sign in to comment.