Can someone explain in plain English how shaders work?

Post Reply
gold
One Eyed Hopeful
Posts: 10
Joined: Wed Feb 05, 2020 10:10 pm

Can someone explain in plain English how shaders work?

Post by gold »

This is so confusing. And I consider myself a PC expert.

I just (had to) download 3DMigoto because the remaster of the game I'm trying to run (Ghostbusters The Video Game Remastered) hasn't been added to Helixmod yet and doesn't work in Nvidia 3D out of the box. It does with 3Dmigoto so I had to install that.

So running 3Dmigoto (and setting hunting to 0) the game works nicely in 3d. Ghosting is irrtating depending on the distance from the camera an object is. You can set convergence perfectly for one distance but when you get closer or further away the ghosting becomes apparent. Oh well, I guess that cannot be helped.

My question is with the shaders. I completely don't understand it.

If you enable hunting=1 you can change a whole bunch of shaders using NUMPAD1,2,4,5,7,8 NUMPADdivide and NUMPADmultiply.

This flashes various textures and geometry on and off in the game as it cycles.

My question is WHY would you do this? Why make tables and chairs invisible in the game? I don't understand.

What is the best way of just getting the game to run in 3D as it was made,..... i.e. without making tables and chairs invisible?
3DNovice
Petrif-Eyed
Posts: 2398
Joined: Thu Mar 29, 2012 4:49 pm

Re: Can someone explain in plain English how shaders work?

Post by 3DNovice »

gold wrote: Thu Jun 04, 2020 4:18 pmMy question is WHY would you do this? Why make tables and chairs invisible in the game? I don't understand.
.

Most games do not run correctly, if at all using 3D Vision.

To overcome this, modding tools were made to make corrections for a game to get the best stereoscopic experience possible.

Helixmod works on dx9 games.

3DMigoto works on dx11 games.

To understand the basics and to answer your own questions, watch the 4 part youtube series from the shaderhacker school. It is based off of dx9/helixmod, the principles are similar for 3Dmigoto.

https://www.youtube.com/watch?v=wBEGq0fhlHY
3DNovice
Petrif-Eyed
Posts: 2398
Joined: Thu Mar 29, 2012 4:49 pm

Re: Can someone explain in plain English how shaders work?

Post by 3DNovice »

3DNovice
Petrif-Eyed
Posts: 2398
Joined: Thu Mar 29, 2012 4:49 pm

Re: Can someone explain in plain English how shaders work?

Post by 3DNovice »

gold wrote: Thu Jun 04, 2020 4:18 pm Can someone explain in plain English how shaders work?
https://en.wikipedia.org/wiki/Shader

https://www.youtube.com/watch?v=TDZMSozKZ20
User avatar
schwing
Cross Eyed!
Posts: 171
Joined: Mon Sep 16, 2019 5:51 am

Re: Can someone explain in plain English how shaders work?

