Client Side Rendering

I have followed the guide (https://www.c5insight.com/Resources/Blog/tabid/148/entryid/653/how-you-make-sharepoint-announcements-grab-attention-easily-using-csr.aspx) to implement some client side rendering for an Announcement list on my site.

I have verified everything multiple times…but it still will only display the unmodified announcement list on my SP page. It isn’t rendering the list like it should.

The JSLink is ugly. Should the JSLink start with a [sourcecode] line?

Upgraded to Unity 2018.4.6f1, many cameras, some with deferred rendering, surfaces now render as white. Very baffling

We have a rather conventional set up to start with:

Main Camera (everything but UI layer, depth 0, deferred, has post-processing)     GUI Camera (only UI layer, depth-only clear, depth 1, forward) 

We also allow screen recording, so we have another pair of cameras, but with different depths:

Recording Main Camera (everything but UI layer, depth -1, deferred, has post-processing)     Recording GUI Camera (only UI layer, depth-only clear, depth -2, forward) 

Before the upgrade, everything worked great. After the upgrade:

enter image description here

We have fiddled a bunch, and results are very peculiar:

  • Turning HDR on with ANY camera will invert the white shading to black shading. enter image description here
  • Disabling any camera will return the game to its proper appearance (obviously not the main camera, since we need that to see anything!).
  • Disabling post-processing on both cameras that have it doesn’t change anything. In fact, post-processing doesn’t seem to be part of the problem at all.
  • Setting the main camera within each pair of cameras to Forward returns that view to normal.
  • Setting all cameras to deferred does not do anything.
  • Moving a pair of cameras, such as the recording camera, to another display returns the game to normal.
  • Setting the lowest-depth camera to deferred and the others as forward renders the game correctly. But putting any camera before the deferred camera causes everything to go white/black.
  • Rendering the recording camera to a render texture returns the game to normal.

It appears that deferred cameras are all sorts of janky now, especially in Unity 2019. Supposedly they have made a whole new ways to layer cameras for a future version of 2019. We wanted to upgrade to 2019.2, unfortunately, 2019 seems to have a slew of issues from rendering to DLL management, and we were unable to upgrade due those issues. 2019.2 wouldn’t have helped us in this issue anyway, because the new layer cameras functionality isn’t live yet.

We are using deferred because we have a lot of lighting effects, and deferred helps frame rate a lot in that regard. Giving up on deferred rendering is unlikely an option.

Magento 1.14 – admin _prepareCollection() and _prepareColumns() are not rendering or not calling

In Magento 1.14 – admin _prepareCollection() and _prepareColumns() are not rendering or not calling. Could anyone please help me out why these functions are not loading from grid.php. Below is my config.xml

<global> <models>         <tk_autoShip>             <class>Tk_AutoShip_Model</class>             <resourceModel>tk_autoShip_resource</resourceModel>         </tk_autoShip>          <!-- Resource model to create a database table -->         <tk_autoShip_resource>             <class>Tk_AutoShip_Model_Resource</class>             <entities>                 <autoshipgrid>                     <table>tk_autoship_tkautoship</table>                 </autoshipgrid>                                 </entities>         </tk_autoShip_resource>     </models>  <resources>      <tk_autoShip_setup>           <setup>               <module>Tk_AutoShip</module>           </setup>      <connection>         <use>core_setup</use>      </connection>      </tk_autoShip_setup>  </resources> <blocks>   <tk_autoShip>     <class>Tk_AutoShip_Block</class>   </tk_autoShip> </blocks> <helpers>     <tk_autoShip>         <class>Tk_AutoShip_Helper</class>     </tk_autoShip> </helpers> 

Tk_AutoShip_Adminhtml admin Tk_AutoShip tk_autoShip autoshipgrid.xml

How to use image filter for improve colors of whole application rendering

While I publish images of my app UI on instagram I see how f.e. image filter like Clarendon can improve overall feel of colors of my application UI.

It could be quite a lot of effort try to modify all colors and images manually with this filter or even try some other filter but what if I could apply it at runtime ?

It’s iOS app but I was thinking about Android too, that it would be cool if it is possible to somehow alter rendering of whole application user interface and apply such or some other filer similar to Instagram ones at runtime.

Someone has idea about how this could be achieved ?

Improving rendering performance of 3D Voxel Game


Improving rendering performance of 3D Voxel Game

Technical features added:

  • Perlin Noise Generator
  • 3D Explorable World (You can’t break or place blocks)
  • Free camera, you can fly and go through blocks

Quick overview of implemented optimizations:

  • Asynchronous (Multi-threaded) chunks system.
  • Render only visible faces and cubes.
  • Textures cache and texture atlas
  • Instead of rendering block by block, render the whole chunk at once.
  • Use VBO and Indices

My problems:

  • The framerate is sort of correct, but I think it can still be optimized, because when i’m comparing my game performance to Minecraft for exemple, Minecraft is much much more optimized.

  • The camera takes few seconds to move (I think this is due to Mouse Input, I am not sure, too)

Code:

Main class:

package me.minkizz.whitata;  import java.awt.Toolkit; import java.nio.IntBuffer; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set;  import org.lwjgl.glfw.Callbacks; import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFWErrorCallback; import org.lwjgl.glfw.GLFWVidMode; import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GL11; import org.lwjgl.system.MemoryStack; import org.lwjgl.system.MemoryUtil;  import me.minkizz.whitata.entities.Camera; import me.minkizz.whitata.entities.Entity; import me.minkizz.whitata.maths.PerlinNoiseGenerator; import me.minkizz.whitata.maths.Vector2f; import me.minkizz.whitata.maths.Vector3f; import me.minkizz.whitata.rendering.Loader; import me.minkizz.whitata.rendering.MasterRenderer; import me.minkizz.whitata.rendering.models.ModelTexture; import me.minkizz.whitata.rendering.models.RawModel; import me.minkizz.whitata.rendering.models.TexturedModel; import me.minkizz.whitata.world.Block; import me.minkizz.whitata.world.Chunk; import me.minkizz.whitata.world.ChunkMesh;  public class Whitata implements Runnable {      private boolean running;     private int latestFps;     private static int width, height;     private Timer timer = new Timer(64f);     private long window;     private MasterRenderer masterRenderer;     private Loader loader;     private int latestKey;     private int latestAction;     private Camera camera;     private PerlinNoiseGenerator generator;      private static final int CHUNK_SIZE = 24;     private static final int WORLD_SIZE = 6 * CHUNK_SIZE;     private static final float BLOCK_SCALE = 0.7f;      public static int getWidth() {         return width;     }      public static int getHeight() {         return height;     }      private List<ChunkMesh> chunks = Collections.synchronizedList(new ArrayList<>());     private List<Entity> entities = new ArrayList<>();      private void init() throws Exception {         width = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();         height = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();          GLFWErrorCallback.createPrint(System.err).set();          if (!GLFW.glfwInit()) {             throw new IllegalStateException("Unable to initialize GLFW!");         }          GLFW.glfwDefaultWindowHints();         GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE);         GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GLFW.GLFW_TRUE);          window = GLFW.glfwCreateWindow(width, height, "Whitata", GLFW.glfwGetPrimaryMonitor(), MemoryUtil.NULL);          if (window == MemoryUtil.NULL) {             throw new RuntimeException("Failed to create the GLFW window!");         }          GLFW.glfwSetInputMode(window, GLFW.GLFW_STICKY_MOUSE_BUTTONS, GLFW.GLFW_TRUE);         GLFW.glfwSetInputMode(window, GLFW.GLFW_STICKY_KEYS, GLFW.GLFW_TRUE);         GLFW.glfwSetCursorPosCallback(window, new Mouse());          GLFW.glfwSetKeyCallback(window, (window, key, scancode, action, mods) -> {             latestKey = key;             latestAction = action;              if (key == GLFW.GLFW_KEY_ESCAPE && action == GLFW.GLFW_RELEASE) {                 GLFW.glfwSetWindowShouldClose(window, true);             }          });          try (MemoryStack stack = MemoryStack.stackPush()) {             IntBuffer pWidth = stack.mallocInt(1);             IntBuffer pHeight = stack.mallocInt(1);              GLFW.glfwGetWindowSize(window, pWidth, pHeight);             GLFWVidMode vidmode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());             GLFW.glfwSetWindowPos(window, (vidmode.width() - pWidth.get(0)) / 2,                     (vidmode.height() - pHeight.get(0)) / 2);          }          GLFW.glfwMakeContextCurrent(window);         GLFW.glfwSwapInterval(1);         GLFW.glfwShowWindow(window);         GLFW.glfwSetInputMode(window, GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_DISABLED);         GL.createCapabilities();         GL11.glViewport(0, 0, width, height);          loader = new Loader();         masterRenderer = new MasterRenderer();         texture = new ModelTexture(loader.loadTexture("DefaultPack.png"));         camera = new Camera(new Vector3f(0, 0, 0), 0, 0, 0);          generator = new PerlinNoiseGenerator();          new Thread(new Runnable() {              @Override             public void run() {                  while (!GLFW.glfwWindowShouldClose(window)) {                      for (int x = (int) (((cameraPosition.x - WORLD_SIZE) / CHUNK_SIZE)                             / BLOCK_SCALE); x < ((cameraPosition.x + WORLD_SIZE) / CHUNK_SIZE) / BLOCK_SCALE; x++) {                          for (int z = (int) (((cameraPosition.z - WORLD_SIZE) / CHUNK_SIZE)                                 / BLOCK_SCALE); z < ((cameraPosition.z + WORLD_SIZE) / CHUNK_SIZE) / BLOCK_SCALE; z++) {                              if (!usedPositions.contains(new Vector2f(x * CHUNK_SIZE, z * CHUNK_SIZE))) {                                 Set<Block> blocks = new HashSet<Block>();                                  for (int i = 0; i < CHUNK_SIZE; i++) {                                      for (int j = 0; j < CHUNK_SIZE; j++) {                                         int generatedY = (int) generator.generateHeight(i + (x * CHUNK_SIZE),                                                 j + (z * CHUNK_SIZE)) + 25;                                         blocks.add(new Block(i, generatedY, j, Block.Type.GRASS));                                     }                                  }                                  Chunk chunk = new Chunk(blocks,                                         new Vector3f(x * CHUNK_SIZE, 0 * CHUNK_SIZE, z * CHUNK_SIZE));                                 ChunkMesh chunkMesh = new ChunkMesh(chunk);                                 chunks.add(chunkMesh);                                 usedPositions.add(new Vector2f(x * CHUNK_SIZE, z * CHUNK_SIZE));                             }                          }                      }                  }              }          }).start();      }      private ModelTexture texture;      private void tick(int index) {         camera.move(latestKey);         cameraPosition = camera.getPosition();     }      private int index;      @Override     public void run() {         running = true;          try {             init();         } catch (Exception exception) {             exception.printStackTrace();         }          long lastTime = System.currentTimeMillis();         int frames = 0;         index = 0;          while (running) {              if (GLFW.glfwWindowShouldClose(window)) {                 running = false;             }              timer.advanceTime();              for (int i = 0; i < timer.ticks; ++i) {                 tick(index);             }              latestKey = 0;             latestAction = 0;             render(timer.a);              ++frames;             while (System.currentTimeMillis() >= lastTime + 1000L) {                 latestFps = frames;                 lastTime += 1000L;                 frames = 0;             }          }          Callbacks.glfwFreeCallbacks(window);         GLFW.glfwDestroyWindow(window);         GLFW.glfwTerminate();         GLFW.glfwSetErrorCallback(null).free();         loader.cleanUp();         masterRenderer.cleanUp();         System.exit(0);     }      private Vector3f cameraPosition = new Vector3f();     private List<Vector2f> usedPositions = Collections.synchronizedList(new ArrayList<>());      private void render(float a) {          if (index < chunks.size()) {             ChunkMesh mesh = chunks.get(index);             RawModel model123 = loader.loadToVAO(mesh.positions, mesh.uvs);             TexturedModel texturedModel123 = new TexturedModel(model123, texture);             Entity entity123 = new Entity(texturedModel123, mesh.chunk.getOrigin().multiply(BLOCK_SCALE), 0, 0, 0,                     BLOCK_SCALE);             entities.add(entity123);              mesh.positions = null;             mesh.normals = null;             mesh.uvs = null;              index++;         }          for (int i = 0; i < entities.size(); i++) {             Vector3f origin = entities.get(i).getPosition();             int distX = Math.abs((int) (cameraPosition.x - origin.x));             int distZ = Math.abs((int) (cameraPosition.z - origin.z));              if (distX <= WORLD_SIZE && distZ <= WORLD_SIZE) {                 masterRenderer.addEntity(entities.get(i));             }          }          masterRenderer.prepare();         masterRenderer.render(camera);         GLFW.glfwSwapBuffers(window);         GLFW.glfwPollEvents();     }      public static void main(String[] args) {         new Thread(new Whitata()).start();     }  } 

