Jump to content

[SOLVED] s_frag_color


photo

Recommended Posts

Posted

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

 

 

Posted

Hi!

 

HLSL doesn't have analogue for gl_FragColor. Instead, it just simply returns data from its main.

Posted

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

Posted

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).

×
×
  • Create New...