We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm trying to figure out DwShadertoy's implementation of Shadertoy shaders, however there are two big issues I've ran into. The first is that the window won't render until it is resized when setResizable is true. The second is the mouse Y cords are not mapped correctly. MouseY seems to be shifted 2/3rds of the screen down. Trying to compensate for the shift doesn't seem to have any effect.
See the example script "WetStone" included in pixelflow for reference.
if(mousePressed){
toy.set_iMouse(mouseX, height-1-mouseY, mouseX, height-1-mouseY);
}
This is the default in all the example scripts and I'm trying to figure out why that is and why it doesn't work.
/**
*
* PixelFlow | Copyright (C) 2017 Thomas Diewald - www.thomasdiewald.com
*
* https://github.com/diwi/PixelFlow.git
*
* A Processing/Java library for high performance GPU-Computing.
* MIT License: https://opensource.org/licenses/MIT
*
*/
import com.thomasdiewald.pixelflow.java.DwPixelFlow;
import com.thomasdiewald.pixelflow.java.imageprocessing.DwShadertoy;
//
// Shadertoy Demo: https://www.shadertoy.com/view/ldSSzV
// Shadertoy Author: https://www.shadertoy.com/user/TDM
//
DwPixelFlow context;
DwShadertoy toy;
public void settings() {
size(1280, 720, P2D);
smooth(0);
}
public void setup() {
surface.setResizable(true);
context = new DwPixelFlow(this);
context.print();
context.printGL();
toy = new DwShadertoy(context, "data/WetStone.frag");
frameRate(60);
}
public void draw() {
if(mousePressed){
toy.set_iMouse(mouseX, height-1-mouseY, mouseX, height-1-mouseY);
}
toy.apply(g);
String txt_fps = String.format(getClass().getSimpleName()+ " [size %d/%d] [frame %d] [fps %6.2f]", width, height, frameCount, frameRate);
surface.setTitle(txt_fps);
}
Answers
The shader is limiting the rotation.
Removing the clamp call allows full rotation but also allows the camera to be inside the 'table'.
You can free the y-rotation by changing the line that starts with "if(iMouse.z > 0.0)" inside imageMain().
From:
To:
Surely there is a way to adjust the mouse coordinates inside the shader to account for the middle of the window but I have not looked that far into it.
When I run the example, even copying your post, I always see a rotating rock and do not need to resize to see the render.
Perhaps it is a difference of operating system or hardware?
I am running 64 bit Linux, NVidia card, GL 4.5 (version is printed by the 'wetstone' sketch).
Interesting, thanks for testing. For the mouseY, it does behave a bit differently than on shadertoy's website even though it's clamped. On shadertoy's website, the Y values change at about the 1/3 down when it starts rotating vertically, while in processing the Y values don't start rotating until it's at 2/3 to the bottom or so.
For me:
Win 10, 64 bit
DEVICE ... AMD Mobility Radeon HD 5800 Series
GLSL ..... #version 440 core / 4.40.0
GL ....... 4.5