Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please provide resolution as vec2 to the shader #4

Open
theMK2k opened this issue Oct 31, 2018 · 5 comments
Open

Please provide resolution as vec2 to the shader #4

theMK2k opened this issue Oct 31, 2018 · 5 comments

Comments

@theMK2k
Copy link

theMK2k commented Oct 31, 2018

Hi,

while porting more shadertoy shaders to VLS, I found that in VLS the resolution information is missing in the shader.

While looking for clues in the VLS sources, I saw that you provide it for m_postFX as "screen" (renderwidget.cpp line 165).

As I'm unable to compile VLS myself, could you please add the resolution info to a new VLS binary release?

@lamogui
Copy link
Collaborator

lamogui commented Nov 2, 2018

Have tried to just add

uniform vec2 screen;

else the uv you can find in most of raymarched shader correspond to the v of VLS (and so you probably don't need the resolution :)

@theMK2k
Copy link
Author

theMK2k commented Nov 2, 2018

Hey @lamogui,

thanks for your reply. Unfortunately, the solution you proposed doesn't work.

Btw. the shader I'm talking about here is [1] https://www.shadertoy.com/view/MsVfz1

You're right, that in most cases I can just use v and assign it to uv of ShaderToy sources.

This is the case when ShaderToy sources have a line like this (see [1] line 845):

vec2 uv = (fragCoord - iResolution.xy*.5) / iResolution.y;

I can do

vec2 uv = v;

and in case of [1] modified it a bit to have a "better" view:

vec2 uv = v - v*.5;

Unfortunately though, this didn't work out well with a line like this (see [1] line 978 here uv is re-assigned):

uv = fragCoord/iResolution.xy;

If I do

uv = v;

I get a checkerboarded output:

grafik

My workaround until now is:

uv = fragCoord/vec2(1920, 1080);

which worked - but I didn't like the approach.

Your proposal using uniform vec2 screen (even though the sources of VLS don't hint at it being ever sent to the shader):

uv = fragCoord/screen;

or even

uv = fragCoord/screen.xy;

didn't work at all: black screen.

@lamogui
Copy link
Collaborator

lamogui commented Nov 4, 2018

you can try uv = v *2.0 - 1.0

@theMK2k
Copy link
Author

theMK2k commented Nov 4, 2018

almost :)

grafik

@theMK2k
Copy link
Author

theMK2k commented Nov 4, 2018

uv = (v - 1.0) * 2.0;

does the trick. Thanks for your suggestion!

grafik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants