calculate lighting in world space
This commit is contained in:
parent
2c385914c6
commit
3889cb47b7
@ -126,14 +126,6 @@ public class StaticPassLightingLogic extends DefaultTechniqueDefLogic {
|
||||
return techniqueDef.getShader(assetManager, rendererCaps, defines);
|
||||
}
|
||||
|
||||
protected void transformDirection(Matrix4f viewMatrix, Vector3f direction) {
|
||||
viewMatrix.multNormal(direction, direction);
|
||||
}
|
||||
|
||||
protected void transformPosition(Matrix4f viewMatrix, Vector3f location) {
|
||||
viewMatrix.mult(location, location);
|
||||
}
|
||||
|
||||
protected float getShadowMapIndex(Light light) {
|
||||
return 1.0f;
|
||||
}
|
||||
@ -154,7 +146,6 @@ public class StaticPassLightingLogic extends DefaultTechniqueDefLogic {
|
||||
ColorRGBA color = light.getColor();
|
||||
float shadowMapIndex = getShadowMapIndex(light);
|
||||
tempDirection.set(light.getDirection());
|
||||
transformDirection(viewMatrix, tempDirection);
|
||||
lightData.setVector4InArray(color.r, color.g, color.b, shadowMapIndex, index++);
|
||||
lightData.setVector4InArray(tempDirection.x, tempDirection.y, tempDirection.z, 1f, index++);
|
||||
}
|
||||
@ -164,7 +155,6 @@ public class StaticPassLightingLogic extends DefaultTechniqueDefLogic {
|
||||
float shadowMapIndex = getShadowMapIndex(light);
|
||||
tempPosition.set(light.getPosition());
|
||||
float invRadius = light.getInvRadius();
|
||||
transformPosition(viewMatrix, tempPosition);
|
||||
lightData.setVector4InArray(color.r, color.g, color.b, shadowMapIndex, index++);
|
||||
lightData.setVector4InArray(tempPosition.x, tempPosition.y, tempPosition.z, invRadius, index++);
|
||||
}
|
||||
@ -175,8 +165,6 @@ public class StaticPassLightingLogic extends DefaultTechniqueDefLogic {
|
||||
|
||||
tempPosition.set(light.getPosition());
|
||||
tempDirection.set(light.getDirection());
|
||||
transformPosition(viewMatrix, tempPosition);
|
||||
transformDirection(viewMatrix, tempDirection);
|
||||
|
||||
float invRange = light.getInvSpotRange();
|
||||
float spotAngleCos = light.getPackedAngleCos();
|
||||
|
||||
@ -162,7 +162,7 @@ surface_t getSurface() {
|
||||
if (!gl_FrontFacing) {
|
||||
s.normal = -s.normal;
|
||||
}
|
||||
s.viewDir = normalize(-vPos);
|
||||
s.viewDir = normalize(g_CameraPosition - s.position);
|
||||
#ifdef AMBIENTMAP
|
||||
s.ambient = texture2D(m_AmbientMap, vTexCoord).rgb;
|
||||
#else
|
||||
|
||||
@ -22,8 +22,8 @@ void main() {
|
||||
Skinning_Compute(modelSpacePos, modelSpaceNorm);
|
||||
#endif
|
||||
|
||||
vPos = TransformWorldView(modelSpacePos).xyz;
|
||||
vNormal = TransformNormal(modelSpaceNorm);
|
||||
vPos = TransformWorld(modelSpacePos).xyz;
|
||||
vNormal = TransformWorldNormal(modelSpaceNorm);
|
||||
|
||||
vec3 shadowPos = TransformWorld(modelSpacePos).xyz;
|
||||
Shadow_ProcessProjCoord(shadowPos);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user