Timer class:

package me.minkizz.whitata;  public class Timer {     private static final long NS_PER_SECOND = 1000000000L;     private static final long MAX_NS_PER_UPDATE = 1000000000L;     private static final int MAX_TICKS_PER_UPDATE = 100;     private float ticksPerSecond;     private long lastTime;     public int ticks;     public float a;     public float timeScale = 1.0f;     public float fps = 0.0f;     public float passedTime = 0.0f;      public Timer(float ticksPerSecond) {         this.ticksPerSecond = ticksPerSecond;         lastTime = System.nanoTime();     }      public void advanceTime() {         long now = System.nanoTime();         long passedNs = now - lastTime;          lastTime = now;          if (passedNs <= 0L) {             return;         }          if (passedNs > MAX_NS_PER_UPDATE) {             passedNs = MAX_NS_PER_UPDATE;         }          fps = NS_PER_SECOND / passedNs;         passedTime += (float) passedNs * timeScale * ticksPerSecond / 1.0E9f;          ticks = (int) passedTime;          if (ticks > MAX_TICKS_PER_UPDATE) {             ticks = MAX_TICKS_PER_UPDATE;         }          passedTime -= (float) ticks;         a = passedTime;     }  } 

Mouse class:

package me.minkizz.whitata;  import org.lwjgl.glfw.GLFWCursorPosCallback;  public class Mouse extends GLFWCursorPosCallback {     private static double oldMouseX, oldMouseY;     private static double newMouseX, newMouseY;     private static double mouseDX, mouseDY;     private static boolean wasFirst;      @Override     public void invoke(long window, double xpos, double ypos) {          if (!wasFirst) {             wasFirst = true;         } else {             oldMouseX = newMouseX;             oldMouseY = newMouseY;             newMouseX = xpos;             newMouseY = ypos;              mouseDX = newMouseX - oldMouseX;             mouseDY = newMouseY - oldMouseY;         }      }      public static double getMouseDX() {         double result = mouseDX;         mouseDX = 0;         return result;     }      public static double getMouseDY() {         double result = -mouseDY;         mouseDY = 0;         return result;     }  } 

