mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-14 06:24:12 +01:00
No hacks here no sir
- Ubershaders working on instancing - Just declare a uniform and fetch/set it right before we draw
This commit is contained in:
parent
39423090b4
commit
6bacc6ea42
@ -17,6 +17,7 @@ import com.jozufozu.flywheel.backend.instancing.Engine;
|
|||||||
import com.jozufozu.flywheel.backend.instancing.InstanceManager;
|
import com.jozufozu.flywheel.backend.instancing.InstanceManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TaskEngine;
|
import com.jozufozu.flywheel.backend.instancing.TaskEngine;
|
||||||
import com.jozufozu.flywheel.backend.instancing.compile.FlwCompiler;
|
import com.jozufozu.flywheel.backend.instancing.compile.FlwCompiler;
|
||||||
|
import com.jozufozu.flywheel.core.ComponentRegistry;
|
||||||
import com.jozufozu.flywheel.core.Pipelines;
|
import com.jozufozu.flywheel.core.Pipelines;
|
||||||
import com.jozufozu.flywheel.core.RenderContext;
|
import com.jozufozu.flywheel.core.RenderContext;
|
||||||
import com.jozufozu.flywheel.core.context.SimpleContext;
|
import com.jozufozu.flywheel.core.context.SimpleContext;
|
||||||
@ -123,8 +124,13 @@ public class InstancingEngine implements Engine {
|
|||||||
var structType = desc.instance();
|
var structType = desc.instance();
|
||||||
var material = desc.material();
|
var material = desc.material();
|
||||||
|
|
||||||
FlwCompiler.INSTANCE.getPipelineProgram(vertexType, structType, context, Pipelines.INSTANCED_ARRAYS)
|
var program = FlwCompiler.INSTANCE.getPipelineProgram(vertexType, structType, context, Pipelines.INSTANCED_ARRAYS);
|
||||||
.bind();
|
program.bind();
|
||||||
|
|
||||||
|
var uniformLocation = program.getUniformLocation("_flw_materialID_instancing");
|
||||||
|
var vertexID = ComponentRegistry.materials.getVertexID(material);
|
||||||
|
var fragmentID = ComponentRegistry.materials.getFragmentID(material);
|
||||||
|
GL32.glUniform2ui(uniformLocation, vertexID, fragmentID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
#use "flywheel:api/vertex.glsl"
|
#use "flywheel:api/vertex.glsl"
|
||||||
|
|
||||||
|
uniform uvec2 _flw_materialID_instancing;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
flw_layoutVertex();
|
flw_layoutVertex();
|
||||||
|
|
||||||
|
flw_materialVertexID = _flw_materialID_instancing.x;
|
||||||
|
flw_materialFragmentID = _flw_materialID_instancing.y;
|
||||||
|
|
||||||
FlwInstance i = flw_unpackInstance();
|
FlwInstance i = flw_unpackInstance();
|
||||||
flw_instanceVertex(i);
|
flw_instanceVertex(i);
|
||||||
flw_materialVertex();
|
flw_materialVertex();
|
||||||
|
Loading…
Reference in New Issue
Block a user