TextureInstancedActor grass packing fix
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
732c9700c4
commit
d87c262955
@ -37,9 +37,9 @@ uniform float time;
|
||||
|
||||
|
||||
/**
|
||||
Size of a column of data
|
||||
Size of a row of data
|
||||
*/
|
||||
uniform int colSize;
|
||||
uniform int rowSize;
|
||||
|
||||
|
||||
//output buffers
|
||||
@ -75,8 +75,8 @@ void main() {
|
||||
|
||||
ivec2 texSize = textureSize(material.diffuse,0);
|
||||
|
||||
int sampleX = (gl_InstanceID / colSize) * 5;
|
||||
int sampleY = (gl_InstanceID % colSize);
|
||||
int sampleX = (gl_InstanceID % rowSize) * 5;
|
||||
int sampleY = (gl_InstanceID / rowSize);
|
||||
|
||||
//grab data out of texture
|
||||
float xOffset = texelFetch(material.diffuse,ivec2(0 + sampleX,sampleY),0).r;
|
||||
|
||||
@ -1349,6 +1349,7 @@ Fix UI Testing debug menu
|
||||
Fix orphan tooltips from inventory screen
|
||||
Code formatting
|
||||
File-controlled foliage coloration
|
||||
Fix TextureInstancedActor packing data texture incorrectly (column major instead of row major)
|
||||
|
||||
|
||||
# TODO
|
||||
|
||||
@ -242,7 +242,7 @@ public class FoliageModel {
|
||||
QueuedTexture queuedAsset = new QueuedTexture(QueuedTextureType.DATA_BUFF,buffer,textureWidth,textureHeight);
|
||||
Globals.assetManager.queuedAsset(queuedAsset);
|
||||
|
||||
TextureInstancedActor actor = TextureInstancedActor.attachTextureInstancedActor(rVal, foliageType.getGraphicsTemplate().getModel().getPath(), vertexPath, fragmentPath, queuedAsset, drawCount, textureHeight);
|
||||
TextureInstancedActor actor = TextureInstancedActor.attachTextureInstancedActor(rVal, foliageType.getGraphicsTemplate().getModel().getPath(), vertexPath, fragmentPath, queuedAsset, drawCount, textureWidth / 5);
|
||||
ClientEntityUtils.initiallyPositionEntity(rVal, realPos, new Quaterniond());
|
||||
EntityUtils.getScale(rVal).set(1,1,1);
|
||||
//add ambient foliage behavior tree
|
||||
|
||||
@ -24,9 +24,9 @@ import electrosphere.renderer.texture.Texture;
|
||||
public class TextureInstancedActor {
|
||||
|
||||
/**
|
||||
* Uniform location for the column size uniform
|
||||
* Uniform location for the row size uniform
|
||||
*/
|
||||
static final String uniformColSize = "colSize";
|
||||
static final String uniformRowSize = "rowSize";
|
||||
|
||||
//path of the model that this instanced actor uses
|
||||
String modelPath;
|
||||
@ -38,9 +38,10 @@ public class TextureInstancedActor {
|
||||
int drawCount;
|
||||
|
||||
/**
|
||||
* Size of a column of data
|
||||
* Size of a row of data
|
||||
* Used because textures are packed row-major, not column-major
|
||||
*/
|
||||
int colSize = 1;
|
||||
int rowSize = 1;
|
||||
|
||||
/**
|
||||
* The queued texture
|
||||
@ -78,12 +79,12 @@ public class TextureInstancedActor {
|
||||
* Creates an instanced actor
|
||||
* @param modelPath The path of the model this actor uses
|
||||
*/
|
||||
protected TextureInstancedActor(String modelPath, String vertexShaderPath, String fragmentShaderPath, QueuedTexture dataTexture, int drawCount, int colSize){
|
||||
protected TextureInstancedActor(String modelPath, String vertexShaderPath, String fragmentShaderPath, QueuedTexture dataTexture, int drawCount, int rowSize){
|
||||
this.modelPath = modelPath;
|
||||
this.material = new Material();
|
||||
this.queuedTexture = dataTexture;
|
||||
this.drawCount = drawCount;
|
||||
this.colSize = colSize;
|
||||
this.rowSize = rowSize;
|
||||
this.vertexShaderPath = vertexShaderPath;
|
||||
this.fragmentShaderPath = fragmentShaderPath;
|
||||
}
|
||||
@ -107,11 +108,11 @@ public class TextureInstancedActor {
|
||||
* @param fragmentShaderPath The path to the fragment shader to use
|
||||
* @param dataTexture The data texture containing data for this actor
|
||||
* @param drawCount The number of instances to draw
|
||||
* @param colSize The size of a column of data
|
||||
* @param rowSize The size of a row of data
|
||||
* @return The TextureInstancedActor that was attached to the entity
|
||||
*/
|
||||
public static TextureInstancedActor attachTextureInstancedActor(Entity parent, String modelPath, String vertexShaderPath, String fragmentShaderPath, QueuedTexture dataTexture, int drawCount, int colSize){
|
||||
TextureInstancedActor newActor = new TextureInstancedActor(modelPath, vertexShaderPath, fragmentShaderPath, dataTexture, drawCount, colSize);
|
||||
public static TextureInstancedActor attachTextureInstancedActor(Entity parent, String modelPath, String vertexShaderPath, String fragmentShaderPath, QueuedTexture dataTexture, int drawCount, int rowSize){
|
||||
TextureInstancedActor newActor = new TextureInstancedActor(modelPath, vertexShaderPath, fragmentShaderPath, dataTexture, drawCount, rowSize);
|
||||
parent.putData(EntityDataStrings.TEXTURE_INSTANCED_ACTOR, newActor);
|
||||
return newActor;
|
||||
}
|
||||
@ -157,7 +158,7 @@ public class TextureInstancedActor {
|
||||
|
||||
|
||||
openGLState.setActiveShader(renderPipelineState, shader);
|
||||
shader.setUniform(openGLState, uniformColSize, colSize);
|
||||
shader.setUniform(openGLState, uniformRowSize, rowSize);
|
||||
this.material.apply_material(openGLState);
|
||||
|
||||
//apply uniform overrides
|
||||
|
||||
Loading…
Reference in New Issue
Block a user