XT95 / VisualLiveSystem

A visual jockey software, real time shaders based.
MIT License
40 stars 4 forks source link

Please provide resolution as vec2 to the shader #4

Open theMK2k opened 6 years ago

theMK2k commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

you can try uv = v *2.0 - 1.0

theMK2k commented 6 years ago

almost :)

grafik

theMK2k commented 6 years ago
uv = (v - 1.0) * 2.0;

does the trick. Thanks for your suggestion!

grafik