Difference between revisions of "Lesson 6 - prime directive"
Bo3b admin (Talk | contribs) |
Bo3b admin (Talk | contribs) |
||
Line 52: | Line 52: | ||
*# What is stereo projection, separation, convergence. | *# What is stereo projection, separation, convergence. | ||
*# Max separation. | *# Max separation. | ||
+ | |||
It's worth reading the rest of this paper for other good tidbits, like why convergence is locked under 'advanced.' | It's worth reading the rest of this paper for other good tidbits, like why convergence is locked under 'advanced.' | ||
Line 77: | Line 78: | ||
With that background, let's go back to the Lava, but fix it from the VertexShader this time. | With that background, let's go back to the Lava, but fix it from the VertexShader this time. | ||
− | In general, we can fix effects from either the VertexShader or the PixelShader, because the output of one is the input of the other. Given a choice, | + | In general, we can fix effects from either the VertexShader or the PixelShader, because the output of one is the input of the other. Given a choice, we'd rather fix location problems like skybox or HUD in the VertexShader. If we are going to disable an effect, it's better to use the PixelShader. And some complicated effects like shadows can generally only be fixed in PixelShaders. |
Line 84: | Line 85: | ||
*# Shader hunt for the VertexShader this time. Note the non-obvious shader makes it all dark. | *# Shader hunt for the VertexShader this time. Note the non-obvious shader makes it all dark. | ||
*# Exit out and move the found shader to ShaderOverride. | *# Exit out and move the found shader to ShaderOverride. | ||
− | *# Edit the shader | + | *# Edit the shader, and comment out the o3 to find the problem texture. |
+ | *# Edit the shader, and add our stereo correction to o3. | ||
Line 94: | Line 96: | ||
*# Play through to the giant worm at the end, it's not far. | *# Play through to the giant worm at the end, it's not far. | ||
*# See the water has double-imaging like the water in the hall earlier. | *# See the water has double-imaging like the water in the hall earlier. | ||
− | *# | + | *# Try to find a way to apply a stereo correction. Finding the right spot will be hard. |
− | + | ||
− | + | ||
*# Save a screenshot to your personal page. | *# Save a screenshot to your personal page. | ||
<br> | <br> |
Revision as of 02:19, 21 September 2014
Summary
Now it's time to talk about how stereo 3D is created, and the math behind it.
Level of difficulty: Easy
Time required: 30 minutes
Video Walkthrough on YouTube ...
Video Walkthrough direct download link
Objective
Review and understand the principles behind stereoscopy.
Learn about the prime directive formula, and how to apply it.
Quiz
Fix the water shader at the end of the game.
For effects that are important for game play, the best solution is of course to fix them, not disable them. We can fix a surprisingly large number of broken effects with different techniques that we will learn in future Lessons.
Let's start by fixing an easy one in The Ball, where there is already stereo fix code to guide us. This is the Lava effect. This will be our first actual fix, as opposed to disabling them.
As a general idea, we probably would not fix this effect, because the version with one layer disabled is perfectly acceptable. It's always worth keeping an eye on how much time a given effect is worth, because there are always more games.
We'll step back into The Ball for a minute to get a first glimpse of the 3D formula I'm calling the prime directive.
Let's not worry about the details yet, just see how it's applied.
- Fix Lava effect, not just disable it.
- Lava in The Ball is perfectly usable now, but we noticed the Unreal fix earlier.
- Unreal fix did not function, but we can make it work, using HelixMod inputs.
- Edit shader file to use HelixMod stereo texture, instead of game based one.
- Fixed in 3D, not just disabling a piece of it.
The best background for how 3D works is a presentation from NVidia for GTC2010.
http://www.nvidia.com/content/GTC-2010/pdfs/2010_GTC2010.pdf
- Let's take a quick look at how 3D Vision works, so that we can all use NVidia's terminology.
- Starts with the basics of two offset images.
- How to think about shader rendering, including coordinate space.
- What is stereo projection, separation, convergence.
- Max separation.
It's worth reading the rest of this paper for other good tidbits, like why convergence is locked under 'advanced.'
- Looking at the prime directive.
- Slide 49.
- Eyesign is automatically applied by driver.
The prime directive from that slide:
clipPos.x += EyeSign * Separation * ( clipPos.w – Convergence )
- How does this translate to code: Canonical_Stereo_Code
With that background, let's go back to the Lava, but fix it from the VertexShader this time.
In general, we can fix effects from either the VertexShader or the PixelShader, because the output of one is the input of the other. Given a choice, we'd rather fix location problems like skybox or HUD in the VertexShader. If we are going to disable an effect, it's better to use the PixelShader. And some complicated effects like shadows can generally only be fixed in PixelShaders.
- Fix Lava effect using the prime directive.
- Run TheBall, and load up a Lava level.
- Shader hunt for the VertexShader this time. Note the non-obvious shader makes it all dark.
- Exit out and move the found shader to ShaderOverride.
- Edit the shader, and comment out the o3 to find the problem texture.
- Edit the shader, and add our stereo correction to o3.
Quiz: Go to the end of the demo, and fix the broken water using the prime directive.
- Fix the water shader at the last level.
- Play through to the giant worm at the end, it's not far.
- See the water has double-imaging like the water in the hall earlier.
- Try to find a way to apply a stereo correction. Finding the right spot will be hard.
- Save a screenshot to your personal page.