graphics – How to decide sprite size for isometric tile textures?

enter image description here

I want to draw isometric tiles with arbitrary tile sizes. For example above picture there are 1×1 and 3×2 sized tiles.

The textures have arbitrary height because of decoration. a is the tile’s height b is texture’s height c is tile’s width.
I can’t figure out what the sprite size should be when I lay these out on screen.

Maybe I should have exact tile sizes cover the whole texture without decorations (a == b). But still what the sprite size should be?

performance – Is it a bad idea to store all textures in linear color-space?

I am wondering about the performance behind color-space conversions for textures during reading.

If a project decides to go with a linear workflow, as in, when doing any sort of color manipulation, like lighting, they operate on within the linear color-space, is there any good reason to not store all texture assets in the linear color-space?

My understanding is that when loading textures which are stored in sRGB, the GPU can do the conversion to linear for you very quickly. Is that cost completely negligible? Why not just store all the textures in that form?

The only reason I can think against this is that you may want to store the textures in a color-space that looks like the one you intend to display to (if you’re going to display to sRGB then you should store the textures in sRGB). In that case, why not master the texture as sRGB but then store them on disk already converted to linear colorspace?

textures – Crash when creating RenderTargetViews for Cubemap

I want to create a cubemap and I want to render to it and later sample from it for reflections.
However, It crashes when I try to create the faces for the cubemap.
Here is my code:

RenderTargetCube::RenderTargetCube(ID3D11Device* device, int resolution, DXGI_FORMAT format) {

    D3D11_TEXTURE2D_DESC desc = {};
    desc.Width = resolution;
    desc.Height = resolution;
    desc.MipLevels = 1;
    desc.ArraySize = 6;
    desc.Format = format;
    desc.SampleDesc.Count = 1;
    desc.SampleDesc.Quality = 0;
    desc.Usage = D3D11_USAGE_DEFAULT;
    desc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
    desc.CPUAccessFlags = 0;
    desc.MiscFlags = D3D11_RESOURCE_MISC_TEXTURECUBE;

    HRESULT res = device->CreateTexture2D(&desc, NULL, &Texture);
    throwIfFailed(res);

    D3D11_RENDER_TARGET_VIEW_DESC viewDesc = {};
    viewDesc.Format = desc.Format;
    viewDesc.Texture2DArray.ArraySize = 6;
    viewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
    for (int i = 0; i < 6; i++) {
        viewDesc.Texture2DArray.FirstArraySlice = D3D11CalcSubresource(0, i, 1);
        res = device->CreateRenderTargetView(Texture.Get(), &viewDesc, RenderTargetView(i).GetAddressOf()); // crash here
        throwIfFailed(res);

    }

and here is the message I receive:

D3D11 ERROR: ID3D11Device::CreateRenderTargetView: The Dimensions of the View are invalid due to at least one of the following conditions. MipSlice (value = 0) must be between 0 and MipLevels-1 of the Texture Resource, 0, inclusively. FirstArraySlice (value = 1) must be between 0 and ArraySize-1 of the Texture Resource, 5, inclusively. With the current FirstArraySlice, ArraySize (value = 6) must be between 1 and 5, inclusively, or -1 to default to all slices from FirstArraySlice, in order that the View fit on the Texture. ( STATE_CREATION ERROR #137: CREATERENDERTARGETVIEW_INVALIDDIMENSIONS)

I dont quite understand the error message, especially the last part about ArraySize, why does it want it to be between 1 and 5 and not 0 to 5?

opengl – (While using a cube map) box-like textures appearing around my scene whenever I move the camera

I’ve been learning about cube map and I implemented one into my program. It seemed to work well until I started moving the camera around the scene and zooming out. As you can see in the attached gif, there seems to be a problem with the cube map since this weird behavior is occurring:

https://gyazo.com/70ad4ce027d1e032bc19258e28def66f

Main program:

        unsigned int cubemapTexture = texo.loadCubeMap(faces);

        glDepthFunc(GL_EQUAL);
        bg.bind();
        skyBox.use();

        glm::mat4 projection = glm::perspective(glm::radians(fov), (float)scr_width / (float)scr_height, 0.1f, 100.0f);
        glm::mat4 view = camera.GetViewMatrix();
        skyBox.setUniformMat4("projection", projection);
        skyBox.setUniformMat4("view", view);

        glActiveTexture(GL_TEXTURE20);
        glBindTexture(GL_TEXTURE_CUBE_MAP, cubemapTexture);
        GLCall(glDrawArrays(GL_TRIANGLES, 0, 36));

loadCubeMap:

unsigned int Textures::loadCubeMap(std::vector<std::string> faces)
{
    unsigned int textureID;
    glGenTextures(1, &textureID);
    glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);

    stbi_set_flip_vertically_on_load(false);

    int width, height, nrChannels;
    for (unsigned int i = 0; i < faces.size(); i++)
    {
        unsigned char* data = stbi_load(faces(i).c_str(), &width, &height, &nrChannels, 0);
        if (data)
        {
            glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
                0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data
            );

            stbi_image_free(data);
        }
        else
        {
            std::cout << "Cubemap tex failed to load at path: " << faces(i) << std::endl;
            stbi_image_free(data);
        }
    }

    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);


    return textureID;
}