Camera class:

package me.minkizz.whitata.entities;  import org.lwjgl.glfw.GLFW;  import me.minkizz.whitata.Mouse; import me.minkizz.whitata.maths.Vector3f;  public class Camera {      private Vector3f position = new Vector3f();     private float rotX, rotY, rotZ;     private float speed = 0.2f;     private float turnSpeed = 0.07f;     private float moveAt_ = 0f;     private float moveAt = 0f;     private boolean doGravity = true;      private static final boolean USE_GRAVITY = true;      public Camera(Vector3f position, float rotX, float rotY, float rotZ) {         this.position = position;         this.rotX = rotX;         this.rotY = rotY;         this.rotZ = rotZ;     }      public void move(int key) {          if (USE_GRAVITY) {             boolean hasMoved = false;              if (key == GLFW.GLFW_KEY_W) {                 moveAt_ = -speed;                 hasMoved = true;             } else if (key == GLFW.GLFW_KEY_S) {                 moveAt_ = speed;                 hasMoved = true;             } else {                 moveAt_ = 0f;             }              if (hasMoved) {                 moveAt = moveAt_;                 doGravity = true;             } else if (!hasMoved && doGravity) {                 calculateGravity();             }          } else {              if (key == GLFW.GLFW_KEY_W) {                 moveAt = -speed;             } else if (key == GLFW.GLFW_KEY_S) {                 moveAt = speed;             } else {                 moveAt = 0f;             }          }          rotX += -Mouse.getMouseDY() * turnSpeed;         rotY += Mouse.getMouseDX() * turnSpeed;          float dx = (float) -(moveAt * Math.sin(Math.toRadians(rotY)));         float dy = (float) (moveAt * Math.sin(Math.toRadians(rotX)));         float dz = (float) (moveAt * Math.cos(Math.toRadians(rotY)));          position.x += dx;         position.y += dy;         position.z += dz;     }      private void calculateGravity() {          if (moveAt > 0) {             moveAt -= 0.0020;             moveAt /= 1.09;              if (moveAt <= 0.0005) {                 moveAt = 0f;                 doGravity = false;             }          } else {             moveAt += 0.0020;             moveAt /= 1.09;              if (moveAt >= -0.0005) {                 moveAt = 0f;                 doGravity = false;             }          }      }      public Vector3f getPosition() {         return position;     }      public void setPosition(Vector3f position) {         this.position = position;     }      public float getRotX() {         return rotX;     }      public void setRotX(float rotX) {         this.rotX = rotX;     }      public float getRotY() {         return rotY;     }      public void setRotY(float rotY) {         this.rotY = rotY;     }      public float getRotZ() {         return rotZ;     }      public void setRotZ(float rotZ) {         this.rotZ = rotZ;     }  } 

