remove vertex_buffer and index_buffer for characters and character shadows
refactor world shader vertex position calculation
This commit is contained in:
+10
-44
@@ -475,8 +475,8 @@ void renderer_frame_draw(R_Buffer vertex_buffer, R_Buffer index_buffer, R_Buffer
|
||||
wgpuRenderPassEncoderSetBindGroup(pass_encoder, 3, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
if (vertex_buffer) wgpuRenderPassEncoderSetVertexBuffer(pass_encoder, 0, vertex_buffer->buffer, 0, WGPU_WHOLE_SIZE);
|
||||
if (instance_buffer) wgpuRenderPassEncoderSetVertexBuffer(pass_encoder, 1, instance_buffer->buffer, 0, WGPU_WHOLE_SIZE);
|
||||
if (vertex_buffer) wgpuRenderPassEncoderSetVertexBuffer(pass_encoder, 0, vertex_buffer->buffer, 0, WGPU_WHOLE_SIZE);
|
||||
if (instance_buffer) wgpuRenderPassEncoderSetVertexBuffer(pass_encoder, vertex_buffer ? 1 : 0, instance_buffer->buffer, 0, WGPU_WHOLE_SIZE);
|
||||
|
||||
if (index_buffer) {
|
||||
wgpuRenderPassEncoderSetIndexBuffer(pass_encoder, index_buffer->buffer, WGPUIndexFormat_Uint16, 0, WGPU_WHOLE_SIZE);
|
||||
@@ -683,14 +683,14 @@ bool renderer_init(SDL_Window *window_) {
|
||||
.chain = { .next = NULL, .sType = WGPUSType_ShaderSourceWGSL },
|
||||
.code = { .data = shader_source, .length = SDL_arraysize(shader_source) },
|
||||
},
|
||||
.label = { .data = "basic shader", .length = WGPU_STRLEN }
|
||||
.label = { .data = "character shader", .length = WGPU_STRLEN }
|
||||
});
|
||||
|
||||
shaders[R_SHADER_CHARACTER] = wgpuDeviceCreateRenderPipeline(device, &(WGPURenderPipelineDescriptor){
|
||||
.label = { .data = "basic render_pipeline", .length = WGPU_STRLEN },
|
||||
.label = { .data = "character render_pipeline", .length = WGPU_STRLEN },
|
||||
|
||||
.layout = wgpuDeviceCreatePipelineLayout(device, &(WGPUPipelineLayoutDescriptor){
|
||||
.label = { .data = "basic pipeline_layout", .length = WGPU_STRLEN },
|
||||
.label = { .data = "character pipeline_layout", .length = WGPU_STRLEN },
|
||||
.bindGroupLayoutCount = 4,
|
||||
.bindGroupLayouts = (WGPUBindGroupLayout[]){
|
||||
wgpuDeviceCreateBindGroupLayout(device, &(WGPUBindGroupLayoutDescriptor){
|
||||
@@ -726,25 +726,8 @@ bool renderer_init(SDL_Window *window_) {
|
||||
.entryPoint = { .data = "main_vertex", .length = WGPU_STRLEN },
|
||||
.constantCount = 0,
|
||||
.constants = NULL,
|
||||
.bufferCount = 2,
|
||||
.bufferCount = 1,
|
||||
.buffers = (WGPUVertexBufferLayout[]){
|
||||
{
|
||||
.stepMode = WGPUVertexStepMode_Vertex,
|
||||
.arrayStride = 20,
|
||||
.attributeCount = 2,
|
||||
.attributes = (WGPUVertexAttribute[]){
|
||||
{
|
||||
.format = WGPUVertexFormat_Float32x3,
|
||||
.offset = 0,
|
||||
.shaderLocation = 0,
|
||||
},
|
||||
{
|
||||
.format = WGPUVertexFormat_Float32x2,
|
||||
.offset = 12,
|
||||
.shaderLocation = 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
.stepMode = WGPUVertexStepMode_Instance,
|
||||
.arrayStride = 12,
|
||||
@@ -804,14 +787,14 @@ bool renderer_init(SDL_Window *window_) {
|
||||
.chain = { .next = NULL, .sType = WGPUSType_ShaderSourceWGSL },
|
||||
.code = { .data = shader_source, .length = SDL_arraysize(shader_source) },
|
||||
},
|
||||
.label = { .data = "basic shader", .length = WGPU_STRLEN }
|
||||
.label = { .data = "character_shadow shader", .length = WGPU_STRLEN }
|
||||
});
|
||||
|
||||
shaders[R_SHADER_CHARACTER_SHADOW] = wgpuDeviceCreateRenderPipeline(device, &(WGPURenderPipelineDescriptor){
|
||||
.label = { .data = "basic render_pipeline", .length = WGPU_STRLEN },
|
||||
.label = { .data = "character_shadow render_pipeline", .length = WGPU_STRLEN },
|
||||
|
||||
.layout = wgpuDeviceCreatePipelineLayout(device, &(WGPUPipelineLayoutDescriptor){
|
||||
.label = { .data = "basic pipeline_layout", .length = WGPU_STRLEN },
|
||||
.label = { .data = "character_shadow pipeline_layout", .length = WGPU_STRLEN },
|
||||
.bindGroupLayoutCount = 4,
|
||||
.bindGroupLayouts = (WGPUBindGroupLayout[]){
|
||||
wgpuDeviceCreateBindGroupLayout(device, &(WGPUBindGroupLayoutDescriptor){
|
||||
@@ -847,25 +830,8 @@ bool renderer_init(SDL_Window *window_) {
|
||||
.entryPoint = { .data = "main_vertex", .length = WGPU_STRLEN },
|
||||
.constantCount = 0,
|
||||
.constants = NULL,
|
||||
.bufferCount = 2,
|
||||
.bufferCount = 1,
|
||||
.buffers = (WGPUVertexBufferLayout[]){
|
||||
{
|
||||
.stepMode = WGPUVertexStepMode_Vertex,
|
||||
.arrayStride = 20,
|
||||
.attributeCount = 2,
|
||||
.attributes = (WGPUVertexAttribute[]){
|
||||
{
|
||||
.format = WGPUVertexFormat_Float32x3,
|
||||
.offset = 0,
|
||||
.shaderLocation = 0,
|
||||
},
|
||||
{
|
||||
.format = WGPUVertexFormat_Float32x2,
|
||||
.offset = 12,
|
||||
.shaderLocation = 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
.stepMode = WGPUVertexStepMode_Instance,
|
||||
.arrayStride = 12,
|
||||
|
||||
Reference in New Issue
Block a user