Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Blasphemer

Pages: [1]
1
Graphics / Determining world position of the current fragment in a shader
« on: January 22, 2015, 12:59:12 pm »
I am trying to make a lighting fragment shader. For that, I need to know the world position of the fragment in order to determine its distance to the light source (in world units). Should I do it by setting up a varying world coordinates variable in a vertex shader? If so, can SFML provide the model matrix needed to compute the vertex world position like this?:

vec2 world_coords = gl_Vertex * gl_ModelMatrix

Or should I compute the vertex world positions in SFML - getting the entity transform, applying it to local vertex coords then passing the results to the vertex shader?

Is this even the correct way to make a per-pixel lighting shader with SFML that would not change output with view/screen transformations?

Pages: [1]