Hello, I have a fixed function subshader working with two passes how I want just fine and am trying to do a one pass shader using an ATI fragment program. (I'm on a 9200 and can't play with the Cg (Gonna borrow someone's laptop this weekend a bit for that 8) ) ) Anyways, I can't get this new and improved subshader to be called! It will only use the second fixed function one. What am I doing incorrectly? Code (csharp): Shader "Graveck/StereoCombiner" { Properties { _TexL ("Left Eye Render Texture", RECT) = "white" {} _TexR ("Right Eye Render Texture", RECT) = "white" {} _LColor ("Left Eye Component Modifier", Color) = (1,0,0,0) _RColor ("Right Eye Component Modifier", Color) = (0,1,1,0) } SubShader { Pass { Program "" { SubProgram { Local 0, [_LColor] Local 1, [_RColor] "!!ATIfs1.0 StartConstants; CONSTANT c0 = program.local[0]; CONSTANT c1 = program.local[1]; EndConstants; StartOutputPass; SampleMap r0, t0.stq_dq; SampleMap r1, t1.stq_dq; MUL r0, r0, c0 MAD r0, r1, c1, r0 EndPass; " } } SetTexture [_TexL] { combine texture } SetTexture [_TexR] { combine texture } } } SubShader { cull off Lighting off ZTest Always ZWrite Off Blend One One Pass { SetTexture [_TexL] { constantColor [_LColor] combine constant * texture } } Pass { SetTexture [_TexR] { constantColor [_RColor] combine constant * texture } } } } Thank you! -Jon p.s. Peter, you wanted ShaderLab questions? Here's your ShaderLab questions! edit: updated output pass
For starters I think my output pass may be incorrect. I had: Code (csharp): StartOutputPass; SampleMap r1, t0.stq_dq; SampleMap r2, t1.stq_dq; MUL r0, r1, c0 MAD r0, r2, c1, r0 EndPass; But should have: Code (csharp): StartOutputPass; SampleMap r0, t0.stq_dq; SampleMap r1, t1.stq_dq; MUL r0, r0, c0 MAD r0, r1, c1, r0 EndPass; I think it should be like that because the destination of SampleMap determines which texture unit to sample from. Am I on the correct path? -Jon
Hi Aarku, and thanks for the question... Yep, its correct that the destination of SampleMap should be the same af the register which the texture is bound to. What do you see on the screen, the result from the fixed function pass ? I would put in a vertex program too, so you make sure that you get the correct texture coordinates into those two registers you sample from. Have you tried to output a fixed color only in the fragment program, just to make sure that everything else is ok ? When you see the fixed color you can try to put your other code back... One thing though, from where I sit it seems like the MUL and MAD lines in the program is missing semi colon at the end, might want to fix that first, if it is not only a misprint in the post ;-) - Peter
It was a dratted semi colon problem. That fixed it. I was confirming that the fixed function one was getting called by commenting out the Blend line (makes it nice and blue/green) Thanks! -Jon