|
|
Line 1,557: |
Line 1,557: |
| </syntaxhighlight> | | </syntaxhighlight> |
|
| |
|
|
| |
| === General comments from forum discussion ===
| |
| {{FGCquote
| |
| |In real-time 3d rendering in general. To be very fast, all tasks are parallelized, so the GPU can crunch every vertex and every pixel independent of what the others do. The price for that to work is that you track only the ray from light (L) to object (O) to eye(E), so if that's the relevant geometry, you don't need to know anything else of the scene, you can get all the reflection angles at the object in one go.
| |
| To place a shadow, you want to know whether the ray L-O intersects somewhere else before it illuminates, i.e. evaluate L-O-O-E - and that's no longer factorizable - now at one vertex, you need to know all the others. I.e. a GPU can't evaluate this (raytracing still can easily, but that doesn't run in real time...) - which is where we need various tricks.
| |
| Which range from very cheap (fake shadows) to very expensive (additional shadow camera or shadow volume creation and stencil buffer passes over the whole scene).
| |
| |{{cite web |url=http://forum.flightgear.org/viewtopic.php?f=47&t=24859&start=45#p232315
| |
| |title=<nowiki>Re: 2D shadow on ground?</nowiki>
| |
| |author=<nowiki>Thorsten</nowiki>
| |
| |date=<nowiki>Tue Feb 17</nowiki>
| |
| }}
| |
| }}
| |
|
| |
| {{FGCquote
| |
| |Not an issue - shadow alpha is set by the fragment shader anyway based on time of the day and cloud cover (if there's lots of clouds, you get very faint shadows).
| |
| I think the issue is simple - multiple layers are visible where only one should be, so I need to do a first pass over just the shadow to fill the depth buffer and then draw the uppermost layer of the shadow in the second pass.
| |
| If the shadow volume really is a low poly version of the model, that should be really cheap (on the other hand, if it's a full multi-million poly replica, then... let's say you will notice...). Anyway, I didn't touch fragment work at all yesterday, I just wanted to sort out the geometry.
| |
| |{{cite web |url=http://forum.flightgear.org/viewtopic.php?f=47&t=24859&start=75#p234088
| |
| |title=<nowiki>Re: 2D shadow on ground?</nowiki>
| |
| |author=<nowiki>Thorsten</nowiki>
| |
| |date=<nowiki>Thu Mar 05</nowiki>
| |
| }}
| |
| }}
| |
|
| |
| {{FGCquote
| |
| |It's not a shadow, it's a squished volume flat on the ground. Don't fall into the trap of thinking of it as a shadow while developing.
| |
|
| |
| Don't need it. Volume and texture shadow are only different at the vertex stage only - to determine the pixel color, we can follow precisely the same steps.
| |
| |{{cite web |url=http://forum.flightgear.org/viewtopic.php?f=47&t=24859&start=75#p234132
| |
| |title=<nowiki>Re: 2D shadow on ground?</nowiki>
| |
| |author=<nowiki>Thorsten</nowiki>
| |
| |date=<nowiki>Thu Mar 05</nowiki>
| |
| }}
| |
| }}
| |
|
| |
| {{FGCquote
| |
| |You have to make it.
| |
| It is the same thing as the 3d model of the aircraft except it is (hopefully) low poly. Meaning it has only what is needed to make a 3 dimensional shadow that looks like the original model without all the details (no interior, etc).
| |
| This is something that really should have been considered back at the beginning of the FG project. Modelers should have by default make LOD versions of their aircraft for various reasons.
| |
| You can't use the effect without it.
| |
| |{{cite web |url=http://forum.flightgear.org/viewtopic.php?f=47&t=24859&start=90#p234163
| |
| |title=<nowiki>Re: 2D shadow on ground?</nowiki>
| |
| |author=<nowiki>wlbragg</nowiki>
| |
| |date=<nowiki>Thu Mar 05</nowiki>
| |
| }}
| |
| }}
| |
|
| |
| {{FGCquote
| |
| |"I guess the effect cannot handle moving gear or tilting nacelles?"
| |
|
| |
| I suspect right now no - animations seem to all go into the gl_ModelViewMatrix and currently the projection generating the shadow is applied before the matrix is multiplied. In principle, it's just a question of sorting the math out to do the projection in eye space, i.e. after applying gl_ModeViewMatrix - then the shadow reflects the state of the model after all animation have been carried out - and then do the projection transformation to screen space separately. I suspect it's ugly though, since the up-direction along which we determine where the ground is needs to be rotated as well, then we may have to do the roll/pitch transformations which make the shadow flat by hand,...
| |
|
| |
| I have a suspicion it's more trouble than it's worth - it's the sort of thing you'll only notice if you go looking for it.
| |
|
| |
|
| |
| "IIRC in OpenGL it's not that necessary to create low poly LODs for your 3D model, someone correct me if I'm wrong here, but I recall this being mentioned more than once."
| |
|
| |
| I think the definition of 'low poly' depends on your hardware. My current graphics card will happily crunch six million scenery vertices at a decent framerate, so it won't even notice whether you add a model with 1000 or 10.000 polygons. However, I assure you that you will feel the effect of adding a 3 million polygon shadow model to the scene.
| |
|
| |
| So you shouldn't waste a lot of time in desperately driving polygon count down, but you should strip down the shadow model from the original where this is feasible, especially if the original has excessive polygon count.
| |
|
| |
| It actually requires a depth buffer fill followed by a depth equality test, that renders one layer only.
| |
| |{{cite web |url=http://forum.flightgear.org/viewtopic.php?f=47&t=24859&start=90#p234209
| |
| |title=<nowiki>Re: 2D shadow on ground?</nowiki>
| |
| |author=<nowiki>Thorsten</nowiki>
| |
| |date=<nowiki>Thu Mar 06</nowiki>
| |
| }}
| |
| }}
| |
|
| |
| {{FGCquote
| |
| |Let me re-iterate that the shader does not use the transparency you set for the material - the rasterizer and z-buffer however may, leading to unexpected and difficult to track behavior. For the texture shadow, you should use texture alpha only to draw the outline of the shadow, and for the shadow volume you should for the moment not use material or texture alpha at all (at a later stage, I can add support for texture alpha). The shader should determine the correct alpha of the shadow output pixel on its own.
| |
| |{{cite web |url=http://forum.flightgear.org/viewtopic.php?f=47&t=24859&start=120#p234459
| |
| |title=<nowiki>Re: 2D shadow on ground?</nowiki>
| |
| |author=<nowiki>Thorsten</nowiki>
| |
| |date=<nowiki>Thu Mar 08</nowiki>
| |
| }}
| |
| }}
| |
|
| |
|
| == Related content == | | == Related content == |