Search in sources :

Example 1 with LightProperties

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;
        }
    }
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) DirectionalLightsAttribute(com.badlogic.gdx.graphics.g3d.attributes.DirectionalLightsAttribute) DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) LightProperties(com.badlogic.gdx.tests.g3d.shadows.system.BaseShadowSystem.LightProperties) Camera(com.badlogic.gdx.graphics.Camera)

Example 2 with LightProperties

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;
        }
    }
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) LightProperties(com.badlogic.gdx.tests.g3d.shadows.system.BaseShadowSystem.LightProperties) SpotLightsAttribute(com.badlogic.gdx.graphics.g3d.attributes.SpotLightsAttribute) Camera(com.badlogic.gdx.graphics.Camera) SpotLight(com.badlogic.gdx.graphics.g3d.environment.SpotLight)

Aggregations

Camera (com.badlogic.gdx.graphics.Camera)2 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)2 LightProperties (com.badlogic.gdx.tests.g3d.shadows.system.BaseShadowSystem.LightProperties)2 DirectionalLightsAttribute (com.badlogic.gdx.graphics.g3d.attributes.DirectionalLightsAttribute)1 SpotLightsAttribute (com.badlogic.gdx.graphics.g3d.attributes.SpotLightsAttribute)1 DirectionalLight (com.badlogic.gdx.graphics.g3d.environment.DirectionalLight)1 SpotLight (com.badlogic.gdx.graphics.g3d.environment.SpotLight)1