Entity class:

package me.minkizz.whitata.entities;  import me.minkizz.whitata.maths.Vector3f; import me.minkizz.whitata.rendering.models.TexturedModel;  public class Entity {      private TexturedModel model;     private Vector3f position;     private float rotX, rotY, rotZ;     private float scale;      public Entity(TexturedModel model, Vector3f position, float rotX, float rotY, float rotZ, float scale) {         this.model = model;         this.position = position;         this.rotX = rotX;         this.rotY = rotY;         this.rotZ = rotZ;         this.scale = scale;     }      public void increasePosition(float dx, float dy, float dz) {         this.position.x += dx;         this.position.y += dy;         this.position.z += dz;     }      public void increaseRotation(float dx, float dy, float dz) {         this.rotX += dx;         this.rotY += dy;         this.rotZ += dz;     }      public void increaseScale(float scale) {         this.scale += scale;     }      public TexturedModel getModel() {         return model;     }      public void setModel(TexturedModel model) {         this.model = model;     }      public Vector3f getPosition() {         return position;     }      public void setPosition(Vector3f position) {         this.position = position;     }      public float getRotX() {         return rotX;     }      public void setRotX(float rotX) {         this.rotX = rotX;     }      public float getRotY() {         return rotY;     }      public void setRotY(float rotY) {         this.rotY = rotY;     }      public float getRotZ() {         return rotZ;     }      public void setRotZ(float rotZ) {         this.rotZ = rotZ;     }      public float getScale() {         return scale;     }      public void setScale(float scale) {         this.scale = scale;     }  } 

Perlin Noise Generator class:

