mirror of https://github.com/bjornbytes/lovr.git
rm lovrEnvironmentTexture from Material;
This commit is contained in:
parent
e4ab5aa85a
commit
96c47d590c
|
@ -143,7 +143,6 @@ const char* MaterialTextures[] = {
|
|||
[TEXTURE_ROUGHNESS] = "roughness",
|
||||
[TEXTURE_OCCLUSION] = "occlusion",
|
||||
[TEXTURE_NORMAL] = "normal",
|
||||
[TEXTURE_ENVIRONMENT_MAP] = "environment",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
|
@ -75,7 +75,6 @@ typedef enum {
|
|||
TEXTURE_ROUGHNESS,
|
||||
TEXTURE_OCCLUSION,
|
||||
TEXTURE_NORMAL,
|
||||
TEXTURE_ENVIRONMENT_MAP,
|
||||
MAX_MATERIAL_TEXTURES
|
||||
} MaterialTexture;
|
||||
|
||||
|
|
|
@ -63,8 +63,7 @@ typedef struct {
|
|||
Mesh* mesh;
|
||||
Pipeline* pipeline;
|
||||
Material* material;
|
||||
Texture* diffuseTexture;
|
||||
Texture* environmentMap;
|
||||
Texture* texture;
|
||||
mat4 transform;
|
||||
uint32_t vertexCount;
|
||||
uint32_t indexCount;
|
||||
|
@ -548,13 +547,16 @@ static void lovrGraphicsBatch(BatchRequest* req) {
|
|||
Pipeline* pipeline = req->pipeline ? req->pipeline : &state.pipeline;
|
||||
Material* material = req->material ? req->material : (state.defaultMaterial ? state.defaultMaterial : (state.defaultMaterial = lovrMaterialCreate()));
|
||||
|
||||
if (!req->material) {
|
||||
lovrMaterialSetTexture(material, TEXTURE_DIFFUSE, req->diffuseTexture);
|
||||
lovrMaterialSetTexture(material, TEXTURE_ENVIRONMENT_MAP, req->environmentMap);
|
||||
if (req->texture) {
|
||||
if (req->type == BATCH_SKYBOX && lovrTextureGetType(req->texture) == TEXTURE_CUBE) {
|
||||
lovrShaderSetTextures(shader, "lovrSkyboxTexture", &req->texture, 0, 1);
|
||||
} else {
|
||||
lovrMaterialSetTexture(material, TEXTURE_DIFFUSE, req->texture);
|
||||
}
|
||||
}
|
||||
|
||||
if (lovrShaderHasUniform(shader, "lovrPose")) {
|
||||
if (req->type == BATCH_MESH && req->params.mesh.pose) {
|
||||
if (req->type == BATCH_MESH && lovrShaderHasUniform(shader, "lovrPose")) {
|
||||
if (req->params.mesh.pose) {
|
||||
lovrShaderSetMatrices(shader, "lovrPose", req->params.mesh.pose, 0, MAX_BONES * 16);
|
||||
} else {
|
||||
lovrShaderSetMatrices(shader, "lovrPose", (float[]) MAT4_IDENTITY, 0, 16);
|
||||
|
@ -1175,8 +1177,7 @@ void lovrGraphicsSkybox(Texture* texture) {
|
|||
.topology = DRAW_TRIANGLE_STRIP,
|
||||
.shader = type == TEXTURE_CUBE ? SHADER_CUBE : SHADER_PANO,
|
||||
.pipeline = &pipeline,
|
||||
.diffuseTexture = type == TEXTURE_2D ? texture : NULL,
|
||||
.environmentMap = type == TEXTURE_CUBE ? texture : NULL,
|
||||
.texture = texture,
|
||||
.vertexCount = 4,
|
||||
.vertices = &vertices,
|
||||
.instanced = true
|
||||
|
@ -1184,10 +1185,10 @@ void lovrGraphicsSkybox(Texture* texture) {
|
|||
|
||||
if (vertices) {
|
||||
static float vertexData[] = {
|
||||
-1, 1, 1, 0, 0, 0, 0, 0,
|
||||
-1, -1, 1, 0, 0, 0, 0, 0,
|
||||
1, 1, 1, 0, 0, 0, 0, 0,
|
||||
1, -1, 1, 0, 0, 0, 0, 0
|
||||
-1.f, 1.f, 1.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
||||
-1.f, -1.f, 1.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
||||
1.f, 1.f, 1.f, 0.f, 0.f, 0.f, 0.f, 0.f,
|
||||
1.f, -1.f, 1.f, 0.f, 0.f, 0.f, 0.f, 0.f
|
||||
};
|
||||
|
||||
memcpy(vertices, vertexData, sizeof(vertexData));
|
||||
|
@ -1218,7 +1219,7 @@ void lovrGraphicsPrint(const char* str, size_t length, mat4 transform, float wra
|
|||
.shader = SHADER_FONT,
|
||||
.pipeline = &pipeline,
|
||||
.transform = transform,
|
||||
.diffuseTexture = font->texture,
|
||||
.texture = font->texture,
|
||||
.vertexCount = glyphCount * 4,
|
||||
.indexCount = glyphCount * 6,
|
||||
.vertices = &vertices,
|
||||
|
@ -1241,7 +1242,7 @@ void lovrGraphicsFill(Texture* texture, float u, float v, float w, float h) {
|
|||
.params.fill = { .u = u, .v = v, .w = w, .h = h },
|
||||
.topology = DRAW_TRIANGLE_STRIP,
|
||||
.shader = SHADER_FILL,
|
||||
.diffuseTexture = texture,
|
||||
.texture = texture,
|
||||
.pipeline = &pipeline,
|
||||
.vertexCount = 4,
|
||||
.vertices = &vertices
|
||||
|
|
|
@ -77,7 +77,6 @@ const char* lovrShaderFragmentPrefix = ""
|
|||
"uniform sampler2D lovrRoughnessTexture; \n"
|
||||
"uniform sampler2D lovrOcclusionTexture; \n"
|
||||
"uniform sampler2D lovrNormalTexture; \n"
|
||||
"uniform samplerCube lovrEnvironmentTexture; \n"
|
||||
"uniform lowp int lovrViewportCount; \n"
|
||||
"#if defined MULTIVIEW \n"
|
||||
"#define lovrViewID gl_ViewID_OVR \n"
|
||||
|
@ -222,8 +221,9 @@ const char* lovrCubeVertexShader = ""
|
|||
|
||||
const char* lovrCubeFragmentShader = ""
|
||||
"in vec3 texturePosition[2]; \n"
|
||||
"uniform samplerCube lovrSkyboxTexture; \n"
|
||||
"vec4 color(vec4 graphicsColor, sampler2D image, vec2 uv) { \n"
|
||||
" return graphicsColor * texture(lovrEnvironmentTexture, texturePosition[lovrViewID] * vec3(-1, 1, 1)); \n"
|
||||
" return graphicsColor * texture(lovrSkyboxTexture, texturePosition[lovrViewID] * vec3(-1, 1, 1)); \n"
|
||||
"}";
|
||||
|
||||
const char* lovrPanoFragmentShader = ""
|
||||
|
@ -271,8 +271,7 @@ const char* lovrShaderTextureUniforms[] = {
|
|||
"lovrMetalnessTexture",
|
||||
"lovrRoughnessTexture",
|
||||
"lovrOcclusionTexture",
|
||||
"lovrNormalTexture",
|
||||
"lovrEnvironmentTexture"
|
||||
"lovrNormalTexture"
|
||||
};
|
||||
|
||||
const char* lovrShaderAttributeNames[] = {
|
||||
|
|
Loading…
Reference in New Issue