X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fgraphics%2Fshaders%2Fgltf-physically-based-shader.vert;h=095e8392eb0b5e925b7cc7ed57944252f9ab7e18;hp=662886518fb97a284df7992e4512321d94511c01;hb=16561908a5e0e9bbef2aa11c9cdc3a27aeb1bd54;hpb=67c2962f7cb1a545a6ad10b8147c8558cc6f45ca diff --git a/dali-toolkit/internal/graphics/shaders/gltf-physically-based-shader.vert b/dali-toolkit/internal/graphics/shaders/gltf-physically-based-shader.vert index 6628865..095e839 100644 --- a/dali-toolkit/internal/graphics/shaders/gltf-physically-based-shader.vert +++ b/dali-toolkit/internal/graphics/shaders/gltf-physically-based-shader.vert @@ -9,51 +9,34 @@ uniform mediump vec3 uSize; uniform mediump mat4 uModelMatrix; uniform mediump mat4 uViewMatrix; uniform mediump mat4 uProjection; -uniform lowp int uLightType; uniform mediump vec3 uLightVector; -uniform lowp int uIsColor; +uniform lowp float uIsPointLight; +uniform lowp float uHasVertexColor; out lowp vec2 vUV[2]; out lowp mat3 vTBN; out lowp vec4 vColor; -flat out int visLight; out highp vec3 vLightDirection; out highp vec3 vPositionToCamera; void main() { highp vec4 invY = vec4(1.0, -1.0, 1.0, 1.0); - highp vec4 positionW = uModelMatrix * vec4( aPosition * uSize, 1.0 ); - highp vec4 positionV = uViewMatrix * ( invY * positionW ); + highp vec4 positionW = uModelMatrix * vec4(aPosition * uSize, 1.0); + highp vec4 positionV = uViewMatrix * (invY * positionW); - vPositionToCamera = transpose( mat3( uViewMatrix ) ) * ( -vec3( positionV.xyz / positionV.w ) ); + vPositionToCamera = transpose(mat3(uViewMatrix)) * (-vec3(positionV.xyz / positionV.w)); vPositionToCamera *= invY.xyz; lowp vec3 bitangent = cross(aNormal, aTangent.xyz) * aTangent.w; - vTBN = mat3( uModelMatrix ) * mat3(aTangent.xyz, bitangent, aNormal); + vTBN = mat3(uModelMatrix) * mat3(aTangent.xyz, bitangent, aNormal); vUV[0] = aTexCoord0; vUV[1] = aTexCoord1; - visLight = 1; - if( uLightType == 1 ) - { - vLightDirection = ( invY.xyz * uLightVector ) - ( positionW.xyz / positionW.w ); - } - else if( uLightType == 2 ) - { - vLightDirection = -( invY.xyz * uLightVector ); - } - else - { - visLight = 0; - } - - vColor = vec4( 1.0 ); - if( uIsColor == 1 ) - { - vColor = aVertexColor; - } + vLightDirection = mix(-(invY.xyz * uLightVector), (invY.xyz * uLightVector) - (positionW.xyz / positionW.w), uIsPointLight); + + vColor = mix(vec4(1.0f), aVertexColor, uHasVertexColor); gl_Position = uProjection * positionV; // needs w for proper perspective correction gl_Position = gl_Position/gl_Position.w;