package me.minkizz.whitata.maths;  import java.util.Random;  public class PerlinNoiseGenerator {      public static float AMPLITUDE = 30f;     public static int OCTAVES = 6;     public static float ROUGHNESS = 0.3f;      private Random random = new Random();     private int seed;     private int xOffset = 0;     private int zOffset = 0;      public PerlinNoiseGenerator() {         this.seed = 0;     }      // only works with POSITIVE gridX and gridZ values!     public PerlinNoiseGenerator(int gridX, int gridZ, int vertexCount, int seed) {         this.seed = seed;         xOffset = gridX * (vertexCount - 1);         zOffset = gridZ * (vertexCount - 1);     }      public float generateHeight(int x, int z) {          x = x < 0 ? -x : x;         z = z < 0 ? -z : z;          float total = 0;         float d = (float) Math.pow(2, OCTAVES - 1);          for (int i = 0; i < OCTAVES; i++) {             float freq = (float) (Math.pow(2, i) / d);             float amp = (float) Math.pow(ROUGHNESS, i) * AMPLITUDE;             total += getInterpolatedNoise((x + xOffset) * freq, (z + zOffset) * freq) * amp;         }          return (float) (int) total;      }      private float getInterpolatedNoise(float x, float z) {         int intX = (int) x;         int intZ = (int) z;         float fracX = x - intX;         float fracZ = z - intZ;          float v1 = getSmoothNoise(intX, intZ);         float v2 = getSmoothNoise(intX + 1, intZ);         float v3 = getSmoothNoise(intX, intZ + 1);         float v4 = getSmoothNoise(intX + 1, intZ + 1);         float i1 = interpolate(v1, v2, fracX);         float i2 = interpolate(v3, v4, fracX);         return interpolate(i1, i2, fracZ);     }      private float interpolate(float a, float b, float blend) {         double theta = blend * Math.PI;         float f = (float) (1f - Math.cos(theta)) * 0.5f;         return a * (1f - f) + b * f;     }      private float getSmoothNoise(int x, int z) {         float corners = (getNoise(x - 1, z - 1) + getNoise(x + 1, z - 1) + getNoise(x - 1, z + 1)                 + getNoise(x + 1, z + 1)) / 16f;         float sides = (getNoise(x - 1, z) + getNoise(x + 1, z) + getNoise(x, z - 1) + getNoise(x, z + 1)) / 8f;         float center = getNoise(x, z) / 4f;         return corners + sides + center;     }      private float getNoise(int x, int z) {         random.setSeed(x * 49632 + z * 325176 + seed);         return random.nextFloat() * 2f - 1f;     }  } 

Entity Renderer class:

package me.minkizz.whitata.rendering;  import java.util.List; import java.util.Map;  import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL13; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL30;  import me.minkizz.whitata.entities.Entity; import me.minkizz.whitata.maths.Maths; import me.minkizz.whitata.maths.Matrix4f; import me.minkizz.whitata.rendering.models.TexturedModel; import me.minkizz.whitata.rendering.shaders.StaticShader;  public class EntityRenderer {      private StaticShader shader = new StaticShader();      public void render(Map<TexturedModel, List<Entity>> entities) {          for (TexturedModel model : entities.keySet()) {             GL30.glBindVertexArray(model.getModel().getVaoID());             GL20.glEnableVertexAttribArray(0);             GL20.glEnableVertexAttribArray(1);             GL13.glActiveTexture(GL13.GL_TEXTURE0);             GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getTextureID());              List<Entity> batch = entities.get(model);              for (Entity entity : batch) {                 Matrix4f transformationMatrix = Maths.createTransformationMatrix(entity.getPosition(), entity.getRotX(),                         entity.getRotY(), entity.getRotZ(), entity.getScale());                 shader.loadTransformationMatrix(transformationMatrix);                 GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, model.getModel().getVertexCount() / 3);             }              GL20.glDisableVertexAttribArray(0);             GL20.glDisableVertexAttribArray(1);             GL30.glBindVertexArray(0);         }      }  } 

Loader class:

