Skip to content

Commit

Permalink
Fixed texture flip issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Jul 9, 2023
1 parent 1c8b017 commit b66e86b
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 12 deletions.
1 change: 1 addition & 0 deletions shaders/colorizers/gradient.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ vec4 deriveTexturePixel(vec2 coord, float nrmRe, float nrmIm)
void main()
{
vec2 coord = gl_TexCoord[0].xy;
coord.y = 1.0 - coord.y;

// Get diffuse color from palette image
vec3 diffuseColor = deriveColor(coord);
Expand Down
1 change: 1 addition & 0 deletions shaders/illuminators/lambert.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ vec3 makeSpatial(vec3 color, float nrmRe, float nrmIm)
void main()
{
vec2 coord = gl_TexCoord[0].xy;
coord.y = 1.0 - coord.y;

// Get color pixel
vec3 diffuseColor = texture2D(image, coord).rgb;
Expand Down
1 change: 1 addition & 0 deletions shaders/illuminators/normalmap.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ float decode_float(vec4 v)
void main()
{
vec2 coord = gl_TexCoord[0].xy;
coord.y = 1.0 - coord.y;

// Get the normal vector
float nrmRe = decode_float(texture2D(normalRe, coord));
Expand Down
5 changes: 1 addition & 4 deletions shaders/illuminators/relief.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,12 @@ vec3 makeSpatial(float nrmRe, float nrmIm)
void main()
{
vec2 coord = gl_TexCoord[0].xy;
coord.y = 1.0 - coord.y;

// Get the normal vector
float nrmRe = decode_float(texture2D(normalRe, coord));
float nrmIm = decode_float(texture2D(normalIm, coord));

// Normalize
vec3 N = normalize(vec3(nrmRe, nrmIm, 1.0));
vec3 L = normalize(lightDir);

// Apply 3D effect
vec3 final = makeSpatial(nrmRe, nrmIm);

Expand Down
5 changes: 4 additions & 1 deletion shaders/scalers/bicubic.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ vec4 bicubic(sampler2D sampler, vec2 texCoords)

void main()
{
vec2 coord = zoomed(gl_TexCoord[0].xy);
vec2 coord = gl_TexCoord[0].xy;
coord.y = 1.0 - coord.y;
coord = zoomed(coord);

vec4 color1 = bicubic(curr, coord);
gl_FragColor = gl_Color * color1;
}
Expand Down
5 changes: 4 additions & 1 deletion shaders/scalers/bilinear.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ vec4 bilinear(sampler2D sampler, vec2 coord)

void main()
{
vec2 coord = zoomed(gl_TexCoord[0].xy);
vec2 coord = gl_TexCoord[0].xy;
coord.y = 1.0 - coord.y;
coord = zoomed(coord);

vec4 color1 = bilinear(curr, coord);
gl_FragColor = gl_Color * color1;
}
5 changes: 4 additions & 1 deletion shaders/scalers/nearest.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ vec2 zoomed(vec2 coord)

void main()
{
vec2 coord = zoomed(gl_TexCoord[0].xy);
vec2 coord = gl_TexCoord[0].xy;
coord.y = 1.0 - coord.y;
coord = zoomed(coord);

vec4 pixel = texture2D(curr, coord);
gl_FragColor = gl_Color * pixel;
}
5 changes: 4 additions & 1 deletion shaders/scalers/tricubic.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ vec4 bicubic(sampler2D sampler, vec2 texCoords)
void main()
{
// Read texel from the current texture
vec2 coord = zoomed(gl_TexCoord[0].xy);
vec2 coord = gl_TexCoord[0].xy;
coord.y = 1.0 - coord.y;
coord = zoomed(coord);

vec4 color1 = bicubic(curr, coord);

// Check if a corresponding texel exists in the next texture
Expand Down
5 changes: 4 additions & 1 deletion shaders/scalers/trilinear.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ vec4 bilinear(sampler2D sampler, vec2 coord)
void main()
{
// Read texel from the current texture
vec2 coord = zoomed(gl_TexCoord[0].xy);
vec2 coord = gl_TexCoord[0].xy;
coord.y = 1.0 - coord.y;
coord = zoomed(coord);

vec4 color1 = bilinear(curr, coord);

if (zoom > 1.0) {
Expand Down
6 changes: 6 additions & 0 deletions src/ddrill/Driller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,20 @@ Driller::drill(const Coord &point, std::vector<Coord> &glitchPoints)

while (++iteration < limit) {

// auto two_xn_plus_dn = ref.xn[iteration - 1].extended2 + dn;
// auto two_xn_plus_two_two_dn = two_xn_plus_dn + dn;

dercn *= ref.xn[iteration - 1].extended2 + (dn * 2.0);
// dercn *= two_xn_plus_two_two_dn;
dercn += derc0;
dercn.reduce();

derzn *= ref.xn[iteration - 1].extended2 + (dn * 2.0);
// derzn *= two_xn_plus_two_two_dn;
derzn.reduce();

dn *= ref.xn[iteration - 1].extended2 + dn;
// dn *= two_xn_plus_dn;
dn += d0;
dn.reduce();

Expand Down
4 changes: 2 additions & 2 deletions src/shared/DrillMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,8 @@ DrillMap::loadChannel(Compressor &is)

for (isize y = 0; y < height; y++) {
for (isize x = 0; x < width; x++) {
normalReMap[y * width + x] = double(loadFloat());
normalImMap[y * width + x] = double(loadFloat());
normalReMap[y * width + x] = float(loadFloat());
normalImMap[y * width + x] = float(loadFloat());
}
}
break;
Expand Down
1 change: 0 additions & 1 deletion src/shared/Filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class Filter {

public:

// Filter(const Options &opt) : opt(opt) { };
void init(const string &shaderName, isize w, isize h);
void init(const string &shaderName, sf::Vector2u resolution);

Expand Down

0 comments on commit b66e86b

Please sign in to comment.