mirror of
				https://github.com/GayPizzaSpecifications/voxelotl-engine.git
				synced 2025-11-04 02:59:37 +00:00 
			
		
		
		
	use floats for instance colour memory
This commit is contained in:
		@ -89,6 +89,10 @@ public extension Color where T: BinaryFloatingPoint {
 | 
				
			|||||||
    self.init(r: newR, g: newG, b: newB, a: Self.one)
 | 
					    self.init(r: newR, g: newG, b: newB, a: Self.one)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  init<U: BinaryFloatingPoint>(_ other: Color<U>) {
 | 
				
			||||||
 | 
					    self._values = SIMD4<T>(other._values)
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  init<U: BinaryInteger>(_ other: Color<U>) {
 | 
					  init<U: BinaryInteger>(_ other: Color<U>) {
 | 
				
			||||||
    let mul = 1 / T(0xFF)
 | 
					    let mul = 1 / T(0xFF)
 | 
				
			||||||
    self.init(
 | 
					    self.init(
 | 
				
			||||||
 | 
				
			|||||||
@ -380,7 +380,7 @@ public class Renderer {
 | 
				
			|||||||
          .scale(instance.scale)
 | 
					          .scale(instance.scale)
 | 
				
			||||||
        data[i] = VertexShaderInstance(
 | 
					        data[i] = VertexShaderInstance(
 | 
				
			||||||
          model: model, normalModel: model.inverse.transpose,
 | 
					          model: model, normalModel: model.inverse.transpose,
 | 
				
			||||||
          color: SIMD4(Color<UInt8>(instance.color)))
 | 
					          color: SIMD4(Color<Float>(instance.color)))
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    instanceBuffer.didModifyRange(0..<instancesBytes)
 | 
					    instanceBuffer.didModifyRange(0..<instancesBytes)
 | 
				
			||||||
 | 
				
			|||||||
@ -23,7 +23,7 @@ vertex FragmentInput vertexMain(
 | 
				
			|||||||
  FragmentInput out;
 | 
					  FragmentInput out;
 | 
				
			||||||
  out.position = u.projView * world;
 | 
					  out.position = u.projView * world;
 | 
				
			||||||
  out.world    = world.xyz;
 | 
					  out.world    = world.xyz;
 | 
				
			||||||
  out.color    = half4(i[instanceID].color) / 255.0;
 | 
					  out.color    = half4(i[instanceID].color);
 | 
				
			||||||
  out.normal   = (i[instanceID].normalModel * vtx[vertexID].normal).xyz;
 | 
					  out.normal   = (i[instanceID].normalModel * vtx[vertexID].normal).xyz;
 | 
				
			||||||
  out.texCoord = vtx[vertexID].texCoord;
 | 
					  out.texCoord = vtx[vertexID].texCoord;
 | 
				
			||||||
  return out;
 | 
					  return out;
 | 
				
			||||||
 | 
				
			|||||||
@ -25,7 +25,7 @@ typedef struct {
 | 
				
			|||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
  matrix_float4x4 model;
 | 
					  matrix_float4x4 model;
 | 
				
			||||||
  matrix_float4x4 normalModel;
 | 
					  matrix_float4x4 normalModel;
 | 
				
			||||||
  vector_uchar4 color;
 | 
					  vector_float4 color;
 | 
				
			||||||
} VertexShaderInstance;
 | 
					} VertexShaderInstance;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user