From e2014cfd9298c584617cc18dfa8f74c1dd29f4fa Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 17 Aug 2021 12:58:39 +0200 Subject: fix opengl; update librw --- src/extras/custompipes_gl.cpp | 12 ++++++------ src/extras/screendroplets.cpp | 4 ++-- src/extras/shaders/leedsDefault.frag | 6 ++---- src/extras/shaders/leedsVehicle_mobile.frag | 8 +++----- src/extras/shaders/obj/leedsDefault_frag.inc | 6 ++---- src/extras/shaders/obj/leedsVehicle_mobile_frag.inc | 8 +++----- vendor/librw | 2 +- 7 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/extras/custompipes_gl.cpp b/src/extras/custompipes_gl.cpp index 47678fd1..0860d59e 100644 --- a/src/extras/custompipes_gl.cpp +++ b/src/extras/custompipes_gl.cpp @@ -41,7 +41,7 @@ static int32 u_emiss; static int32 u_colorscale; static int32 u_texMatrix; -static int32 u_fxparams; +static int32 u_shininess; static int32 u_skyTop; static int32 u_skyBot; @@ -98,7 +98,7 @@ uploadEnvMatrix(rw::Frame *frame) convMatrix(&invMtx, &invMat); RawMatrix::mult(&envMtx, &invMtx, &normal2texcoord_flipU); } - glUniformMatrix4fv(U(u_texMatrix), 1, GL_FALSE, (float*)&envMtx); + setUniform(u_texMatrix, &envMtx); } static void @@ -141,7 +141,7 @@ leedsVehicleRenderCB(rw::Atomic *atomic, rw::gl3::InstanceDataHeader *header) if(gGlassCarsCheat) coef = 1.0f; } - glUniform1f(U(u_fxparams), coef); + glUniform1f(U(u_shininess), coef); setMaterial(m->color, m->surfaceProps); @@ -226,7 +226,7 @@ leedsVehicleRenderCB_mobile(rw::Atomic *atomic, rw::gl3::InstanceDataHeader *hea if(gGlassCarsCheat) coef = 1.0f; } - glUniform1f(U(u_fxparams), coef); + glUniform1f(U(u_shininess), coef); setMaterial(m->color, m->surfaceProps); @@ -809,8 +809,8 @@ CustomPipeRegisterGL(void) u_emiss = rw::gl3::registerUniform("u_emiss"); u_colorscale = rw::gl3::registerUniform("u_colorscale"); - u_texMatrix = rw::gl3::registerUniform("u_texMatrix"); - u_fxparams = rw::gl3::registerUniform("u_fxparams"); + u_texMatrix = rw::gl3::registerUniform("u_texMatrix", rw::gl3::UNIFORM_MAT4); + u_shininess = rw::gl3::registerUniform("u_shininess"); u_skyTop = rw::gl3::registerUniform("u_skyTop"); u_skyBot = rw::gl3::registerUniform("u_skyBot"); diff --git a/src/extras/screendroplets.cpp b/src/extras/screendroplets.cpp index 2485386b..cc86808f 100644 --- a/src/extras/screendroplets.cpp +++ b/src/extras/screendroplets.cpp @@ -741,7 +741,7 @@ uint32 im2D_UV2_Vao; void openim2d_uv2(void) { - u_xform = rw::gl3::registerUniform("u_xform"); // this doesn't add a new one, so it's safe + u_xform = rw::gl3::registerUniform("u_xform", rw::gl3::UNIFORM_VEC4); // this doesn't add a new one, so it's safe glGenBuffers(1, &im2D_UV2_Ibo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, im2D_UV2_Ibo); @@ -803,7 +803,7 @@ RenderIndexedPrimitive_UV2(RwPrimitiveType primType, Im2DVertexUV2 *vertices, Rw setAttribPointers(im2d_UV2_attribDesc, 4); #endif - glUniform4fv(currentShader->uniformLocations[u_xform], 1, xform); + setUniform(u_xform, xform); flushCache(); glDrawElements(primTypeMap[primType], numIndices, diff --git a/src/extras/shaders/leedsDefault.frag b/src/extras/shaders/leedsDefault.frag index 3955e6a5..4284fb7a 100644 --- a/src/extras/shaders/leedsDefault.frag +++ b/src/extras/shaders/leedsDefault.frag @@ -1,11 +1,9 @@ uniform sampler2D tex0; uniform sampler2D tex1; -uniform float u_fxparams; +uniform float u_shininess; uniform vec4 u_colorscale; -#define shininess (u_fxparams) - FSIN vec4 v_color; FSIN vec2 v_tex0; #if defined(PASS_BLEND) || defined(PASS_ADD) @@ -23,7 +21,7 @@ main(void) vec4 color; #if defined(PASS_BLEND) || defined(PASS_ADD) vec4 pass2 = texture(tex1, vec2(v_tex1.x, 1.0-v_tex1.y)); - pass2.a *= shininess; + pass2.a *= u_shininess; pass2.rgb = mix(vec3(0.0, 0.0, 0.0), pass2.rgb, v_fog); // We simulate drawing this in two passes. diff --git a/src/extras/shaders/leedsVehicle_mobile.frag b/src/extras/shaders/leedsVehicle_mobile.frag index 467379dd..5c7a60b9 100644 --- a/src/extras/shaders/leedsVehicle_mobile.frag +++ b/src/extras/shaders/leedsVehicle_mobile.frag @@ -1,12 +1,10 @@ uniform sampler2D tex0; uniform sampler2D tex1; -uniform float u_fxparams; +uniform float u_shininess; uniform vec3 u_skyTop; uniform vec3 u_skyBot; -#define shininess (u_fxparams) - // matfx: // case 1 normal envmap // custom1 (4.0, 1.0, 1.0, coef) @@ -59,10 +57,10 @@ main(void) vec3 skyColour = mix(u_skyBot, u_skyTop, envtex.g); vec3 envOut = mix(envtex.rrr, skyColour, envtex.b); - float fresnel = mix(shininess, shininess * 2.0, v_NdotV); + float fresnel = mix(u_shininess, u_shininess * 2.0, v_NdotV); fresnel = pow(v_NdotV * preMult, power); fresnel = clamp(fresnel * postMult, 0.0, 1.0); - float reflectivity = v_lightingCont * mix(minRefl, maxRefl, fresnel)*shininess; + float reflectivity = v_lightingCont * mix(minRefl, maxRefl, fresnel)*u_shininess; float opacity = mix(minOpacity, maxOpacity, fresnel)*pass1.a; vec4 color = pass1 + vec4(reflectivity * envOut, 0.0); diff --git a/src/extras/shaders/obj/leedsDefault_frag.inc b/src/extras/shaders/obj/leedsDefault_frag.inc index 312a32a3..e00eb66c 100644 --- a/src/extras/shaders/obj/leedsDefault_frag.inc +++ b/src/extras/shaders/obj/leedsDefault_frag.inc @@ -2,11 +2,9 @@ const char *leedsDefault_frag_src = "uniform sampler2D tex0;\n" "uniform sampler2D tex1;\n" -"uniform float u_fxparams;\n" +"uniform float u_shininess;\n" "uniform vec4 u_colorscale;\n" -"#define shininess (u_fxparams)\n" - "FSIN vec4 v_color;\n" "FSIN vec2 v_tex0;\n" "#if defined(PASS_BLEND) || defined(PASS_ADD)\n" @@ -24,7 +22,7 @@ const char *leedsDefault_frag_src = " vec4 color;\n" "#if defined(PASS_BLEND) || defined(PASS_ADD)\n" " vec4 pass2 = texture(tex1, vec2(v_tex1.x, 1.0-v_tex1.y));\n" -" pass2.a *= shininess;\n" +" pass2.a *= u_shininess;\n" " pass2.rgb = mix(vec3(0.0, 0.0, 0.0), pass2.rgb, v_fog);\n" " // We simulate drawing this in two passes.\n" diff --git a/src/extras/shaders/obj/leedsVehicle_mobile_frag.inc b/src/extras/shaders/obj/leedsVehicle_mobile_frag.inc index 8098599c..a937c327 100644 --- a/src/extras/shaders/obj/leedsVehicle_mobile_frag.inc +++ b/src/extras/shaders/obj/leedsVehicle_mobile_frag.inc @@ -2,12 +2,10 @@ const char *leedsVehicle_mobile_frag_src = "uniform sampler2D tex0;\n" "uniform sampler2D tex1;\n" -"uniform float u_fxparams;\n" +"uniform float u_shininess;\n" "uniform vec3 u_skyTop;\n" "uniform vec3 u_skyBot;\n" -"#define shininess (u_fxparams)\n" - "// matfx:\n" "// case 1 normal envmap\n" "// custom1 (4.0, 1.0, 1.0, coef)\n" @@ -60,10 +58,10 @@ const char *leedsVehicle_mobile_frag_src = " vec3 skyColour = mix(u_skyBot, u_skyTop, envtex.g);\n" " vec3 envOut = mix(envtex.rrr, skyColour, envtex.b);\n" -" float fresnel = mix(shininess, shininess * 2.0, v_NdotV);\n" +" float fresnel = mix(u_shininess, u_shininess * 2.0, v_NdotV);\n" " fresnel = pow(v_NdotV * preMult, power);\n" " fresnel = clamp(fresnel * postMult, 0.0, 1.0);\n" -" float reflectivity = v_lightingCont * mix(minRefl, maxRefl, fresnel)*shininess;\n" +" float reflectivity = v_lightingCont * mix(minRefl, maxRefl, fresnel)*u_shininess;\n" " float opacity = mix(minOpacity, maxOpacity, fresnel)*pass1.a;\n" " vec4 color = pass1 + vec4(reflectivity * envOut, 0.0);\n" diff --git a/vendor/librw b/vendor/librw index 65c619b3..4c4b1990 160000 --- a/vendor/librw +++ b/vendor/librw @@ -1 +1 @@ -Subproject commit 65c619b3e7dcec6f5dbd05d3203b530d667ba90f +Subproject commit 4c4b199057e9570557cdf108d21795236a076755 -- cgit v1.2.3