Triangle

01-29-2013, 10:07 AM

During a gbuffer stage I save in textures a depth, normals, diffuse and specular colors, shininnes factors but also

normals from a normal maps (tangent space) and tangent vectors (I can calculate binormal vectors using normals from a normal maps and tangent vectors ).

Only some objects are shaded using normal maps. For objects which don't use normal maps I save in texture vec3(0,0,0) as a normal from a normal map.

Then in a framgent shader I do something like this :

if(a normal vector from a normal map is equal vec3(0,0,0))

{

fragColor = standard_shading_function( some parameters );

}

else

{

fragColor = nm_shading_function( some parameters );

}

'If' statement in a shader program can be expensive but I don't have any other ideas how to solve above problem.

Do you know any better solution ?

normals from a normal maps (tangent space) and tangent vectors (I can calculate binormal vectors using normals from a normal maps and tangent vectors ).

Only some objects are shaded using normal maps. For objects which don't use normal maps I save in texture vec3(0,0,0) as a normal from a normal map.

Then in a framgent shader I do something like this :

if(a normal vector from a normal map is equal vec3(0,0,0))

{

fragColor = standard_shading_function( some parameters );

}

else

{

fragColor = nm_shading_function( some parameters );

}

'If' statement in a shader program can be expensive but I don't have any other ideas how to solve above problem.

Do you know any better solution ?