package me.minkizz.whitata.rendering;  import java.io.IOException; import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry;  import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL30;  import me.minkizz.whitata.rendering.models.RawModel; import me.minkizz.whitata.rendering.textures.Texture; import me.minkizz.whitata.rendering.textures.TextureLoader;  public class Loader {      private List<Integer> vaos = new ArrayList<>();     private List<Integer> vbos = new ArrayList<>();      public RawModel loadToVAO(float[] vertices, int[] indices, float[] uv) {         int vaoID = createVAO();         storeDataInAttributeList(vertices, 0, 3);         storeDataInAttributeList(uv, 1, 2);         bindIndicesBuffer(indices);         GL30.glBindVertexArray(0);         return new RawModel(vaoID, indices.length);     }      public RawModel loadToVAO(float[] vertices, float[] uv) {         int vaoID = createVAO();         storeDataInAttributeList(vertices, 0, 3);         storeDataInAttributeList(uv, 1, 2);         GL30.glBindVertexArray(0);         return new RawModel(vaoID, vertices.length);     }      private int createVAO() {         int vaoID = GL30.glGenVertexArrays();         vaos.add(vaoID);         GL30.glBindVertexArray(vaoID);         return vaoID;     }      private Map<String, Integer> textureCache = new HashMap<>();      public int loadTexture(String fileName) {          if (textureCache.containsKey(fileName)) {             return textureCache.get(fileName);         }          Texture texture = null;          try {             texture = TextureLoader.getTexture("/res/" + fileName);             GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);             GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);             GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);             GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, -4);         } catch (IOException exception) {             exception.printStackTrace();         }          int textureID = texture.getTextureID();         textureCache.put(fileName, textureID);         return textureID;     }      private void storeDataInAttributeList(float[] data, int attributeNumber, int dimensions) {         int vboID = GL15.glGenBuffers();         vbos.add(vboID);         GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID);         FloatBuffer buffer = storeDataInFloatBuffer(data);         GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);         GL20.glVertexAttribPointer(attributeNumber, dimensions, GL11.GL_FLOAT, false, 0, 0);         GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);     }      private void bindIndicesBuffer(int[] indices) {         int vboID = GL15.glGenBuffers();         vbos.add(vboID);         GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboID);         IntBuffer buffer = storeDataInIntBuffer(indices);         GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);     }      private IntBuffer storeDataInIntBuffer(int[] data) {         IntBuffer buffer = BufferUtils.createIntBuffer(data.length);         buffer.put(data);         buffer.flip();         return buffer;     }      private FloatBuffer storeDataInFloatBuffer(float[] data) {         FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);         buffer.put(data);         buffer.flip();         return buffer;     }      public void cleanUp() {          for (int vao : vaos) {             GL30.glDeleteVertexArrays(vao);         }          for (int vbo : vbos) {             GL15.glDeleteBuffers(vbo);         }          for (Entry<String, Integer> entry : textureCache.entrySet()) {             GL11.glDeleteTextures(entry.getValue());         }      }  } 

Master Renderer class:

package me.minkizz.whitata.rendering;  import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;  import org.lwjgl.opengl.GL11;  import me.minkizz.whitata.Whitata; import me.minkizz.whitata.entities.Camera; import me.minkizz.whitata.entities.Entity; import me.minkizz.whitata.maths.Matrix4f; import me.minkizz.whitata.rendering.models.TexturedModel; import me.minkizz.whitata.rendering.shaders.StaticShader;  public class MasterRenderer {      private Matrix4f projectionMatrix = new Matrix4f();     private static final float FOV = 70f;     private static final float NEAR_PLANE = 0.1f;     private static final float FAR_PLANE = 10000f;      private StaticShader shader = new StaticShader();     private EntityRenderer renderer = new EntityRenderer();     private Map<TexturedModel, List<Entity>> entities = new HashMap<>();      public MasterRenderer() {         createProjectionMatrix();         shader.start();         shader.loadProjectionMatrix(projectionMatrix);         shader.stop();     }      public void prepare() {         GL11.glClearColor(0.4f, 0.7f, 1.0f, 1);         GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);         GL11.glEnable(GL11.GL_DEPTH_TEST);         GL11.glDepthFunc(GL11.GL_LEQUAL);     }      public void render(Camera camera) {         prepare();         shader.start();         shader.loadViewMatrix(camera);         renderer.render(entities);         shader.stop();         entities.clear();     }      public void addEntity(Entity entity) {         TexturedModel model = entity.getModel();         List<Entity> batch = entities.get(model);          if (batch != null) {             batch.add(entity);         } else {             List<Entity> newBatch = new ArrayList<>();             newBatch.add(entity);             entities.put(model, newBatch);         }      }      public void createProjectionMatrix() {         float aspect = (float) Whitata.getWidth() / (float) Whitata.getHeight();         float yScale = (float) (1f / Math.tan(Math.toRadians(FOV / 2F)));         float xScale = yScale / aspect;         float zp = FAR_PLANE + NEAR_PLANE;         float zm = FAR_PLANE - NEAR_PLANE;          projectionMatrix.m00 = xScale;         projectionMatrix.m11 = yScale;         projectionMatrix.m22 = -zp / zm;         projectionMatrix.m23 = -1;         projectionMatrix.m32 = -(2 * FAR_PLANE * NEAR_PLANE) / zm;         projectionMatrix.m33 = 0;     }      public void cleanUp() {         shader.cleanUp();     }  } 

Block class:

package me.minkizz.whitata.world;  public class Block {      public int x, y, z;      public static enum Type {          GRASS(0), DIRT(1), STONE(2), TREEBARK(3), TREELEAF(4);          private int id;          Type(int id) {             this.id = id;         }          public int getId() {             return id;         }      }      public Type type;      public Block(int x, int y, int z, Type type) {         this.x = x;         this.y = y;         this.z = z;         this.type = type;     }      public void setType(Type type) {         this.type = type;     }      public Type getType() {         return type;     }  } 

Chunk class:

