massung / r-cade

Retro Game Engine for Racket
https://r-cade.io
Other
273 stars 13 forks source link

Broken Visuals With Racket 8.1 cs #30

Closed youssefsahli closed 2 years ago

youssefsahli commented 3 years ago

Description: Since the 8.1 cs version, running any example gives broken visuals.

Screenshots: Screenshot from 2021-05-23 19-31-39 Screenshot from 2021-05-23 19-40-16

|| || ||\ || || \ // CPU: Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz || || ||\|| || )X( DESKTOP: GNOME \_// || || || // \ DEVICE: HP Notebook DISTRO: Fedora 34 (Workstation Edition) EDITOR: N/A (Could Not Read $Editor, Make Sure It Is Set) KERNEL: 5.11.20-300.fc34.x86_64 PKGS: DNF MEMORY: 3816MB SHELL: NU UPTIME: 4d 0h 9m

massung commented 3 years ago

This is definitely something I haven't noticed. Could you try a couple things:

  1. Try calling run with #:shader #f to turn off the shader. Is everything ok?
  2. It's not updated yet in raco, but if you clone the repo, you can install it locally and see if the same thing happens with the master branch...
% raco pkg remove r-cade   # remove already installed version
% cd r-cade   # cd into cloned repository folder
% raco pkg install   # install using local, cloned copy
youssefsahli commented 3 years ago

Running without the shader works. After cloning the repo, and installing it, I can see the same bug again, with the shader on.

massung commented 3 years ago

I've been trying different things, but can't seem to get anything like this to repro. I don't have a Linux box to test on, sadly. The CRT shader is most definitely the culprit (see: https://github.com/massung/r-cade/blob/master/shader.rkt#L44). But, it would be difficult to debug w/o some help from you. Also, do you have a video card? If so, which one? The shader doesn't really do anything special, but maybe there's a odd function I'm using that's not working and I can work around it.

If you're willing to work with me a bit w/ the code, there are a few things you may consider trying to see what happens:

  1. Try changing the last line of the shader (see: https://github.com/massung/r-cade/blob/master/shader.rkt#L109) to this:
"gl_FragColor = vec4(texture2D(texture, gl_TexCoord[0].xy).rgb, 1.0);"

This should have the same effect as using #:shader #f, but still actually use the shader. If that's still messed up, then the issue is more fundamental. If it looks fine, then at least that's a start.

  1. I don't use any special GLSL shader functions, but it may help to add a specific version line to the shader. That would mean at the very beginning of the shader (see: https://github.com/massung/r-cade/blob/master/shader.rkt#L44) adding a line like so before anything else:
"#version 110\n"   ; NOTE the \n is needed!

You can see all available GLSL versions here: https://riptutorial.com/glsl. You may also try ES versions to see if they work for you. If you hit something that does the trick, let me know and I can update the repo.

  1. It's possible the shader is being compiled using low-precision data types. There's technically no default precision used by the compiler. After the #version line, you can try forcing high precision floats and integers:
"precision highp float;"
"precision highp int;"

If that has no effect, it's also possible high precision is supported on your system. I find that unlikely, but you can use mediump instead. As a mental note, I can run it locally using lowp precision and the shader still works fine.

I understand if you aren't willing to try these things out, but if you are, I thank you very much!

Edit: note that if you've cloned the repo and used raco pkg install on the local copy, you don't need to uninstall/reinstall the package each change. You can just edit the shader.rkt file and re-run the programs.

youssefsahli commented 3 years ago
Uniform "resolution" not found in shader
Uniform "scale" not found in shader "
- version 320 es: same as 300 es

- version 120 & 130: No error but broken as before.

- version 330 & 400 : 

Failed to compile fragment shader: 0:2(748): error: gl_TexCoord' undeclared 0:2(748): error: type mismatch 0:2(748): error: operands to arithmetic operators must be numeric 0:2(1108): warning:pixel' used uninitialized 0:2(1150): warning: `pixel' used uninitialized



* Notes:
- _(Precision qualifiers don't work with glsl versions prior to 130)_
- using mediump: nothing changes
- using lowp: same
youssefsahli commented 2 years ago

Good news! Since 8.5 everything is back to normal.