wip(render3d): plan 22.14 - the OpenGL backend removed (suite 306/306, not yet handed over)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c2a5df4be8
commit
9a4137e9da
8 changed files with 162 additions and 388 deletions
|
|
@ -34,28 +34,6 @@ function r3d_find_root(render3d_st: mut Render3dState) -> void {
|
|||
print(`r3d: cannot find the renderer's shaders (looked in {render3d_st.r3d_root}/shaders and {alt}/shaders)`)
|
||||
}
|
||||
|
||||
function r3d_shader_file(render3d_st: mut Render3dState, name: string) -> string {
|
||||
r3d_find_root(render3d_st)
|
||||
let path = `{render3d_st.r3d_root}/shaders/{name}`
|
||||
let s = Fs.read_text(path)
|
||||
if s == null { print(`r3d: missing shader {path}`); return "" }
|
||||
return s
|
||||
}
|
||||
|
||||
function r3d_shader_src(render3d_st: mut Render3dState, name: string, defines: string, is_frag: bool) -> string {
|
||||
if render3d_st.r3d_noise_src == null { render3d_st.r3d_noise_src = r3d_shader_file(render3d_st, "noise.glsl") }
|
||||
if render3d_st.r3d_lighting_src == null { render3d_st.r3d_lighting_src = r3d_shader_file(render3d_st, "lighting.glsl") }
|
||||
# the wind goes to BOTH stages: the grass and the crowns move in the vertex shader, the water
|
||||
# ripples in the fragment one, and they have to be reading the same field or the meadow and
|
||||
# the lake disagree about the weather
|
||||
if render3d_st.r3d_wind_src == null { render3d_st.r3d_wind_src = r3d_shader_file(render3d_st, "wind.glsl") }
|
||||
var s = "#version 410 core\n" + render3d_st.r3d_global_defs + defines + render3d_st.r3d_wind_src
|
||||
if is_frag { s = s + render3d_st.r3d_noise_src + render3d_st.r3d_lighting_src }
|
||||
# a blade's colour field is worked out once per vertex, not once per pixel (grass.vert)
|
||||
else if Text.contains(defines, "#define GBLADE") { s = s + render3d_st.r3d_noise_src }
|
||||
return s + r3d_shader_file(render3d_st, name)
|
||||
}
|
||||
|
||||
# Build a program from a vertex + fragment file pair (defines apply to both).
|
||||
# R3D_PROGRAMS_LOG=<file>: append every program built (vertex, fragment, defines) - the list a
|
||||
# backend that cannot compile shaders at run time (Vulkan: SPIR-V is built ahead) must cover
|
||||
|
|
@ -72,7 +50,7 @@ function r3d_program_log(render3d_st: mut Render3dState, vs: string, fs: string,
|
|||
}
|
||||
function r3d_program(render3d_st: mut Render3dState, vs: string, fs: string, defines: string) -> int {
|
||||
r3d_program_log(render3d_st, vs, fs, defines)
|
||||
let p = gpu_program(render3d_st, r3d_shader_src(render3d_st, vs, defines, false), r3d_shader_src(render3d_st, fs, defines, true), vs, fs, `{render3d_st.r3d_global_defs}{defines}`)
|
||||
let p = gpu_program(render3d_st, vs, fs, `{render3d_st.r3d_global_defs}{defines}`)
|
||||
if p == 0 { print(`r3d: program failed: {vs} + {fs}`) }
|
||||
return p
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue