I wanted to try some shader effect, and even if I understood something by tinkering with already working shaders, I still don't get how to do some pretty basic stuff:
Since I managed to color moving relative portions of the screen at my pleasure, I was trying to draw a more "detailed" thing like a grid.
And here I noticed how much I miss having a print function to see what happens there:
My idea was that I could basically draw a black pixel when its x or y coordinate was even, but it seems that my condition is never triggered, and I guess that the issue is that fTexCoord.x and .y are relative values that go from 0 to 1, not "real" pixel coordinates.. but at the same time I think that I should have got at least a weird output instead of the source image..
Any suggestions?
Effect.grid=makeEffect("grid",
function (vVertex,vColor,vTexCoord) : Shader
local vertex = hF4(vVertex,0.0,1.0)
fTexCoord=vTexCoord
return vMatrix*vertex
end,
function () : Shader
local frag=lF4(fColor)*texture2D(fTexture, fTexCoord)
if fTexCoord.x%2.0 ==0 or fTexCoord.y%2.0 == 0 then --when x/2 is even
frag.rgb=lF3(0.0,0.0,0.0) --this changes the pixel color
else
frag.rgb=lF3(frag.r,frag.g,frag.b) --this leaves the original pixel color
end
if (frag.a==0.0) then discard() end --discard transparent pixels
return frag
end) |
thank you!
Comments
on the other hand you can use e.g. https://www.shadertoy.com/ to prototype much faster perhaps than in gideros/lua and when you are happy with the result then you can translate your code to gideros glsl or lua shader (although there will be hassles with texture coordinates etc. at least for me it also takes time and trial and error to translate a shadertoy code so that it works as i expect).
Fragmenter - animated loop machine and IKONOMIKON - the memory game
https://computergraphics.stackexchange.com/questions/96/how-can-i-debug-glsl-shaders
Likes: pie
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: pie