package me.minkizz.whitata.world;  import java.util.Set;  import me.minkizz.whitata.maths.Vector3f;  public class Chunk {      private Set<Block> blocks;     private Vector3f origin;      public Chunk(Set<Block> blocks, Vector3f origin) {         this.blocks = blocks;         this.origin = origin;     }      public Set<Block> getBlocks() {         return blocks;     }      public void setBlocks(Set<Block> blocks) {         this.blocks = blocks;     }      public Vector3f getOrigin() {         return origin;     }      public void setOrigin(Vector3f origin) {         this.origin = origin;     }  } 

Chunk Mesh class:

package me.minkizz.whitata.world;  import java.util.ArrayList; import java.util.Iterator; import java.util.List;  import me.minkizz.whitata.maths.Vector3f; import me.minkizz.whitata.maths.Vertex; import me.minkizz.whitata.rendering.models.CubeModel;  public class ChunkMesh {      private List<Vertex> vertices;      private List<Float> positionsList;     private List<Float> uvsList;     private List<Float> normalsList;      public float[] positions, uvs, normals;      public Chunk chunk;      public ChunkMesh(Chunk chunk) {         this.chunk = chunk;          vertices = new ArrayList<Vertex>();         positionsList = new ArrayList<Float>();         uvsList = new ArrayList<Float>();         normalsList = new ArrayList<Float>();          buildMesh();         populateLists();     }      public void update(Chunk chunk) {         this.chunk = chunk;          buildMesh();         populateLists();     }      public void buildMesh() {         Iterator<Block> iterator = chunk.getBlocks().iterator();          while (iterator.hasNext()) {             Block blockI = iterator.next();             boolean px = false, nx = false, py = false, ny = false, pz = false, nz = false;             Iterator<Block> iterator2 = chunk.getBlocks().iterator();              while (iterator2.hasNext()) {                 Block blockJ = iterator2.next();                  if (((blockI.x + 1) == (blockJ.x)) && ((blockI.y) == (blockJ.y)) && ((blockI.z) == (blockJ.z))) {                     px = true;                 }                  if (((blockI.x - 1) == (blockJ.x)) && ((blockI.y) == (blockJ.y)) && ((blockI.z) == (blockJ.z))) {                     nx = true;                 }                  if (((blockI.x) == (blockJ.x)) && ((blockI.y + 1) == (blockJ.y)) && ((blockI.z) == (blockJ.z))) {                     py = true;                 }                  if (((blockI.x) == (blockJ.x)) && ((blockI.y - 1) == (blockJ.y)) && ((blockI.z) == (blockJ.z))) {                     ny = true;                 }                  if (((blockI.x) == (blockJ.x)) && ((blockI.y) == (blockJ.y)) && ((blockI.z + 1) == (blockJ.z))) {                     pz = true;                 }                  if (((blockI.x) == (blockJ.x)) && ((blockI.y) == (blockJ.y)) && ((blockI.z - 1) == (blockJ.z))) {                     nz = true;                 }              }              if (!px) {                  for (int k = 0; k < 6; k++) {                     vertices.add(new Vertex(                             new Vector3f(CubeModel.PX_POS[k].x + blockI.x, CubeModel.PX_POS[k].y + blockI.y,                                     CubeModel.PX_POS[k].z + blockI.z),                             CubeModel.UV_PX[(blockI.type.getId() * 6) + k], CubeModel.NORMALS[k]));                 }              }              if (!px) {                  for (int k = 0; k < 6; k++) {                     vertices.add(new Vertex(                             new Vector3f(CubeModel.PX_POS[k].x + blockI.x, CubeModel.PX_POS[k].y + blockI.y,                                     CubeModel.PX_POS[k].z + blockI.z),                             CubeModel.UV_PX[(blockI.type.getId() * 6) + k], CubeModel.NORMALS[k]));                 }              }              if (!nx) {                  for (int k = 0; k < 6; k++) {                     vertices.add(new Vertex(                             new Vector3f(CubeModel.NX_POS[k].x + blockI.x, CubeModel.NX_POS[k].y + blockI.y,                                     CubeModel.NX_POS[k].z + blockI.z),                             CubeModel.UV_NX[(blockI.type.getId() * 6) + k], CubeModel.NORMALS[k]));                 }              }              if (!py) {                  for (int k = 0; k < 6; k++) {                     vertices.add(new Vertex(                             new Vector3f(CubeModel.PY_POS[k].x + blockI.x, CubeModel.PY_POS[k].y + blockI.y,                                     CubeModel.PY_POS[k].z + blockI.z),                             CubeModel.UV_PY[(blockI.type.getId() * 6) + k], CubeModel.NORMALS[k]));                 }              }              if (!ny) {                  for (int k = 0; k < 6; k++) {                     vertices.add(new Vertex(                             new Vector3f(CubeModel.NY_POS[k].x + blockI.x, CubeModel.NY_POS[k].y + blockI.y,                                     CubeModel.NY_POS[k].z + blockI.z),                             CubeModel.UV_NY[(blockI.type.getId() * 6) + k], CubeModel.NORMALS[k]));                 }              }              if (!pz) {                  for (int k = 0; k < 6; k++) {                     vertices.add(new Vertex(                             new Vector3f(CubeModel.PZ_POS[k].x + blockI.x, CubeModel.PZ_POS[k].y + blockI.y,                                     CubeModel.PZ_POS[k].z + blockI.z),                             CubeModel.UV_PZ[(blockI.type.getId() * 6) + k], CubeModel.NORMALS[k]));                 }              }              if (!nz) {                  for (int k = 0; k < 6; k++) {                     vertices.add(new Vertex(                             new Vector3f(CubeModel.NZ_POS[k].x + blockI.x, CubeModel.NZ_POS[k].y + blockI.y,                                     CubeModel.NZ_POS[k].z + blockI.z),                             CubeModel.UV_NZ[(blockI.type.getId() * 6) + k], CubeModel.NORMALS[k]));                 }              }          }      }      public void populateLists() {          for (int i = 0; i < vertices.size(); i++) {             Vertex vertex = vertices.get(i);             positionsList.add(vertex.positions.x);             positionsList.add(vertex.positions.y);             positionsList.add(vertex.positions.z);             normalsList.add(vertex.normals.x);             normalsList.add(vertex.normals.y);             normalsList.add(vertex.normals.z);             uvsList.add(vertex.uvs.x);             uvsList.add(vertex.uvs.y);         }          positions = new float[positionsList.size()];         uvs = new float[uvsList.size()];         normals = new float[normalsList.size()];          for (int i = 0; i < positionsList.size(); i++) {             positions[i] = positionsList.get(i);         }          for (int i = 0; i < uvsList.size(); i++) {             uvs[i] = uvsList.get(i);         }          for (int i = 0; i < normalsList.size(); i++) {             normals[i] = normalsList.get(i);         }          positionsList.clear();         uvsList.clear();         normalsList.clear();     }  } 