Vertex Shader:

#version 330 core

layout (location = 0) in vec3 aPos;

out vec3 TexCoords; 

uniform mat4 view;
uniform mat4 projection;

void main()
{
    vec4 pos = projection * view * vec4(aPos, 1.0);
    TexCoords = aPos;
    //Setting z value to w (1.0) so that the cube map is always in the background
    gl_Position = pos.xyww;
}  

Fragment shader:

#version 330 core

out vec4 FragColor;

in vec3 TexCoords;
uniform samplerCube skybox;

void main()
{
    FragColor = texture(skybox, TexCoords);
}

The problem probably originates from one of these snippets, but if you have any other ideas I can provide more info.

Get 25 great high-resolution textures for $ 5

Get 25 beautiful high resolution textures

Get 25 beautiful high resolution textures

You'll find everything from bricks to granite, marble, metal, rust, water and more! Find exactly what you're looking for in this gigantic collection of awesome textures

.

opengl – Green textures when adding 2 textures using GLUT

My cube is entirely green and uses only the texture bumpID (0) instead of texID (0) under bumpID (0).
This is my display function

void display() {
   t = clock();
   glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  // Clear color and depth buffers
   glMatrixMode(GL_PROJECTION);     // To operate on model-view matrix
   glMatrixMode(GL_MODELVIEW);
   // Render a color-cube consisting of 6 quads with different colors
   glLoadIdentity();                 // Reset the model-view matrix
   glEnable(GL_TEXTURE_2D); 
   //std::thread threadt(engTranslatef, 1.5f, 0, -6.0f, Cube);
   engTranslatef(1.5f, 0, -6.0f, Cube);
   glEnable(GL_TEXTURE_GEN_S); //enable texture coordinate generation
    glEnable(GL_TEXTURE_GEN_T);
    glEnable ( GL_COLOR_MATERIAL ) ;
    glActiveTexture(GL_TEXTURE0);  
    glBindTexture(GL_TEXTURE_2D, texID(0));
    glActiveTexture(GL_TEXTURE0 + 1);  
    glBindTexture(GL_TEXTURE_2D, bumpID(0));
    //threadt.join();
    glutSolidCube(2);
    glDisable(GL_TEXTURE_GEN_S); //enable texture coordinate generation
    glDisable(GL_TEXTURE_GEN_T);
    glActiveTexture(GL_TEXTURE0);  
    glBindTexture(GL_TEXTURE_2D, texID(-1));


   // Render a pyramid consists of 4 triangles
   glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE,  ambientGenericMaterial) ;
   glLoadIdentity();
   glTranslatef(-1.5f, sin(pyramidplace), -6.0f);  // Move left and into the screen

   glBegin(GL_TRIANGLES);           // Begin drawing the pyramid with 4 triangles
      // Front
      glColor3f(1.0f, 0.0f, 0.0f);     // Red
      glVertex3f( 0.0f, 1.0f, 0.0f);
      glColor3f(0.0f, 1.0f, 0.0f);     // Green
      glVertex3f(-1.0f, -1.0f, 1.0f);
      glColor3f(0.0f, 0.0f, 1.0f);     // Blue
      glVertex3f(1.0f, -1.0f, 1.0f);

      // Right
      glColor3f(1.0f, 0.0f, 0.0f);     // Red
      glVertex3f(0.0f, 1.0f, 0.0f);
      glColor3f(0.0f, 0.0f, 1.0f);     // Blue
      glVertex3f(1.0f, -1.0f, 1.0f);
      glColor3f(0.0f, 1.0f, 0.0f);     // Green
      glVertex3f(1.0f, -1.0f, -1.0f);

      // Back
      glColor3f(1.0f, 0.0f, 0.0f);     // Red
      glVertex3f(0.0f, 1.0f, 0.0f);
      glColor3f(0.0f, 1.0f, 0.0f);     // Green
      glVertex3f(1.0f, -1.0f, -1.0f);
      glColor3f(0.0f, 0.0f, 1.0f);     // Blue
      glVertex3f(-1.0f, -1.0f, -1.0f);

      // Left
      glColor3f(1.0f,0.0f,0.0f);       // Red
      glVertex3f( 0.0f, 1.0f, 0.0f);
      glColor3f(0.0f,0.0f,1.0f);       // Blue
      glVertex3f(-1.0f,-1.0f,-1.0f);
      glColor3f(0.0f,1.0f,0.0f);       // Green
      glVertex3f(-1.0f,-1.0f, 1.0f);
   glEnd();   // Done drawing the pyramid

   //std::thread threadp(PhysicsUpdate);
   glutSwapBuffers();  // Swap the front and back frame buffers (double buffering)
   float deltatime = clock() - t;
   printf("%f fpsn", (CLOCKS_PER_SEC / deltatime));
   //threadp.join ();
}
```

textures – How to choose what to use in Java: enumerations or objects?

I am in a dilemma regarding the use of enumeration types or the use of class objects in this particular part of my java project.

Suppose I have an array where I constantly add and remove things, but I also render the textures of this array by accessing the texture with an enum type of its class like:

public static Texture requestTexture(Type type){
    if(type == Type.One){
        return textureOne;
    }
}

// can be improved with hashmap

I wonder if I can use classes rather than enumerations? Will this slow down my performance as I will constantly create new objects and delete them as they leave the stack, but on the other hand it will be cleaner, more structured code?

Export of models from Crocotile3D to Unreal Engine 4 (.obj). The texts are still vague. I want crisp, clean textures

Can anyone help me? I'm exporting models with textures (.obj) from Crocotile3D to Unreal Engine 4. I want them to be crisp and clear, as in the image on the left (Crocotile editor), but don't become fuzzy, as in the image on the right (Unreal editor). Whether I export the model to the scale x 1 or more makes no difference. My textures measure 16×16 pixels.

I watched endless videos and tinkered with settings but got stuck for two days. Any help or advice will be highly appreciated!

Crocotile3D ,, Unreal Editor, Crocotile Eport Settings

textures – Java – adjust the game resolution

everyone I make small game using pure Java 8 and redirecting it with Java AWT Graphics2D method. My question is how to get this user to change the quality of the game. For example: 720p, 1080p, 1440p. Something similar happens when playing a YouTube video.

The steps I will take:

  • Take 3 photos of each, each with a different quality.
  • Then charge them.
    But Java is only 72 dpi by default, so each of them will be of the same quality. So how do you make it in a different resolution?

Thanks in advance,
Maratonec

java – How to fix "stretched" textures in LibGDX?

I draw textures using SpriteBatch and all the textures are stretched.

Stretched textures

Before, I used Stage and StretchViewport and at the time everything was fine.

Correctly drawn texture

My code:

//in GameScreen class (implements Screen)
OrthographicCamera camera;
SpriteBatch spriteBatch;

public GameScreen() {
  camera = new OrthographicCamera();
  camera.setToOrtho(false);
  spriteBatch = new SpriteBatch();
}

public void render(float dt) {
  Gdx.gl.glClearColor(0, 0, 0 , 0);
  Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  spriteBatch.setProjectionMatrix(camera.combined);

  //drawing
}

public void resize(int width, int height) {
  camera.viewportWidth = width;
  camera.viewportHeight = height;
}

How can I fix this? I tried this solution using the aspect ratio but it didn't work or I messed it up.