Java 类com.badlogic.gdx.graphics.g3d.attributes.CubemapAttribute 实例源码

项目:Mundus    文件:SkyboxShader.java   
@Override
public void render(Renderable renderable) {

    // texture uniform
    CubemapAttribute cubemapAttribute = ((CubemapAttribute) (renderable.material
            .get(CubemapAttribute.EnvironmentMap)));
    if (cubemapAttribute != null) {
        set(UNIFORM_TEXTURE, cubemapAttribute.textureDescription);
    }

    // Fog
    Fog fog = ((MundusEnvironment) renderable.environment).getFog();
    if (fog == null) {
        set(UNIFORM_FOG, 0);
    } else {
        set(UNIFORM_FOG, 1);
        set(UNIFORM_FOG_COLOR, fog.color);
    }

    renderable.meshPart.render(program);
}
项目:ChessGDX    文件:PerspectiveRenderer.java   
/**
 * Configures the lighting and attributes for the environments   *
 */
private void configureEnvironments() {
    mEnvironment.set(new CubemapAttribute(CubemapAttribute.EnvironmentMap, AssetHandler.getInstance().getCubeMap()),
            new ColorAttribute(ColorAttribute.AmbientLight, 0.5f, 0.5f, 0.5f, 0.5f));

    mEnvironment.add((mShadowLight = new DirectionalShadowLight(4096, 4096, 60f, 60f, .1f, 50f)).set(0.5f, 0.5f, 0.5f,
            mLightDirection.x, mLightDirection.y, mLightDirection.z));
    mEnvironment.shadowMap = mShadowLight;

    mBackgroundEnvironment.set(new ColorAttribute(ColorAttribute.AmbientLight, 1.0f, 1.0f, 1.0f, 1f));
}
项目:Mundus    文件:Skybox.java   
private Model createModel() {
    ModelBuilder modelBuilder = new ModelBuilder();
    Model model = modelBuilder.createBox(1, 1, 1,
            new Material(new CubemapAttribute(CubemapAttribute.EnvironmentMap, cubemap)),
            VertexAttributes.Usage.Position);
    return model;
}
项目:libgdxcn    文件:DefaultShader.java   
@Override
public void set (BaseShader shader, int inputID, Renderable renderable, Attributes combinedAttributes) {
    if (combinedAttributes.has(CubemapAttribute.EnvironmentMap)) {
        shader.set(inputID, shader.context.textureBinder.bind(((CubemapAttribute)combinedAttributes
            .get(CubemapAttribute.EnvironmentMap)).textureDescription));
    }
}
项目:libgdxcn    文件:DefaultShader.java   
public DefaultShader (final Renderable renderable, final Config config, final ShaderProgram shaderProgram) {
    this.config = config;
    this.program = shaderProgram;
    this.lighting = renderable.environment != null;
    this.environmentCubemap = renderable.material.has(CubemapAttribute.EnvironmentMap)
        || (lighting && renderable.environment.has(CubemapAttribute.EnvironmentMap));
    this.shadowMap = lighting && renderable.environment.shadowMap != null;
    this.fog = lighting && renderable.environment.has(ColorAttribute.Fog);
    this.renderable = renderable;
    materialMask = renderable.material.getMask() | optionalAttributes;
    vertexMask = renderable.mesh.getVertexAttributes().getMask();

    this.directionalLights = new DirectionalLight[lighting && config.numDirectionalLights > 0 ? config.numDirectionalLights : 0];
    for (int i = 0; i < directionalLights.length; i++)
        directionalLights[i] = new DirectionalLight();
    this.pointLights = new PointLight[lighting && config.numPointLights > 0 ? config.numPointLights : 0];
    for (int i = 0; i < pointLights.length; i++)
        pointLights[i] = new PointLight();

    if (!config.ignoreUnimplemented && (implementedFlags & materialMask) != materialMask)
        throw new GdxRuntimeException("Some attributes not implemented yet (" + materialMask + ")");

    // Global uniforms
    u_projTrans = register(Inputs.projTrans, Setters.projTrans);
    u_viewTrans = register(Inputs.viewTrans, Setters.viewTrans);
    u_projViewTrans = register(Inputs.projViewTrans, Setters.projViewTrans);
    u_cameraPosition = register(Inputs.cameraPosition, Setters.cameraPosition);
    u_cameraDirection = register(Inputs.cameraDirection, Setters.cameraDirection);
    u_cameraUp = register(Inputs.cameraUp, Setters.cameraUp);
    u_time = register(new Uniform("u_time"));
    // Object uniforms
    u_worldTrans = register(Inputs.worldTrans, Setters.worldTrans);
    u_viewWorldTrans = register(Inputs.viewWorldTrans, Setters.viewWorldTrans);
    u_projViewWorldTrans = register(Inputs.projViewWorldTrans, Setters.projViewWorldTrans);
    u_normalMatrix = register(Inputs.normalMatrix, Setters.normalMatrix);
    u_bones = (renderable.bones != null && config.numBones > 0) ? register(Inputs.bones, new Setters.Bones(config.numBones))
        : -1;

    u_shininess = register(Inputs.shininess, Setters.shininess);
    u_opacity = register(Inputs.opacity);
    u_diffuseColor = register(Inputs.diffuseColor, Setters.diffuseColor);
    u_diffuseTexture = register(Inputs.diffuseTexture, Setters.diffuseTexture);
    u_diffuseUVTransform = register(Inputs.diffuseUVTransform, Setters.diffuseUVTransform);
    u_specularColor = register(Inputs.specularColor, Setters.specularColor);
    u_specularTexture = register(Inputs.specularTexture, Setters.specularTexture);
    u_specularUVTransform = register(Inputs.specularUVTransform, Setters.specularUVTransform);
    u_emissiveColor = register(Inputs.emissiveColor, Setters.emissiveColor);
    u_emissiveTexture = register(Inputs.emissiveTexture, Setters.emissiveTexture);
    u_emissiveUVTransform = register(Inputs.emissiveUVTransform, Setters.emissiveUVTransform);
    u_reflectionColor = register(Inputs.reflectionColor, Setters.reflectionColor);
    u_reflectionTexture = register(Inputs.reflectionTexture, Setters.reflectionTexture);
    u_reflectionUVTransform = register(Inputs.reflectionUVTransform, Setters.reflectionUVTransform);
    u_normalTexture = register(Inputs.normalTexture, Setters.normalTexture);
    u_normalUVTransform = register(Inputs.normalUVTransform, Setters.normalUVTransform);
    u_ambientTexture = register(Inputs.ambientTexture, Setters.ambientTexture);
    u_ambientUVTransform = register(Inputs.ambientUVTransform, Setters.ambientUVTransform);
    u_alphaTest = register(Inputs.alphaTest);

    u_ambientCubemap = lighting ? register(Inputs.ambientCube, new Setters.ACubemap(config.numDirectionalLights,
        config.numPointLights)) : -1;
    u_environmentCubemap = environmentCubemap ? register(Inputs.environmentCubemap, Setters.environmentCubemap) : -1;
}
项目:libgdxcn    文件:DefaultShader.java   
public static String createPrefix (final Renderable renderable, final Config config) {
    String prefix = "";
    final long mask = renderable.material.getMask();
    final long attributes = renderable.mesh.getVertexAttributes().getMask();
    if (and(attributes, Usage.Position)) prefix += "#define positionFlag\n";
    if (or(attributes, Usage.Color | Usage.ColorPacked)) prefix += "#define colorFlag\n";
    if (and(attributes, Usage.BiNormal)) prefix += "#define binormalFlag\n";
    if (and(attributes, Usage.Tangent)) prefix += "#define tangentFlag\n";
    if (and(attributes, Usage.Normal)) prefix += "#define normalFlag\n";
    if (and(attributes, Usage.Normal) || and(attributes, Usage.Tangent | Usage.BiNormal)) {
        if (renderable.environment != null) {
            prefix += "#define lightingFlag\n";
            prefix += "#define ambientCubemapFlag\n";
            prefix += "#define numDirectionalLights " + config.numDirectionalLights + "\n";
            prefix += "#define numPointLights " + config.numPointLights + "\n";
            if (renderable.environment.has(ColorAttribute.Fog)) {
                prefix += "#define fogFlag\n";
            }
            if (renderable.environment.shadowMap != null) prefix += "#define shadowMapFlag\n";
            if (renderable.material.has(CubemapAttribute.EnvironmentMap)
                || renderable.environment.has(CubemapAttribute.EnvironmentMap)) prefix += "#define environmentCubemapFlag\n";
        }
    }
    final int n = renderable.mesh.getVertexAttributes().size();
    for (int i = 0; i < n; i++) {
        final VertexAttribute attr = renderable.mesh.getVertexAttributes().get(i);
        if (attr.usage == Usage.BoneWeight)
            prefix += "#define boneWeight" + attr.unit + "Flag\n";
        else if (attr.usage == Usage.TextureCoordinates) prefix += "#define texCoord" + attr.unit + "Flag\n";
    }
    if ((mask & BlendingAttribute.Type) == BlendingAttribute.Type) prefix += "#define " + BlendingAttribute.Alias + "Flag\n";
    if ((mask & TextureAttribute.Diffuse) == TextureAttribute.Diffuse) {
        prefix += "#define " + TextureAttribute.DiffuseAlias + "Flag\n";
        prefix += "#define " + TextureAttribute.DiffuseAlias + "Coord texCoord0\n"; // FIXME implement UV mapping
    }
    if ((mask & TextureAttribute.Specular) == TextureAttribute.Specular) {
        prefix += "#define " + TextureAttribute.SpecularAlias + "Flag\n";
        prefix += "#define " + TextureAttribute.SpecularAlias + "Coord texCoord0\n"; // FIXME implement UV mapping
    }
    if ((mask & TextureAttribute.Normal) == TextureAttribute.Normal) {
        prefix += "#define " + TextureAttribute.NormalAlias + "Flag\n";
        prefix += "#define " + TextureAttribute.NormalAlias + "Coord texCoord0\n"; // FIXME implement UV mapping
    }
    if ((mask & TextureAttribute.Emissive) == TextureAttribute.Emissive) {
        prefix += "#define " + TextureAttribute.EmissiveAlias + "Flag\n";
        prefix += "#define " + TextureAttribute.EmissiveAlias + "Coord texCoord0\n"; // FIXME implement UV mapping
    }
    if ((mask & TextureAttribute.Reflection) == TextureAttribute.Reflection) {
        prefix += "#define " + TextureAttribute.ReflectionAlias + "Flag\n";
        prefix += "#define " + TextureAttribute.ReflectionAlias + "Coord texCoord0\n"; // FIXME implement UV mapping
    }
    if ((mask & TextureAttribute.Ambient) == TextureAttribute.Ambient) {
        prefix += "#define " + TextureAttribute.AmbientAlias + "Flag\n";
        prefix += "#define " + TextureAttribute.AmbientAlias + "Coord texCoord0\n"; // FIXME implement UV mapping
    }
    if ((mask & ColorAttribute.Diffuse) == ColorAttribute.Diffuse)
        prefix += "#define " + ColorAttribute.DiffuseAlias + "Flag\n";
    if ((mask & ColorAttribute.Specular) == ColorAttribute.Specular)
        prefix += "#define " + ColorAttribute.SpecularAlias + "Flag\n";
    if ((mask & ColorAttribute.Emissive) == ColorAttribute.Emissive)
        prefix += "#define " + ColorAttribute.EmissiveAlias + "Flag\n";
    if ((mask & ColorAttribute.Reflection) == ColorAttribute.Reflection)
        prefix += "#define " + ColorAttribute.ReflectionAlias + "Flag\n";
    if ((mask & FloatAttribute.Shininess) == FloatAttribute.Shininess)
        prefix += "#define " + FloatAttribute.ShininessAlias + "Flag\n";
    if ((mask & FloatAttribute.AlphaTest) == FloatAttribute.AlphaTest)
        prefix += "#define " + FloatAttribute.AlphaTestAlias + "Flag\n";
    if (renderable.bones != null && config.numBones > 0) prefix += "#define numBones " + config.numBones + "\n";
    return prefix;
}