Post by schwing »

    Fixing effects boils down to understanding two things: 3Dmigoto's d3dx.ini features and how shaders are modified to disable or fix effects. The hunting you're doing makes effects or objects disappear, for which pressing the marking button saves that shader to the ShaderFixes folder inside the game's folder. So you'd see what shader is responsible for drawing the invisible object, open that new ShaderFixes shader file, and see the shader's code. There are hotkeys to cycle through different shader types, and you will mainly stick with vertex and pixel shaders starting out. For recent games, if the broken effect you're seeing isn't disappearing, then also cycle through compute shaders. The marking_mode defaults to skip, which is why effects disappear when shader hunting. Press the Numpad+ button to cancel hunting and unhide the effect/object. You'll typically find yourself marking both the vertex and pixel shader responsible so you can mess around with each's code in different ways and see what happens to the effect/object.

    You can go to b03b's school to get a basic idea of either disabling an effect or going through the effort of fixing it. That school deals with the old dx9 helixmod tool and its assembly (asm) shaders. 3DMigoto fixing is usually with HLSL shaders which have easier-to-read code. ASM shaders are low-level code and HLSL shaders look like C++. The process you'll go through to disable or fix an effect is basically the same but with different syntax (e.g. for HLSL you type o0 = 0; before the ending } ending curly brace to disable an effect).

    Alternatively, you can download existing fixes--looking at each's "fixed effects" section like shadows or HUD--and see what fixes typically look like. This will help clear up what I mean regarding ASM or HLSL as you'll see that shaders' code look either alien or more-readable at a glance. You'll know it's HLSL if the code lines end in semicolons. Good fixes leave enough comments in the shader code or 3Dmigoto's d3dx.ini file to understand what fix is being done and less likely why. One quick way to find fixes for certain effects is to use GrepWin by right-clicking the fix's ShaderFixes folder, choosing GrepWin, and typing something like shadow or hud. Since there isn't a comprehensive guide to learning shaderfixing, you'll have to invest time in learning like the others did. I certainly have not done enough of that to feel like an expert, myself.

    For fixing shaders' code (understanding the above "nonsense"), having prior general or graphics programming experience is recommended, or otherwise patience for editing shader code and learning how shaders work through trial-and-error and doing some online research. Shaders are small programs where each type of shader is part of the graphics rendering pipeline (just focus on the top half of this pipeline image for now). You can try 3DNovice's shader wiki link above, search for information on directx at a site like docs.microsoft.com (e.g. Vertex Shaders), or you can try an online class website like Udemy (likely deep-discounted) if you really want to become an expert in directx graphics.

    Types of shaders when talking about the player character: vertex shaders decide where each point of the player's model goes. You can imagine subtracting a fixed amount from the vertex shader's output and seeing the player move left. All of the vertices (points) in the model are fed through the vertex shader first. The vertex shader's output is what happens to each vertex. Pixel shaders take that output (resulting model) and decide where a texture goes on the resulting model. You can imagine the texture shifting left if you subtract from the correct output in the pixel shader. Like the player's t-shirt logo moving left from where it usually is. The pixel shader's output is what color each pixel on the screen will be. Vertex shaders are responsible for the game world position of geometry/models, screen position of HUD elements, etc. Pixel shaders are responsible for effects like shadows, lighting, lens flares, etc. Compute shaders are a general calculation type of shader or they do pixel shader-related calculations like lighting, but you may end up not even seeing these for older games.

    As you learn about fixing shaders and hunting, you'll notice that 3DMigoto has other features. Understanding the tool is trial-and-error and patience, but might help you in possibly not having to touch shaders depending on what you're trying to do (e.g. skipping a shader [disabling effects] or using ShaderRegex to replace code for all matching shaders [fixing effects]). There are other aspects of graphics like textures (e.g. a gun texture), render targets (i.e. usually represents the screen being drawn to that is shown as the final image), etc. that 3DMigoto has features to deal with. Go back and forth with the 3DMigoto wiki to understand what each feature is meant to do and how it will help you. Combining your understanding with d3dx.ini features with understanding shaders and directx will start painting the big picture of why 3DMIgoto's features exist and how to make shader changes that look more and more like helixmod blog fixes.

    Lastly, there's understanding stereo itself. The Nvidia 3D Vision whitepaper has a slide called Stereo shift on clip position that says what the canonical stereo formula is (bo3b's "prime directive" formula). The stereo driver uses this formula to automatically stereoize things. So you could mark a v or pshader for a working stereo effect, apply this same formula at the end (likely to the o0 output [specifically o0.x]), and likely see the same result the driver got. The whitepaper is a good place to learn stereo concepts such as separation, convergence, how they work in a 3D space, etc.

    Unfortunately, information about undocumented 3DMigoto features and countless helpful posts from shaderfixers are buried in the new Nvidia forum we left a while ago. The best way to learn is if someone creates a comprehensive wiki or an interactive learning tool detailing and walking through everything. With 3D Vision discontinued, I doubt it will happen. Admittedly, the information that is available isn't satisfactory to get started without some growing pains, but it's what we've had up to now.

    Either way, I hope this information helps you. It's a lengthy, yet necessary overview to help you help yourself if you're willing to put in the effort to make the sort of fixes that end up on the helixmod blog. Feel free to search for or ask questions in this forum or on the 3DV Discord if you get stuck on something.
Win 10 v1909 / 1x Nvidia 980Ti GPU (v452.22, 1080p)
User avatar
maurizioclaudio21
Cross Eyed!
Posts: 167
Joined: Mon Sep 16, 2019 10:01 am

Re: Can someone explain in plain English how shaders work?

Post by maurizioclaudio21 »

gold wrote: Thu Jun 04, 2020 4:18 pm This is so confusing. And I consider myself a PC expert.

I just (had to) download 3DMigoto because the remaster of the game I'm trying to run (Ghostbusters The Video Game Remastered) hasn't been added to Helixmod yet and doesn't work in Nvidia 3D out of the box. It does with 3Dmigoto so I had to install that.

So running 3Dmigoto (and setting hunting to 0) the game works nicely in 3d. Ghosting is irrtating depending on the distance from the camera an object is. You can set convergence perfectly for one distance but when you get closer or further away the ghosting becomes apparent. Oh well, I guess that cannot be helped.



il gioco necessita di varie convergenze
per giocare al meglio
che puoi settare con vari tasti
ti ho mandato un messaggio privato

the game needs several convergences
to play better
that you can set with various keys
I sent you a private message
Post Reply

Return to “Nvidia 3D Vision Fixes, Solutions and Troubleshooting”