Hi Grigoriy,

why don't you do the multiply in the shader like you do with gl_vertex?

- Werner -

Am 16.11.2018 um 12:29 schrieb Grigoriy Mylnikov:
> Sorry for delayed reply.
>
> My goal is to open and display .osgt files on android the same way they can 
> be opened on desktop. This includes using several lights inside a model, both 
> directional and point lights.
>
> I have some progress with writing shaders, but I have troubles with 
> understanding OSG states. I've updated osg::Light apply() code to pass light 
> position (relative to camera) as uniform:
>
>
> Code:
> void LightShader::apply(osg::State& state) const
> {
> #ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE
> ... // Original code
> #else
>     ...
>     osg::Vec4 relPos = state.getModelViewMatrix() * _position;
>     lightPosUniform.get()->set(relPos);
>     ...
> #endif
> }
>
>
>
>
> But it seems that state.getModelViewMatrix() does not gives me valid view 
> matrix.
>
> If I could get light position (relative to camera), I can use it in shaders 
> like this:
>
>
> Code:
> vec3 APos = vec3(gl_ModelViewMatrix * gl_Vertex);
> ...
> vec3 fromPointToLight = lightPos.xyz - APos;
>
>
>
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75204#75204
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to