Shader preprocessor

Started by Thomas., October 29, 2012, 12:13:14 PM

Previous topic - Next topic

Thomas.

Please, is there anyone who knows a library that works with this?

#if USE_FOG
...shader code...
#endif

Thomas.

By GLSL ES specification it is supported. Could you implement it into jPCT-AE, please?

http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf

EgonOlsen

#2
I'm not sure what you mean!? I don't care about what the compiler does or does not, i'm just feeding the source code directly into the driver. What am i supposed to implement?

Thomas.

Preprocessor on page 11 :) It should be integrated in GPU, if I understood it correctly... I have to somehow send variables together with shader...

EgonOlsen

Quote from: Thomas. on November 03, 2012, 09:52:24 PM
... I have to somehow send variables together with shader...
I don't think so. You can define something in the source code and then ask somewhere else if it has been defined and stuff like that. Like in C/C++...correct me, if i'm wrong.

Thomas.

Yes, you are right, I got it wrong...

Thomas.

And please, have you idea, how it should be used? Now, I have in VS code for fog, even if is not needed in FS (FS is dynamically generated). I want leave out calculation of fog, if is not needed. So I did this....


...
        #ifdef USE_FOG
varying vec3 fogVertexColor;
varying float fogWeight;
#endif
...
#ifdef USE_FOG
fogWeight = clamp((-v_Position.z - fogStart) / (fogEnd - fogStart), 0.0, 1.0);
fogVertexColor = fogColor * fogWeight;
#endif


And if I need fog, I add "#define USE_FOG" on the first line of VS and FS, but it not works when I turn on fog.
11-06 15:40:34.768: I/jPCT-AE(11566): [ 1352212834770 ] - ERROR: Could not link shader program: L0008 Varying 'fogWeight' not found in vertex shader

EgonOlsen

No idea...looks fine to me, but then again, i don't trust my own understanding of these preprocessor commands nor the shader compilers on mobile devices. I would try to use two #define like USE_FOG and USE_FOG2 and then use the first on in the first #ifdef and the second one in the second. Just to see what happens then...

Thomas.

I have it. I was sending old VS without #define ... line to the GPU ::)