Simon.Anderson Posted January 12, 2015 Posted January 12, 2015 Hi There, I see the the fragment color variable defined as 's_frag_color' in so many unigine shader scripts that come with the sdk but I can't find where the heck it is defined?! There is this line of code in fragment_base.h: #define gl_FragColor s_frag_color But this is obviously for an open gl shader ( GLSL ). I'm after a definition for the the High Level Shader Language (HLSL) shaders. Can anyone help me out? Is there something I'm missing here? Cheers, Simon
unclebob Posted January 12, 2015 Posted January 12, 2015 Hi! HLSL doesn't have analogue for gl_FragColor. Instead, it just simply returns data from its main.
Simon.Anderson Posted January 13, 2015 Author Posted January 13, 2015 Is there any other way to identify a .shader file as either GLSL or HLSL in unigine? The following vertex shader I found that we use with unigine, - is it GLSL or HLSL? it uses float4 (HLSL) but then sets gl_Position (GLSL)?! #include <core/shaders/default/common/vertex_base.h> /******************************************************************************\ ** OpenGL/OpenGLES*\******************************************************************************/ #ifdef OPENGL || OPENGLES in float4 s_attribute_0; in half4 s_attribute_1; in half4 s_attribute_2; out vec3 normalisedFragmentLoc; void main() { float4 row_0,row_1,row_2; row_0 = s_transform[0]; row_1 = s_transform[1]; row_2 = s_transform[2]; float4 position = float4(s_attribute_0.x,s_attribute_0.y,s_attribute_2.w,1.0f); float4 vertex = float4(dot(row_0,position),dot(row_1,position),dot(row_2,position),1.0f); gl_Position = getPosition(vertex); normalisedFragmentLoc = s_attribute_1.xyz; } #elif DIRECT3D10 || DIRECT3D11
unclebob Posted January 13, 2015 Posted January 13, 2015 The thing is that both GLSL and HLSL implementations are contained inside one .shader file. We're using our own preprocessor to select which shader we need to compie (by passing proper define constants).
Recommended Posts