PDA

View Full Version : Is it a valid shader?



Soth
12-16-2007, 02:10 PM
#version 120

varying vec2 uvf;


uniform sampler2D s1;
struct y{
sampler2D s2;
} z;

void main()
{
z.s2=s1;
gl_FragColor = texture2D(z.s2,uvf);
}

This shader works on my 6600gt, but i wonder if it is valid to use a sampler as an l-value in assignment expression?

Groovounet
12-16-2007, 03:39 PM
I suppose it is, it makes possible to choose between two samplers in some case. At less, it's useful.

Trenki
12-16-2007, 04:10 PM
Id's say it is invalid. you can't have samples in a struct as samplers always have to be uniforms which can't be in a struct either.

I used the GLSLValidate tool to verify correctnes. It is a good idea to use that tool as nvidia cards are way to tollerand and als0 accept malformed programs. Without GLSLValidate it is practically impossible to develop a shader which will also work on ATI without having an ATI card to test on.

[ www.trenki.net (http://www.trenki.net) | vector_math (3d math library) (http://www.trenki.net/content/view/16/36/) | software renderer (http://www.trenki.net/content/view/18/38/) ]

Soth
12-16-2007, 04:15 PM
They say that GLSLValidate does not reflect glsl 1.2 features.

Komat
12-17-2007, 02:26 AM
This shader works on my 6600gt, but i wonder if it is valid to use a sampler as an l-value in assignment expression?

The 1.20 version of GLSL specification explicitly states:


Samplers cannot be treated as l-values; hence cannot be used as
out or inout function parameters, nor can they be assigned into.





They say that GLSLValidate does not reflect glsl 1.2 features.
That is true. GLSLValidate is 1.10 only.