use of com.badlogic.gdx.tests.g3d.shadows.system.BaseShadowSystem.LightProperties in project libgdx by libgdx.
the class MainShader method bindDirectionalShadows.
public void bindDirectionalShadows(final Attributes attributes) {
final DirectionalLightsAttribute dla = attributes.get(DirectionalLightsAttribute.class, DirectionalLightsAttribute.Type);
final Array<DirectionalLight> dirs = dla == null ? null : dla.lights;
if (dirLightsLoc >= 0) {
for (int i = 0; i < directionalLights.length; i++) {
if (dirs == null || dirs.size <= i) {
continue;
}
int idx = dirShadowsLoc + i * dirShadowsSize;
// Shadow
ObjectMap<DirectionalLight, LightProperties> dirCameras = shadowSystem.getDirectionalCameras();
DirectionalLight dl = dirs.get(i);
if (shadowSystem.hasLight(dl)) {
// UVTransform
final TextureRegion tr = dirCameras.get(dl).region;
Camera cam = dirCameras.get(dl).camera;
if (cam != null) {
program.setUniformf(idx + dirShadowsUvTransformOffset, tr.getU(), tr.getV(), tr.getU2() - tr.getU(), tr.getV2() - tr.getV());
// ProjViewTrans
idx = dirShadowMapProjViewTransLoc + i * dirShadowMapProjViewTransSize;
program.setUniformMatrix(idx, dirCameras.get(dl).camera.combined);
}
}
if (dirLightsSize <= 0)
break;
}
}
}
use of com.badlogic.gdx.tests.g3d.shadows.system.BaseShadowSystem.LightProperties in project libgdx by libgdx.
the class MainShader method bindSpotShadows.
public void bindSpotShadows(final Attributes attributes) {
final SpotLightsAttribute sla = attributes.get(SpotLightsAttribute.class, SpotLightsAttribute.Type);
final Array<SpotLight> spots = sla == null ? null : sla.lights;
if (spotLightsLoc >= 0) {
for (int i = 0; i < spotLights.length; i++) {
if (spots == null || spots.size <= i) {
continue;
}
int idx = spotShadowsLoc + i * spotShadowsSize;
// Shadow
ObjectMap<SpotLight, LightProperties> spotCameras = shadowSystem.getSpotCameras();
SpotLight sl = spots.get(i);
if (shadowSystem.hasLight(sl)) {
// UVTransform
final TextureRegion tr = spotCameras.get(sl).region;
Camera cam = spotCameras.get(sl).camera;
if (cam != null) {
program.setUniformf(idx + spotShadowsUvTransformOffset, tr.getU(), tr.getV(), tr.getU2() - tr.getU(), tr.getV2() - tr.getV());
// ProjViewTrans
idx = spotShadowMapProjViewTransLoc + i * spotShadowMapProjViewTransSize;
program.setUniformMatrix(idx, spotCameras.get(sl).camera.combined);
}
}
if (spotLightsSize <= 0)
break;
}
}
}
Aggregations