mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-08 18:16:12 +00:00
[spline/bezier]Fix around vertex type flags.
This commit is contained in:
parent
d4a667397c
commit
453e274fbe
@ -760,7 +760,5 @@ void TessellationDataTransfer::CopyControlPoints(float *pos, float *tex, float *
|
|||||||
memcpy(col, Vec4f::FromRGBA(points[i]->color_32).AsArray(), 4 * sizeof(float));
|
memcpy(col, Vec4f::FromRGBA(points[i]->color_32).AsArray(), 4 * sizeof(float));
|
||||||
col += colStride;
|
col += colStride;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
memcpy(col, Vec4f::FromRGBA(points[0]->color_32).AsArray(), 4 * sizeof(float));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ std::string VertexShaderDesc(const ShaderID &id) {
|
|||||||
if (id.Bit(VS_BIT_SPLINE)) desc << "Spline ";
|
if (id.Bit(VS_BIT_SPLINE)) desc << "Spline ";
|
||||||
if (id.Bit(VS_BIT_HAS_COLOR_TESS)) desc << "TessC ";
|
if (id.Bit(VS_BIT_HAS_COLOR_TESS)) desc << "TessC ";
|
||||||
if (id.Bit(VS_BIT_HAS_TEXCOORD_TESS)) desc << "TessT ";
|
if (id.Bit(VS_BIT_HAS_TEXCOORD_TESS)) desc << "TessT ";
|
||||||
|
if (id.Bit(VS_BIT_HAS_NORMAL_TESS)) desc << "TessN ";
|
||||||
if (id.Bit(VS_BIT_NORM_REVERSE_TESS)) desc << "TessRevN ";
|
if (id.Bit(VS_BIT_NORM_REVERSE_TESS)) desc << "TessRevN ";
|
||||||
|
|
||||||
return desc.str();
|
return desc.str();
|
||||||
@ -73,6 +74,7 @@ void ComputeVertexShaderID(ShaderID *id_out, u32 vertType, bool useHWTransform)
|
|||||||
bool doSpline = gstate_c.spline;
|
bool doSpline = gstate_c.spline;
|
||||||
bool hasColorTess = (gstate.vertType & GE_VTYPE_COL_MASK) != 0 && (doBezier || doSpline);
|
bool hasColorTess = (gstate.vertType & GE_VTYPE_COL_MASK) != 0 && (doBezier || doSpline);
|
||||||
bool hasTexcoordTess = (gstate.vertType & GE_VTYPE_TC_MASK) != 0 && (doBezier || doSpline);
|
bool hasTexcoordTess = (gstate.vertType & GE_VTYPE_TC_MASK) != 0 && (doBezier || doSpline);
|
||||||
|
bool hasNormalTess = (gstate.vertType & GE_VTYPE_NRM_MASK) != 0 && (doBezier || doSpline);
|
||||||
|
|
||||||
bool enableFog = gstate.isFogEnabled() && !isModeThrough && !gstate.isModeClear();
|
bool enableFog = gstate.isFogEnabled() && !isModeThrough && !gstate.isModeClear();
|
||||||
bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled() && !isModeThrough;
|
bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled() && !isModeThrough;
|
||||||
@ -139,6 +141,7 @@ void ComputeVertexShaderID(ShaderID *id_out, u32 vertType, bool useHWTransform)
|
|||||||
id.SetBit(VS_BIT_SPLINE, doSpline);
|
id.SetBit(VS_BIT_SPLINE, doSpline);
|
||||||
id.SetBit(VS_BIT_HAS_COLOR_TESS, hasColorTess);
|
id.SetBit(VS_BIT_HAS_COLOR_TESS, hasColorTess);
|
||||||
id.SetBit(VS_BIT_HAS_TEXCOORD_TESS, hasTexcoordTess);
|
id.SetBit(VS_BIT_HAS_TEXCOORD_TESS, hasTexcoordTess);
|
||||||
|
id.SetBit(VS_BIT_HAS_NORMAL_TESS, hasNormalTess);
|
||||||
id.SetBit(VS_BIT_NORM_REVERSE_TESS, gstate.isPatchNormalsReversed());
|
id.SetBit(VS_BIT_NORM_REVERSE_TESS, gstate.isPatchNormalsReversed());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ enum {
|
|||||||
VS_BIT_HAS_COLOR_TESS = 12, // 1 bit
|
VS_BIT_HAS_COLOR_TESS = 12, // 1 bit
|
||||||
VS_BIT_HAS_TEXCOORD_TESS = 13, // 1 bit
|
VS_BIT_HAS_TEXCOORD_TESS = 13, // 1 bit
|
||||||
VS_BIT_NORM_REVERSE_TESS = 14, // 1 bit
|
VS_BIT_NORM_REVERSE_TESS = 14, // 1 bit
|
||||||
// 15 is free.
|
VS_BIT_HAS_NORMAL_TESS = 15, // 1 bit
|
||||||
VS_BIT_UVGEN_MODE = 16,
|
VS_BIT_UVGEN_MODE = 16,
|
||||||
VS_BIT_UVPROJ_MODE = 18, // 2, can overlap with LS0
|
VS_BIT_UVPROJ_MODE = 18, // 2, can overlap with LS0
|
||||||
VS_BIT_LS0 = 18, // 2
|
VS_BIT_LS0 = 18, // 2
|
||||||
|
@ -734,8 +734,6 @@ void TessellationDataTransferD3D11::SendDataToShader(const SimpleVertex *const *
|
|||||||
float *tex = (float *)(data + offsetof(TessData, uv));
|
float *tex = (float *)(data + offsetof(TessData, uv));
|
||||||
float *col = (float *)(data + offsetof(TessData, color));
|
float *col = (float *)(data + offsetof(TessData, color));
|
||||||
int stride = sizeof(TessData) / sizeof(float);
|
int stride = sizeof(TessData) / sizeof(float);
|
||||||
bool hasColor = (vertType & GE_VTYPE_COL_MASK) != 0;
|
|
||||||
bool hasTexCoord = (vertType & GE_VTYPE_TC_MASK) != 0;
|
|
||||||
|
|
||||||
CopyControlPoints(pos, tex, col, stride, stride, stride, points, size, vertType);
|
CopyControlPoints(pos, tex, col, stride, stride, stride, points, size, vertType);
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ void GenerateVertexShaderHLSL(const VShaderID &id, char *buffer, ShaderLanguage
|
|||||||
bool doSpline = id.Bit(VS_BIT_SPLINE);
|
bool doSpline = id.Bit(VS_BIT_SPLINE);
|
||||||
bool hasColorTess = id.Bit(VS_BIT_HAS_COLOR_TESS);
|
bool hasColorTess = id.Bit(VS_BIT_HAS_COLOR_TESS);
|
||||||
bool hasTexcoordTess = id.Bit(VS_BIT_HAS_TEXCOORD_TESS);
|
bool hasTexcoordTess = id.Bit(VS_BIT_HAS_TEXCOORD_TESS);
|
||||||
|
bool hasNormalTess = id.Bit(VS_BIT_HAS_NORMAL_TESS);
|
||||||
bool flipNormalTess = id.Bit(VS_BIT_NORM_REVERSE_TESS);
|
bool flipNormalTess = id.Bit(VS_BIT_NORM_REVERSE_TESS);
|
||||||
|
|
||||||
DoLightComputation doLight[4] = { LIGHT_OFF, LIGHT_OFF, LIGHT_OFF, LIGHT_OFF };
|
DoLightComputation doLight[4] = { LIGHT_OFF, LIGHT_OFF, LIGHT_OFF, LIGHT_OFF };
|
||||||
@ -300,11 +301,10 @@ void GenerateVertexShaderHLSL(const VShaderID &id, char *buffer, ShaderLanguage
|
|||||||
|
|
||||||
WRITE(p, "struct Tess {\n");
|
WRITE(p, "struct Tess {\n");
|
||||||
WRITE(p, " float3 pos;\n");
|
WRITE(p, " float3 pos;\n");
|
||||||
if (doTexture && hasTexcoord)
|
if (doTexture)
|
||||||
WRITE(p, " float2 tex;\n");
|
WRITE(p, " float2 tex;\n");
|
||||||
if (hasColor)
|
WRITE(p, " float4 col;\n");
|
||||||
WRITE(p, " float4 col;\n");
|
if (hasNormalTess)
|
||||||
if (hasNormal)
|
|
||||||
WRITE(p, " float3 nrm;\n");
|
WRITE(p, " float3 nrm;\n");
|
||||||
WRITE(p, "};\n");
|
WRITE(p, "};\n");
|
||||||
|
|
||||||
@ -331,9 +331,9 @@ void GenerateVertexShaderHLSL(const VShaderID &id, char *buffer, ShaderLanguage
|
|||||||
for (int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
WRITE(p, " index = (%i + v%s) * spline_num_points_u + (%i + u%s);\n", i, doBezier ? " * 3" : "", j, doBezier ? " * 3" : "");
|
WRITE(p, " index = (%i + v%s) * spline_num_points_u + (%i + u%s);\n", i, doBezier ? " * 3" : "", j, doBezier ? " * 3" : "");
|
||||||
WRITE(p, " _pos[%i] = tess_data[index].pos;\n", i * 4 + j);
|
WRITE(p, " _pos[%i] = tess_data[index].pos;\n", i * 4 + j);
|
||||||
if (doTexture && hasTexcoord && hasTexcoordTess)
|
if (doTexture && hasTexcoordTess)
|
||||||
WRITE(p, " _tex[%i] = tess_data[index].tex;\n", i * 4 + j);
|
WRITE(p, " _tex[%i] = tess_data[index].tex;\n", i * 4 + j);
|
||||||
if (hasColor && hasColorTess)
|
if (hasColorTess)
|
||||||
WRITE(p, " _col[%i] = tess_data[index].col;\n", i * 4 + j);
|
WRITE(p, " _col[%i] = tess_data[index].col;\n", i * 4 + j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -350,19 +350,17 @@ void GenerateVertexShaderHLSL(const VShaderID &id, char *buffer, ShaderLanguage
|
|||||||
|
|
||||||
// Tessellate
|
// Tessellate
|
||||||
WRITE(p, " tess.pos = tess_sample(_pos, basis_u, basis_v);\n");
|
WRITE(p, " tess.pos = tess_sample(_pos, basis_u, basis_v);\n");
|
||||||
if (doTexture && hasTexcoord) {
|
if (doTexture) {
|
||||||
if (hasTexcoordTess)
|
if (hasTexcoordTess)
|
||||||
WRITE(p, " tess.tex = tess_sample(_tex, basis_u, basis_v);\n");
|
WRITE(p, " tess.tex = tess_sample(_tex, basis_u, basis_v);\n");
|
||||||
else
|
else
|
||||||
WRITE(p, " tess.tex = In.normal.xy + float2(patch_pos);\n");
|
WRITE(p, " tess.tex = In.normal.xy + float2(patch_pos);\n");
|
||||||
}
|
}
|
||||||
if (hasColor) {
|
if (hasColorTess)
|
||||||
if (hasColorTess)
|
WRITE(p, " tess.col = tess_sample(_col, basis_u, basis_v);\n");
|
||||||
WRITE(p, " tess.col = tess_sample(_col, basis_u, basis_v);\n");
|
else
|
||||||
else
|
WRITE(p, " tess.col = u_matambientalpha;\n");
|
||||||
WRITE(p, " tess.col = tess_data[0].col;\n");
|
if (hasNormalTess) {
|
||||||
}
|
|
||||||
if (hasNormal) {
|
|
||||||
// Derivatives as weight coefficients
|
// Derivatives as weight coefficients
|
||||||
WRITE(p, " float4 deriv_u = tess_weights_u[vertex_pos.x].deriv;\n");
|
WRITE(p, " float4 deriv_u = tess_weights_u[vertex_pos.x].deriv;\n");
|
||||||
WRITE(p, " float4 deriv_v = tess_weights_v[vertex_pos.y].deriv;\n");
|
WRITE(p, " float4 deriv_v = tess_weights_v[vertex_pos.y].deriv;\n");
|
||||||
@ -433,7 +431,7 @@ void GenerateVertexShaderHLSL(const VShaderID &id, char *buffer, ShaderLanguage
|
|||||||
WRITE(p, " tessellate(In, tess);\n");
|
WRITE(p, " tessellate(In, tess);\n");
|
||||||
|
|
||||||
WRITE(p, " float3 worldpos = mul(float4(tess.pos.xyz, 1.0), u_world);\n");
|
WRITE(p, " float3 worldpos = mul(float4(tess.pos.xyz, 1.0), u_world);\n");
|
||||||
if (hasNormal)
|
if (hasNormalTess)
|
||||||
WRITE(p, " float3 worldnormal = normalize(mul(float4(%stess.nrm, 0.0), u_world));\n", flipNormalTess ? "-" : "");
|
WRITE(p, " float3 worldnormal = normalize(mul(float4(%stess.nrm, 0.0), u_world));\n", flipNormalTess ? "-" : "");
|
||||||
else
|
else
|
||||||
WRITE(p, " float3 worldnormal = float3(0.0, 0.0, 1.0);\n");
|
WRITE(p, " float3 worldnormal = float3(0.0, 0.0, 1.0);\n");
|
||||||
@ -539,6 +537,7 @@ void GenerateVertexShaderHLSL(const VShaderID &id, char *buffer, ShaderLanguage
|
|||||||
const char *diffuseStr = (matUpdate & 2) && hasColor ? "In.color0.rgb" : "u_matdiffuse";
|
const char *diffuseStr = (matUpdate & 2) && hasColor ? "In.color0.rgb" : "u_matdiffuse";
|
||||||
const char *specularStr = (matUpdate & 4) && hasColor ? "In.color0.rgb" : "u_matspecular.rgb";
|
const char *specularStr = (matUpdate & 4) && hasColor ? "In.color0.rgb" : "u_matspecular.rgb";
|
||||||
if (doBezier || doSpline) {
|
if (doBezier || doSpline) {
|
||||||
|
// TODO: Probably, should use hasColorTess but FF4 has a problem with drawing the background.
|
||||||
ambientStr = (matUpdate & 1) && hasColor ? "tess.col" : "u_matambientalpha";
|
ambientStr = (matUpdate & 1) && hasColor ? "tess.col" : "u_matambientalpha";
|
||||||
diffuseStr = (matUpdate & 2) && hasColor ? "tess.col.rgb" : "u_matdiffuse";
|
diffuseStr = (matUpdate & 2) && hasColor ? "tess.col.rgb" : "u_matdiffuse";
|
||||||
specularStr = (matUpdate & 4) && hasColor ? "tess.col.rgb" : "u_matspecular.rgb";
|
specularStr = (matUpdate & 4) && hasColor ? "tess.col.rgb" : "u_matspecular.rgb";
|
||||||
@ -694,10 +693,7 @@ void GenerateVertexShaderHLSL(const VShaderID &id, char *buffer, ShaderLanguage
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (hasTexcoord) {
|
if (hasTexcoord) {
|
||||||
if (doBezier || doSpline)
|
WRITE(p, " Out.v_texcoord = float3(In.texcoord.xy * u_uvscaleoffset.xy + u_uvscaleoffset.zw, 0.0);\n");
|
||||||
WRITE(p, " Out.v_texcoord = float3(tess.tex.xy * u_uvscaleoffset.xy + u_uvscaleoffset.zw, 0.0);\n");
|
|
||||||
else
|
|
||||||
WRITE(p, " Out.v_texcoord = float3(In.texcoord.xy * u_uvscaleoffset.xy + u_uvscaleoffset.zw, 0.0);\n");
|
|
||||||
} else {
|
} else {
|
||||||
WRITE(p, " Out.v_texcoord = float3(u_uvscaleoffset.zw, 0.0);\n");
|
WRITE(p, " Out.v_texcoord = float3(u_uvscaleoffset.zw, 0.0);\n");
|
||||||
}
|
}
|
||||||
|
@ -659,11 +659,10 @@ bool DrawEngineGLES::IsCodePtrVertexDecoder(const u8 *ptr) const {
|
|||||||
void TessellationDataTransferGLES::SendDataToShader(const SimpleVertex *const *points, int size, u32 vertType, const Weight2D &weights) {
|
void TessellationDataTransferGLES::SendDataToShader(const SimpleVertex *const *points, int size, u32 vertType, const Weight2D &weights) {
|
||||||
bool hasColor = (vertType & GE_VTYPE_COL_MASK) != 0;
|
bool hasColor = (vertType & GE_VTYPE_COL_MASK) != 0;
|
||||||
bool hasTexCoord = (vertType & GE_VTYPE_TC_MASK) != 0;
|
bool hasTexCoord = (vertType & GE_VTYPE_TC_MASK) != 0;
|
||||||
int sizeColor = hasColor ? size : 1;
|
|
||||||
|
|
||||||
float *pos = new float[size * 4];
|
float *pos = new float[size * 4];
|
||||||
float *tex = hasTexCoord ? new float[size * 4] : nullptr;
|
float *tex = hasTexCoord ? new float[size * 4] : nullptr;
|
||||||
float *col = new float[sizeColor * 4];
|
float *col = hasColor ? new float[size * 4] : nullptr;
|
||||||
int stride = 4;
|
int stride = 4;
|
||||||
|
|
||||||
CopyControlPoints(pos, tex, col, stride, stride, stride, points, size, vertType);
|
CopyControlPoints(pos, tex, col, stride, stride, stride, points, size, vertType);
|
||||||
@ -683,7 +682,8 @@ void TessellationDataTransferGLES::SendDataToShader(const SimpleVertex *const *p
|
|||||||
if (hasTexCoord)
|
if (hasTexCoord)
|
||||||
renderManager_->TextureSubImage(data_tex[0], 0, 0, 1, size, 1, GL_RGBA, GL_FLOAT, (u8 *)tex, GLRAllocType::NEW);
|
renderManager_->TextureSubImage(data_tex[0], 0, 0, 1, size, 1, GL_RGBA, GL_FLOAT, (u8 *)tex, GLRAllocType::NEW);
|
||||||
// Color
|
// Color
|
||||||
renderManager_->TextureSubImage(data_tex[0], 0, 0, 2, sizeColor, 1, GL_RGBA, GL_FLOAT, (u8 *)col, GLRAllocType::NEW);
|
if (hasColor)
|
||||||
|
renderManager_->TextureSubImage(data_tex[0], 0, 0, 2, size, 1, GL_RGBA, GL_FLOAT, (u8 *)col, GLRAllocType::NEW);
|
||||||
|
|
||||||
// Weight U
|
// Weight U
|
||||||
if (data_tex[1])
|
if (data_tex[1])
|
||||||
@ -700,7 +700,6 @@ void TessellationDataTransferGLES::SendDataToShader(const SimpleVertex *const *p
|
|||||||
renderManager_->TextureImage(data_tex[2], 0, weights.size_v * 2, 1, GL_RGBA32F, GL_RGBA, GL_FLOAT, (uint8_t *)weights.v, GLRAllocType::NONE, false);
|
renderManager_->TextureImage(data_tex[2], 0, weights.size_v * 2, 1, GL_RGBA32F, GL_RGBA, GL_FLOAT, (uint8_t *)weights.v, GLRAllocType::NONE, false);
|
||||||
renderManager_->FinalizeTexture(data_tex[2], 0, false);
|
renderManager_->FinalizeTexture(data_tex[2], 0, false);
|
||||||
renderManager_->BindTexture(TEX_SLOT_SPLINE_WEIGHTS_V, data_tex[2]);
|
renderManager_->BindTexture(TEX_SLOT_SPLINE_WEIGHTS_V, data_tex[2]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TessellationDataTransferGLES::EndFrame() {
|
void TessellationDataTransferGLES::EndFrame() {
|
||||||
|
@ -193,6 +193,7 @@ void GenerateVertexShader(const VShaderID &id, char *buffer, uint32_t *attrMask,
|
|||||||
bool doSpline = id.Bit(VS_BIT_SPLINE);
|
bool doSpline = id.Bit(VS_BIT_SPLINE);
|
||||||
bool hasColorTess = id.Bit(VS_BIT_HAS_COLOR_TESS);
|
bool hasColorTess = id.Bit(VS_BIT_HAS_COLOR_TESS);
|
||||||
bool hasTexcoordTess = id.Bit(VS_BIT_HAS_TEXCOORD_TESS);
|
bool hasTexcoordTess = id.Bit(VS_BIT_HAS_TEXCOORD_TESS);
|
||||||
|
bool hasNormalTess = id.Bit(VS_BIT_HAS_NORMAL_TESS);
|
||||||
bool flipNormalTess = id.Bit(VS_BIT_NORM_REVERSE_TESS);
|
bool flipNormalTess = id.Bit(VS_BIT_NORM_REVERSE_TESS);
|
||||||
|
|
||||||
const char *shading = "";
|
const char *shading = "";
|
||||||
@ -403,11 +404,10 @@ void GenerateVertexShader(const VShaderID &id, char *buffer, uint32_t *attrMask,
|
|||||||
|
|
||||||
WRITE(p, "struct Tess {\n");
|
WRITE(p, "struct Tess {\n");
|
||||||
WRITE(p, " vec3 pos;\n");
|
WRITE(p, " vec3 pos;\n");
|
||||||
if (doTexture && hasTexcoord)
|
if (doTexture)
|
||||||
WRITE(p, " vec2 tex;\n");
|
WRITE(p, " vec2 tex;\n");
|
||||||
if (hasColor)
|
WRITE(p, " vec4 col;\n");
|
||||||
WRITE(p, " vec4 col;\n");
|
if (hasNormalTess)
|
||||||
if (hasNormal)
|
|
||||||
WRITE(p, " vec3 nrm;\n");
|
WRITE(p, " vec3 nrm;\n");
|
||||||
WRITE(p, "};\n");
|
WRITE(p, "};\n");
|
||||||
|
|
||||||
@ -432,9 +432,9 @@ void GenerateVertexShader(const VShaderID &id, char *buffer, uint32_t *attrMask,
|
|||||||
WRITE(p, " for (int j = 0; j < 4; j++) {\n");
|
WRITE(p, " for (int j = 0; j < 4; j++) {\n");
|
||||||
WRITE(p, " int index = (i + v%s) * spline_num_points_u + (j + u%s);\n", doBezier ? " * 3" : "", doBezier ? " * 3" : "");
|
WRITE(p, " int index = (i + v%s) * spline_num_points_u + (j + u%s);\n", doBezier ? " * 3" : "", doBezier ? " * 3" : "");
|
||||||
WRITE(p, " _pos[i * 4 + j] = %s(u_tess_points, ivec2(index, 0), 0).xyz;\n", texelFetch);
|
WRITE(p, " _pos[i * 4 + j] = %s(u_tess_points, ivec2(index, 0), 0).xyz;\n", texelFetch);
|
||||||
if (doTexture && hasTexcoord && hasTexcoordTess)
|
if (doTexture && hasTexcoordTess)
|
||||||
WRITE(p, " _tex[i * 4 + j] = %s(u_tess_points, ivec2(index, 1), 0).xy;\n", texelFetch);
|
WRITE(p, " _tex[i * 4 + j] = %s(u_tess_points, ivec2(index, 1), 0).xy;\n", texelFetch);
|
||||||
if (hasColor && hasColorTess)
|
if (hasColorTess)
|
||||||
WRITE(p, " _col[i * 4 + j] = %s(u_tess_points, ivec2(index, 2), 0).rgba;\n", texelFetch);
|
WRITE(p, " _col[i * 4 + j] = %s(u_tess_points, ivec2(index, 2), 0).rgba;\n", texelFetch);
|
||||||
WRITE(p, " }\n");
|
WRITE(p, " }\n");
|
||||||
WRITE(p, " }\n");
|
WRITE(p, " }\n");
|
||||||
@ -451,19 +451,17 @@ void GenerateVertexShader(const VShaderID &id, char *buffer, uint32_t *attrMask,
|
|||||||
|
|
||||||
// Tessellate
|
// Tessellate
|
||||||
WRITE(p, " tess.pos = tess_sample(_pos, basis_u, basis_v);\n");
|
WRITE(p, " tess.pos = tess_sample(_pos, basis_u, basis_v);\n");
|
||||||
if (doTexture && hasTexcoord) {
|
if (doTexture) {
|
||||||
if (hasTexcoordTess)
|
if (hasTexcoordTess)
|
||||||
WRITE(p, " tess.tex = tess_sample(_tex, basis_u, basis_v);\n");
|
WRITE(p, " tess.tex = tess_sample(_tex, basis_u, basis_v);\n");
|
||||||
else
|
else
|
||||||
WRITE(p, " tess.tex = normal.xy + vec2(patch_pos);\n");
|
WRITE(p, " tess.tex = normal.xy + vec2(patch_pos);\n");
|
||||||
}
|
}
|
||||||
if (hasColor) {
|
if (hasColorTess)
|
||||||
if (hasColorTess)
|
WRITE(p, " tess.col = tess_sample(_col, basis_u, basis_v);\n");
|
||||||
WRITE(p, " tess.col = tess_sample(_col, basis_u, basis_v);\n");
|
else
|
||||||
else
|
WRITE(p, " tess.col = u_matambientalpha;\n");
|
||||||
WRITE(p, " tess.col = %s(u_tess_points, ivec2(0, 2), 0).rgba;\n", texelFetch);
|
if (hasNormalTess) {
|
||||||
}
|
|
||||||
if (hasNormal) {
|
|
||||||
// Derivatives as weight coefficients
|
// Derivatives as weight coefficients
|
||||||
WRITE(p, " vec4 deriv_u = %s(u_tess_weights_u, %s, 0);\n", texelFetch, "ivec2(vertex_pos.x * 2 + 1, 0)");
|
WRITE(p, " vec4 deriv_u = %s(u_tess_weights_u, %s, 0);\n", texelFetch, "ivec2(vertex_pos.x * 2 + 1, 0)");
|
||||||
WRITE(p, " vec4 deriv_v = %s(u_tess_weights_v, %s, 0);\n", texelFetch, "ivec2(vertex_pos.y * 2 + 1, 0)");
|
WRITE(p, " vec4 deriv_v = %s(u_tess_weights_v, %s, 0);\n", texelFetch, "ivec2(vertex_pos.y * 2 + 1, 0)");
|
||||||
@ -523,7 +521,7 @@ void GenerateVertexShader(const VShaderID &id, char *buffer, uint32_t *attrMask,
|
|||||||
WRITE(p, " tessellate(tess);\n");
|
WRITE(p, " tessellate(tess);\n");
|
||||||
|
|
||||||
WRITE(p, " vec3 worldpos = (u_world * vec4(tess.pos.xyz, 1.0)).xyz;\n");
|
WRITE(p, " vec3 worldpos = (u_world * vec4(tess.pos.xyz, 1.0)).xyz;\n");
|
||||||
if (hasNormal) {
|
if (hasNormalTess) {
|
||||||
WRITE(p, " mediump vec3 worldnormal = normalize((u_world * vec4(%stess.nrm, 0.0)).xyz);\n", flipNormalTess ? "-" : "");
|
WRITE(p, " mediump vec3 worldnormal = normalize((u_world * vec4(%stess.nrm, 0.0)).xyz);\n", flipNormalTess ? "-" : "");
|
||||||
} else {
|
} else {
|
||||||
WRITE(p, " mediump vec3 worldnormal = vec3(0.0, 0.0, 1.0);\n");
|
WRITE(p, " mediump vec3 worldnormal = vec3(0.0, 0.0, 1.0);\n");
|
||||||
@ -628,6 +626,7 @@ void GenerateVertexShader(const VShaderID &id, char *buffer, uint32_t *attrMask,
|
|||||||
const char *diffuseStr = (matUpdate & 2) && hasColor ? "color0.rgb" : "u_matdiffuse";
|
const char *diffuseStr = (matUpdate & 2) && hasColor ? "color0.rgb" : "u_matdiffuse";
|
||||||
const char *specularStr = (matUpdate & 4) && hasColor ? "color0.rgb" : "u_matspecular.rgb";
|
const char *specularStr = (matUpdate & 4) && hasColor ? "color0.rgb" : "u_matspecular.rgb";
|
||||||
if (doBezier || doSpline) {
|
if (doBezier || doSpline) {
|
||||||
|
// TODO: Probably, should use hasColorTess but FF4 has a problem with drawing the background.
|
||||||
ambientStr = (matUpdate & 1) && hasColor ? "tess.col" : "u_matambientalpha";
|
ambientStr = (matUpdate & 1) && hasColor ? "tess.col" : "u_matambientalpha";
|
||||||
diffuseStr = (matUpdate & 2) && hasColor ? "tess.col.rgb" : "u_matdiffuse";
|
diffuseStr = (matUpdate & 2) && hasColor ? "tess.col.rgb" : "u_matdiffuse";
|
||||||
specularStr = (matUpdate & 4) && hasColor ? "tess.col.rgb" : "u_matspecular.rgb";
|
specularStr = (matUpdate & 4) && hasColor ? "tess.col.rgb" : "u_matspecular.rgb";
|
||||||
@ -775,8 +774,6 @@ void GenerateVertexShader(const VShaderID &id, char *buffer, uint32_t *attrMask,
|
|||||||
if (scaleUV) {
|
if (scaleUV) {
|
||||||
if (hasTexcoord) {
|
if (hasTexcoord) {
|
||||||
if (doBezier || doSpline)
|
if (doBezier || doSpline)
|
||||||
// TODO: Need fix?
|
|
||||||
// Fix to avoid temporarily texture animation bug with hardware tessellation.
|
|
||||||
WRITE(p, " v_texcoord = vec3(tess.tex * u_uvscaleoffset.xy + u_uvscaleoffset.zw, 0.0);\n");
|
WRITE(p, " v_texcoord = vec3(tess.tex * u_uvscaleoffset.xy + u_uvscaleoffset.zw, 0.0);\n");
|
||||||
else
|
else
|
||||||
WRITE(p, " v_texcoord = vec3(texcoord.xy * u_uvscaleoffset.xy, 0.0);\n");
|
WRITE(p, " v_texcoord = vec3(texcoord.xy * u_uvscaleoffset.xy, 0.0);\n");
|
||||||
@ -785,10 +782,7 @@ void GenerateVertexShader(const VShaderID &id, char *buffer, uint32_t *attrMask,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (hasTexcoord) {
|
if (hasTexcoord) {
|
||||||
if (doBezier || doSpline)
|
WRITE(p, " v_texcoord = vec3(texcoord.xy * u_uvscaleoffset.xy + u_uvscaleoffset.zw, 0.0);\n");
|
||||||
WRITE(p, " v_texcoord = vec3(tess.tex * u_uvscaleoffset.xy + u_uvscaleoffset.zw, 0.0);\n");
|
|
||||||
else
|
|
||||||
WRITE(p, " v_texcoord = vec3(texcoord.xy * u_uvscaleoffset.xy + u_uvscaleoffset.zw, 0.0);\n");
|
|
||||||
} else {
|
} else {
|
||||||
WRITE(p, " v_texcoord = vec3(u_uvscaleoffset.zw, 0.0);\n");
|
WRITE(p, " v_texcoord = vec3(u_uvscaleoffset.zw, 0.0);\n");
|
||||||
}
|
}
|
||||||
|
@ -133,6 +133,7 @@ bool GenerateVulkanGLSLVertexShader(const VShaderID &id, char *buffer) {
|
|||||||
bool doSpline = id.Bit(VS_BIT_SPLINE);
|
bool doSpline = id.Bit(VS_BIT_SPLINE);
|
||||||
bool hasColorTess = id.Bit(VS_BIT_HAS_COLOR_TESS);
|
bool hasColorTess = id.Bit(VS_BIT_HAS_COLOR_TESS);
|
||||||
bool hasTexcoordTess = id.Bit(VS_BIT_HAS_TEXCOORD_TESS);
|
bool hasTexcoordTess = id.Bit(VS_BIT_HAS_TEXCOORD_TESS);
|
||||||
|
bool hasNormalTess = id.Bit(VS_BIT_HAS_NORMAL_TESS);
|
||||||
bool flipNormalTess = id.Bit(VS_BIT_NORM_REVERSE_TESS);
|
bool flipNormalTess = id.Bit(VS_BIT_NORM_REVERSE_TESS);
|
||||||
|
|
||||||
WRITE(p, "\n");
|
WRITE(p, "\n");
|
||||||
@ -252,11 +253,10 @@ bool GenerateVulkanGLSLVertexShader(const VShaderID &id, char *buffer) {
|
|||||||
|
|
||||||
WRITE(p, "struct Tess {\n");
|
WRITE(p, "struct Tess {\n");
|
||||||
WRITE(p, " vec3 pos;\n");
|
WRITE(p, " vec3 pos;\n");
|
||||||
if (doTexture && hasTexcoord)
|
if (doTexture)
|
||||||
WRITE(p, " vec2 tex;\n");
|
WRITE(p, " vec2 tex;\n");
|
||||||
if (hasColor)
|
WRITE(p, " vec4 col;\n");
|
||||||
WRITE(p, " vec4 col;\n");
|
if (hasNormalTess)
|
||||||
if (hasNormal)
|
|
||||||
WRITE(p, " vec3 nrm;\n");
|
WRITE(p, " vec3 nrm;\n");
|
||||||
WRITE(p, "};\n");
|
WRITE(p, "};\n");
|
||||||
|
|
||||||
@ -282,9 +282,9 @@ bool GenerateVulkanGLSLVertexShader(const VShaderID &id, char *buffer) {
|
|||||||
WRITE(p, " for (int j = 0; j < 4; j++) {\n");
|
WRITE(p, " for (int j = 0; j < 4; j++) {\n");
|
||||||
WRITE(p, " int idx = (i + v%s) * spline_num_points_u + (j + u%s);\n", doBezier ? " * 3" : "", doBezier ? " * 3" : "");
|
WRITE(p, " int idx = (i + v%s) * spline_num_points_u + (j + u%s);\n", doBezier ? " * 3" : "", doBezier ? " * 3" : "");
|
||||||
WRITE(p, " _pos[i * 4 + j] = tess_data.data[idx].pos.xyz;\n");
|
WRITE(p, " _pos[i * 4 + j] = tess_data.data[idx].pos.xyz;\n");
|
||||||
if (doTexture && hasTexcoord && hasTexcoordTess)
|
if (doTexture && hasTexcoordTess)
|
||||||
WRITE(p, " _tex[i * 4 + j] = tess_data.data[idx].uv.xy;\n");
|
WRITE(p, " _tex[i * 4 + j] = tess_data.data[idx].uv.xy;\n");
|
||||||
if (hasColor && hasColorTess)
|
if (hasColorTess)
|
||||||
WRITE(p, " _col[i * 4 + j] = tess_data.data[idx].color;\n");
|
WRITE(p, " _col[i * 4 + j] = tess_data.data[idx].color;\n");
|
||||||
WRITE(p, " }\n");
|
WRITE(p, " }\n");
|
||||||
WRITE(p, " }\n");
|
WRITE(p, " }\n");
|
||||||
@ -301,19 +301,17 @@ bool GenerateVulkanGLSLVertexShader(const VShaderID &id, char *buffer) {
|
|||||||
|
|
||||||
// Tessellate
|
// Tessellate
|
||||||
WRITE(p, " tess.pos = tess_sample(_pos, basis_u, basis_v);\n");
|
WRITE(p, " tess.pos = tess_sample(_pos, basis_u, basis_v);\n");
|
||||||
if (doTexture && hasTexcoord) {
|
if (doTexture) {
|
||||||
if (hasTexcoordTess)
|
if (hasTexcoordTess)
|
||||||
WRITE(p, " tess.tex = tess_sample(_tex, basis_u, basis_v);\n");
|
WRITE(p, " tess.tex = tess_sample(_tex, basis_u, basis_v);\n");
|
||||||
else
|
else
|
||||||
WRITE(p, " tess.tex = normal.xy + vec2(patch_pos);\n");
|
WRITE(p, " tess.tex = normal.xy + vec2(patch_pos);\n");
|
||||||
}
|
}
|
||||||
if (hasColor) {
|
if (hasColorTess)
|
||||||
if (hasColorTess)
|
WRITE(p, " tess.col = tess_sample(_col, basis_u, basis_v);\n");
|
||||||
WRITE(p, " tess.col = tess_sample(_col, basis_u, basis_v);\n");
|
else
|
||||||
else
|
WRITE(p, " tess.col = base.matambientalpha;\n");
|
||||||
WRITE(p, " tess.col = tess_data.data[0].color;\n");
|
if (hasNormalTess) {
|
||||||
}
|
|
||||||
if (hasNormal) {
|
|
||||||
// Derivatives as weight coefficients
|
// Derivatives as weight coefficients
|
||||||
WRITE(p, " vec4 deriv_u = tess_weights_u.data[vertex_pos.x].deriv;\n");
|
WRITE(p, " vec4 deriv_u = tess_weights_u.data[vertex_pos.x].deriv;\n");
|
||||||
WRITE(p, " vec4 deriv_v = tess_weights_v.data[vertex_pos.y].deriv;\n");
|
WRITE(p, " vec4 deriv_v = tess_weights_v.data[vertex_pos.y].deriv;\n");
|
||||||
@ -373,7 +371,7 @@ bool GenerateVulkanGLSLVertexShader(const VShaderID &id, char *buffer) {
|
|||||||
WRITE(p, " tessellate(tess);\n");
|
WRITE(p, " tessellate(tess);\n");
|
||||||
|
|
||||||
WRITE(p, " vec3 worldpos = vec4(tess.pos.xyz, 1.0) * base.world_mtx;\n");
|
WRITE(p, " vec3 worldpos = vec4(tess.pos.xyz, 1.0) * base.world_mtx;\n");
|
||||||
if (hasNormal) {
|
if (hasNormalTess) {
|
||||||
WRITE(p, " mediump vec3 worldnormal = normalize(vec4(%stess.nrm, 0.0) * base.world_mtx);\n", flipNormalTess ? "-" : "");
|
WRITE(p, " mediump vec3 worldnormal = normalize(vec4(%stess.nrm, 0.0) * base.world_mtx);\n", flipNormalTess ? "-" : "");
|
||||||
} else {
|
} else {
|
||||||
WRITE(p, " mediump vec3 worldnormal = vec3(0.0, 0.0, 1.0);\n");
|
WRITE(p, " mediump vec3 worldnormal = vec3(0.0, 0.0, 1.0);\n");
|
||||||
@ -431,6 +429,7 @@ bool GenerateVulkanGLSLVertexShader(const VShaderID &id, char *buffer) {
|
|||||||
const char *diffuseStr = ((matUpdate & 2) && hasColor) ? "color0.rgb" : "light.matdiffuse";
|
const char *diffuseStr = ((matUpdate & 2) && hasColor) ? "color0.rgb" : "light.matdiffuse";
|
||||||
const char *specularStr = ((matUpdate & 4) && hasColor) ? "color0.rgb" : "light.matspecular.rgb";
|
const char *specularStr = ((matUpdate & 4) && hasColor) ? "color0.rgb" : "light.matspecular.rgb";
|
||||||
if (doBezier || doSpline) {
|
if (doBezier || doSpline) {
|
||||||
|
// TODO: Probably, should use hasColorTess but FF4 has a problem with drawing the background.
|
||||||
ambientStr = (matUpdate & 1) && hasColor ? "tess.col" : "base.matambientalpha";
|
ambientStr = (matUpdate & 1) && hasColor ? "tess.col" : "base.matambientalpha";
|
||||||
diffuseStr = (matUpdate & 2) && hasColor ? "tess.col.rgb" : "light.matdiffuse";
|
diffuseStr = (matUpdate & 2) && hasColor ? "tess.col.rgb" : "light.matdiffuse";
|
||||||
specularStr = (matUpdate & 4) && hasColor ? "tess.col.rgb" : "light.matspecular.rgb";
|
specularStr = (matUpdate & 4) && hasColor ? "tess.col.rgb" : "light.matspecular.rgb";
|
||||||
@ -583,10 +582,7 @@ bool GenerateVulkanGLSLVertexShader(const VShaderID &id, char *buffer) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (hasTexcoord) {
|
if (hasTexcoord) {
|
||||||
if (doBezier || doSpline)
|
WRITE(p, " v_texcoord = vec3(texcoord.xy * base.uvscaleoffset.xy + base.uvscaleoffset.zw, 0.0);\n");
|
||||||
WRITE(p, " v_texcoord = vec3(tess.tex.xy * base.uvscaleoffset.xy + base.uvscaleoffset.zw, 0.0);\n");
|
|
||||||
else
|
|
||||||
WRITE(p, " v_texcoord = vec3(texcoord.xy * base.uvscaleoffset.xy + base.uvscaleoffset.zw, 0.0);\n");
|
|
||||||
} else {
|
} else {
|
||||||
WRITE(p, " v_texcoord = vec3(base.uvscaleoffset.zw, 0.0);\n");
|
WRITE(p, " v_texcoord = vec3(base.uvscaleoffset.zw, 0.0);\n");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user