Raymarching Beginners' Thread
category: code [glöplog]
[ur]http://www.dasprinzip.com/prinzipiell/2011/06/15/fog-me-fog-you/[/url]
Once again I am happy to find some of my code without any kind of reference or credits! :)
FOG YOU TOO... What the hell possed him?
Once again I am happy to find some of my code without any kind of reference or credits! :)
FOG YOU TOO... What the hell possed him?
http://www.dasprinzip.com/prinzipiell/2011/06/15/fog-me-fog-you/
There I fixed it.
There I fixed it.
Fog him indeed. Btw, being pirated is a sign of success, it should make you happy at the same time as making you mad :D
@las: Indeed! I recognised that shape of yours...
Now.. could it be that Frank Reitberger is a lurker, or did he really came up with the same algorithm applied on the same shape with a very similar color scheme?
"the logical next step for me was to implement some noise for my WebGL stuff and add it to my raymarchers. However, my evil plan was to use this noise for generating smoke-like behaviours and what should I say - I think it worked pretty good…"
Thats kind of messed up for Frank if he is a poser...
"the logical next step for me was to implement some noise for my WebGL stuff and add it to my raymarchers. However, my evil plan was to use this noise for generating smoke-like behaviours and what should I say - I think it worked pretty good…"
Thats kind of messed up for Frank if he is a poser...
las, i have find shaders of mine and formulas for plane deformations copied (up to the constants, spacing and semicolons) all over the internet, from blogs to "experiments" and even tools/software, without mention not to their source. Not that I mind, but at least, if you are just copying, at least do not publish/blog a tutorial as if it was your big discovery. Do not be surprised if for every new tutorial/demo a demoscener publishes, there is one replica in Chrome Experiments under a different author name (and perhaps with a web-code-color schema), or a js version of it. That's how it is. Yay the internets!!!
I'm just wondering las, because he actually credited you and this thread in his article:
..so why bitching?
or is it a recent modification from his blog entry?
anyway, yes, when you post information on the net, it can be copied by anyone. even by people that you don't like, or know. if you don't want to be copied, then the best is maybe to not share information/sources in the first place. :)
but from ripping entirely something that you did and using a different name and bitching around that someone used your noise function, there are limits too...
On my side i've always considered that being copied is a sign of success. I'd find it personally very flattering to be copied. :)
Quote:
(by strictly implementing Las´s sources & instructions from the ‘Raymarching Beginners‘ Thread which I recommended you reading a dozen times the last blogposts).
..so why bitching?
or is it a recent modification from his blog entry?
anyway, yes, when you post information on the net, it can be copied by anyone. even by people that you don't like, or know. if you don't want to be copied, then the best is maybe to not share information/sources in the first place. :)
but from ripping entirely something that you did and using a different name and bitching around that someone used your noise function, there are limits too...
On my side i've always considered that being copied is a sign of success. I'd find it personally very flattering to be copied. :)
flattering, i think i'm doing frenglish here, i mean gratifying of course. :}
ey guys,
already wearing sackcloth and ashes for not saying it right out in my post @dasprinzip. it shouldn´t sound like inventing 'fog' - but as always rely on that great thread like my posts before...
especially @las: Edited in the credits & clarifications - missing anything, just say...
already wearing sackcloth and ashes for not saying it right out in my post @dasprinzip. it shouldn´t sound like inventing 'fog' - but as always rely on that great thread like my posts before...
especially @las: Edited in the credits & clarifications - missing anything, just say...
@las You can contact me at mewler7 at gmail dot com :)
Quote:
I'm just wondering las, because he actually credited you and this thread in his article.. so why bitching?
That's due to the bitching ;)
Everything is fine now - now he even has a pouet account to participate here! :D
pwd: Thank you.
Yep, not crediting the code like this = bitching. Getting an account here and joining in = everyone wins :)
Dunno if it's entirely relevant here, but it answers my question before about where to read up on shader scheduling and such (particularly on powervr SGX chips, which aren't all that commonly used with raymarching ;)
Imagination released the SGX architecture guide, which explains in a bit more detail how their chippery works. Very useful if you're working on this hardware! http://www.imgtec.com/powervr/insider/powervr-sdk-docs.asp
Is there some "fairly generalised" documentation like this somewhere that would apply to modern ati + nvidia cards? It would be well worth reading.
Imagination released the SGX architecture guide, which explains in a bit more detail how their chippery works. Very useful if you're working on this hardware! http://www.imgtec.com/powervr/insider/powervr-sdk-docs.asp
Is there some "fairly generalised" documentation like this somewhere that would apply to modern ati + nvidia cards? It would be well worth reading.
I'd love to see the day when powervr chips will be powerful enough for raymarching. :) Maybe i don't even have so long to wait even, who knows?
psonice, i've learned quite a lot about nvidia architecture in the cuda documents..
pwd, welcome! :)
psonice, i've learned quite a lot about nvidia architecture in the cuda documents..
pwd, welcome! :)
nystep - how about now?
Nvidia used to do a gpu programming guide, but now it's mostly focused on compute.
Nvidia used to do a gpu programming guide, but now it's mostly focused on compute.
hornet: that GPU guide looks promising, thanks!
Anyone tried raymarching on that shader toy app? Is performance anywhere near acceptable?
Anyone tried raymarching on that shader toy app? Is performance anywhere near acceptable?
I have no idea honnestly. But honnestly, if anyone would want to send me an ipad2 for free, i'd try ;)
psonice: One of the examples are a raymarcher, so yes. It's slow as fuck on my Samsung Galaxy SII at least ;)
nystep: i'll be running some of my stuff on it at some point, no time lately (writing an ipad2 app, so any time spent on the ipad tends to be working time :( )
kusma: sounds about right. It's amazing how far you can squeeze stuff down for these mobile GPUs though, so I reckon it's still worth a try.
kusma: sounds about right. It's amazing how far you can squeeze stuff down for these mobile GPUs though, so I reckon it's still worth a try.
You guys should have a look at FXAA3
http://timothylottes.blogspot.com/
That one might be pretty useful to get rid of raymarching artifacts.
Hmm for the current test scene there's for some reason only a slight difference between just bilinear sampling and FXAA3 - maybe I am doing it wrong (anyways - both look far better than doing nothing).
http://timothylottes.blogspot.com/
That one might be pretty useful to get rid of raymarching artifacts.
Hmm for the current test scene there's for some reason only a slight difference between just bilinear sampling and FXAA3 - maybe I am doing it wrong (anyways - both look far better than doing nothing).
Hmm.. looks interesting. No time to read it thoroughly just now unfortunately, work to do :(
But, quickly skimming the source did get me thinking a bit. I think something I wrote during the last week could be used for a similar effect with a small tweak, and it should be plenty fast enough. I'll try it out tomorrow.
But, quickly skimming the source did get me thinking a bit. I think something I wrote during the last week could be used for a similar effect with a small tweak, and it should be plenty fast enough. I'll try it out tomorrow.
Talking about reflections I came across this idea: http://forum.beyond3d.com/showthread.php?t=56095
Has anyone here tried something similar?
Has anyone here tried something similar?
WOW! Thanks las. That FXAA thing works great. Really easy to set up and well documented. Took me like 20 mins. Also, heres a bonus: FXAA nicely compressed up and ready to plug in for GL raymarchers, just add rgbl ;)
Code:
"vec4 FxaaPixelShader("
"vec2 pos,"
"vec4 posPos,"
"sampler2D tex,"
"vec2 rcpFrame,"
"vec4 rcpFrameOpt "
") { "
"float lumaN = textureLodOffset(tex, pos.xy, 0.0, ivec2(0, -1)).w;"
"float lumaW = textureLodOffset(tex, pos.xy, 0.0, ivec2(-1, 0)).w;"
"vec4 rgbyM = textureLod(tex, pos.xy, 0.0);"
"float lumaE = textureLodOffset(tex, pos.xy, 0.0, ivec2( 1, 0)).w;"
"float lumaS = textureLodOffset(tex, pos.xy, 0.0, ivec2( 0, 1)).w;"
"float lumaM = rgbyM.w;"
"float rangeMin = min(lumaM, min(min(lumaN, lumaW), min(lumaS, lumaE)));"
"float rangeMax = max(lumaM, max(max(lumaN, lumaW), max(lumaS, lumaE)));"
"float range = rangeMax - rangeMin;"
"if(range < max((1.0/12.0), rangeMax * (1.0/6.0)))"
//#if (FXAA_DISCARD == 1)
// discard;
//#else
"return rgbyM;"
// #endif
"float lumaNW = textureLodOffset(tex, pos.xy, 0.0, ivec2(-1,-1)).w;"
"float lumaNE = textureLodOffset(tex, pos.xy, 0.0, ivec2( 1,-1)).w;"
"float lumaSW = textureLodOffset(tex, pos.xy, 0.0, ivec2(-1, 1)).w;"
"float lumaSE = textureLodOffset(tex, pos.xy, 0.0, ivec2( 1, 1)).w;"
"float lumaL = (lumaN + lumaW + lumaE + lumaS) * 0.25;"
"float rangeL = abs(lumaL - lumaM);"
"float blendL = clamp((rangeL / range) - (1.0/4.0), 0.0, 1.0) * (1.0/(1.0 - (1.0/4.0))); "
"blendL = min((3.0/4.0), blendL);"
"float edgeVert = "
"abs(lumaNW + (-2.0 * lumaN) + lumaNE) +"
"2.0 * abs(lumaW + (-2.0 * lumaM) + lumaE ) +"
"abs(lumaSW + (-2.0 * lumaS) + lumaSE);"
"float edgeHorz = "
"abs(lumaNW + (-2.0 * lumaW) + lumaSW) +"
"2.0 * abs(lumaN + (-2.0 * lumaM) + lumaS ) +"
"abs(lumaNE + (-2.0 * lumaE) + lumaSE);"
"bool horzSpan = edgeHorz >= edgeVert;"
"float lengthSign = horzSpan ? -rcpFrame.y : -rcpFrame.x;"
"if(!horzSpan) lumaN = lumaW;"
"if(!horzSpan) lumaS = lumaE;"
"float gradientN = abs(lumaN - lumaM);"
"float gradientS = abs(lumaS - lumaM);"
"lumaN = (lumaN + lumaM) * 0.5;"
"lumaS = (lumaS + lumaM) * 0.5;"
"bool pairN = gradientN >= gradientS;"
"if(!pairN) lumaN = lumaS;"
"if(!pairN) gradientN = gradientS;"
"if(!pairN) lengthSign *= -1.0;"
"vec2 posN;"
"posN.x = pos.x + (horzSpan ? 0.0 : lengthSign * 0.5);"
"posN.y = pos.y + (horzSpan ? lengthSign * 0.5 : 0.0);"
"gradientN *= (1.0/4.0);"
"vec2 posP = posN;"
"vec2 offNP = horzSpan ? "
"vec2(rcpFrame.x, 0.0) :"
"vec2(0.0f, rcpFrame.y);"
"float lumaEndN;"
"float lumaEndP;"
"bool doneN = false;"
"bool doneP = false;"
"posN += offNP * (-1.5);"
"posP += offNP * ( 1.5);"
"for(int i = 0; i < 6; i++) {"
"lumaEndN = textureLod(tex, posN.xy, 0.0).w;"
"lumaEndP = textureLod(tex, posP.xy, 0.0).w;"
"bool doneN2 = abs(lumaEndN - lumaN) >= gradientN;"
"bool doneP2 = abs(lumaEndP - lumaN) >= gradientN;"
"if(doneN2 && !doneN) posN += offNP;"
"if(doneP2 && !doneP) posP -= offNP;"
"if(doneN2 && doneP2) break;"
"doneN = doneN2;"
"doneP = doneP2;"
"if(!doneN) posN -= offNP * 2.0;"
"if(!doneP) posP += offNP * 2.0; }"
"float dstN = horzSpan ? pos.x - posN.x : pos.y - posN.y;"
"float dstP = horzSpan ? posP.x - pos.x : posP.y - pos.y;"
"bool directionN = dstN < dstP;"
"lumaEndN = directionN ? lumaEndN : lumaEndP;"
"if(((lumaM - lumaN) < 0.0) == ((lumaEndN - lumaN) < 0.0))"
"lengthSign = 0.0;"
"float spanLength = (dstP + dstN);"
"dstN = directionN ? dstN : dstP;"
"float subPixelOffset = 0.5 + (dstN * (-1.0/spanLength));"
"subPixelOffset += blendL * (1.0/8.0);"
"subPixelOffset *= lengthSign;"
"vec3 rgbF = textureLod(tex, vec2("
"pos.x + (horzSpan ? 0.0 : subPixelOffset),"
"pos.y + (horzSpan ? subPixelOffset : 0.0)), 0.0).xyz;"
// #if (FXAA_LINEAR == 1)
// lumaL *= lumaL;
//#endif
"float lumaF = dot(rgbF, vec3(0.299, 0.587, 0.114)) + (1.0/(65536.0*256.0));"
"float lumaB = mix(lumaF, lumaL, blendL);"
"float scale = min(4.0, lumaB/lumaF);"
"rgbF *= scale;"
"return vec4(rgbF, lumaM); "
"}"
Also, would Smash's stencil + flip trick be useful for FXAA as well?
xernobyl: As said in the forum: Probably really good for water-like stuff.