Are graphic cards using the Map-Reduce model when performing typical gaming rendering

I know that the Map-Reduce model is a common model of parallel computation, perhaps some sort of standard way(?). I also know that graphic cards are specifically built for parallel computation. However when reading about the graphic pipeline I am not sure if there is a point at which the Map Reduce model is used. If not, what kind of parallel computations (just the general model of them so I could read more about it) are done during the typical rendering process of modern graphics cards? If it is used, where would that be on the below pipeline?

Programmable 3D-Pipeline public domain

Rendering form in paragraph [on hold]

I need to preprocess paragraph that is in a custom block in header so I can generate my custom made form inside it, and then render that form in twig. So far I have form, paragraph–request.html.twig file with {{form}} in it, and in my theme.module file I have

function theme_preprocess_paragraph__request(&$ vars){ $ myForm = \Drupal::formBuilder()->getForm(‘\Drupal\theme\src\Form\RequestForm’); $ vars = [ ‘#form’ => $ myForm,]; }

I cleared my cashe but nothing is happening. How can I achieve this?

SVG not rendering in PNG, only renders in Chrome after zooming in/out

I’m trying trying to create a relatively simple background for an SVG image. I’ve created an equivalent in GIMP, applying a radial gradient from the centre to the edge and then applying the “spread” filter.

Version created in GIMP.

I have the following code that accomplishes a similar result, at least in Inkscape.

<?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg id="wallpaper"   viewBox="0 0 1920 1080" height="1080" width="1920"   xmlns="http://www.w3.org/2000/svg"   version="1.1" >   <defs>     <radialGradient id="gradient">       <stop offset="2.5%" stop-color="#ffffff"/>       <stop offset="100%" stop-color="#000000"/>     </radialGradient>      <clipPath id="gradientClip" clipPathUnits="userSpaceOnUse">       <rect         id="gradientClip-rect" y="0" x="0" height="1080" width="1920"       />     </clipPath>   </defs>     <g id="background" clip-path="url(#gradientClip)">     <rect       id="background-fill" width="1920" height="1080" x="0" y="0"       style="fill:#000000;"     />      <filter id="gradientNoise">       <feTurbulence type="fractalNoise" baseFrequency="50" numOctaves="2" result="turbulence"/>       <feDisplacementMap         in2="turbulence" in="SourceGraphic" scale="540"         xChannelSelector="R" yChannelSelector="G"       />     </filter>      <circle       id="background-gradient" filter="url(#gradientNoise)" fill="url(#gradient)"       cx="960" cy="540" r="960"     />   </g> </svg> 

However, when I rasterize it to a PNG or open it in Chrome (at 100% zoom) all I get is the gradient with no noise.

enter image description here

However again, if I zoom in or out in Chrome the filter applies correctly.

Side-by-side comparison of Chrome rendering the image at 80% and 110%.

Is it possible that there is some kind of issue with this file that only appears when the image is viewed at the size defined in the viewbox? Is there something else that I’m not seeing?

I would have chalked my PNG issue up to the same problem this poster was having if it weren’t for the odd behaviour I’m only noticing when my browser is set to 100% zoom.

Thanks!