fix opengl; update librw

This commit is contained in:
aap 2021-08-17 12:58:39 +02:00
parent 2c4a3b5f5e
commit e2014cfd92
7 changed files with 19 additions and 27 deletions

View file

@ -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");

View file

@ -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,

View file

@ -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.

View file

@ -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);

View file

@ -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"

View file

@ -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"

2
vendor/librw vendored

@ -1 +1 @@
Subproject commit 65c619b3e7dcec6f5dbd05d3203b530d667ba90f
Subproject commit 4c4b199057e9570557cdf108d21795236a076755