and though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here

...
 
......@@ -356,20 +356,10 @@ void Renderer::Render()
// For no obvious reason rendering non-buildings before buildings "fixes"
// some bugs, e.g. lack of textures on palms
// TODO: Investigate why some textures reset rasters after loading
for ( uint32_t id = 0; id < mNoOfVisibleEntities; id++ )
{
assert( mVisibleEntities[id] != nullptr );
// InMemoryFuncCall<void>( 0x4C9DA0, mVisibleEntities[id] );
if ( mVisibleEntities[id]->mType != 1 )
mVisibleEntities[id]->Render();
}
for ( uint32_t id = 0; id < mNoOfVisibleEntities; id++ )
{
assert( mVisibleEntities[id] != nullptr );
// InMemoryFuncCall<void>( 0x4C9DA0, mVisibleEntities[id] );
if ( mVisibleEntities[id]->mType == 1 )
mVisibleEntities[id]->Render();
mVisibleEntities[id]->Render();
}
// Render clouds
InMemoryFuncCall<void>( 0x53FC50 );
......
......@@ -75,7 +75,7 @@ rpGeometryList *GeometryListStreamRead( void *stream, rpGeometryList *geomList )
RpGeometry *RpGeometryStreamRead( void *stream )
{
RpGeometry * geometry;
RpGeometryChunkInfo geom;
RpGeometryChunkInfo geom{};
uint32_t version;
struct _rpGeometry_Rw_3_0_ext
......@@ -83,7 +83,7 @@ RpGeometry *RpGeometryStreamRead( void *stream )
float ambient;
float diffuse;
float specular;
} geom_ext;
} geom_ext{};
if ( !RwStreamFindChunk( stream, rwID_STRUCT, nullptr, &version ) )
return nullptr;
......
......@@ -72,7 +72,7 @@ RpMaterial *RpMaterialStreamRead( void *stream )
RpMaterial *RpMaterialCreate()
{
RpMaterial *material;
RwRGBA color;
RwRGBA color{};
material = static_cast<RpMaterial *>(
malloc( sizeof( RpMaterial ) + sizeof( BackendMaterialExt ) ) );
......
......@@ -107,9 +107,12 @@ void GenerateNormals( VertexDescPosColorUVNormals *verticles,
// normalize normals
for ( uint32_t i = 0; i < vertexCount; i++ )
{
assert( !( isnan( verticles[i].nx ) || isnan( verticles[i].ny ) ||
isnan( verticles[i].nx ) ) );
float length = sqrt( verticles[i].nx * verticles[i].nx +
verticles[i].ny * verticles[i].ny +
verticles[i].nz * verticles[i].nz );
assert( !isnan( length ) );
if ( length > 0.0f )
{
verticles[i].nx = verticles[i].nx / length;
......
......@@ -44,11 +44,11 @@ void main()
vec2 tc = v0.uv.xy * barycentrics.x + v1.uv.xy * barycentrics.y + v2.uv.xy * barycentrics.z;
vec4 res_color = color * unpackUnorm4x8(material.color);
if (material.txd_id > 0) {
if (material.txd_id >= 0) {
vec4 tex_color =texture(sampler2D(textures[material.txd_id], baseSampler), tc) * res_color;
if (tex_color.a < 0.9 && tex_color.a * prd.materialParams.a < 0.3)
ignoreIntersectionNV();
}
else if (res_color.a < 0.9 && res_color.a * prd.materialParams.a < 0.3)
ignoreIntersectionNV();
ignoreIntersectionNV();
}
......@@ -79,14 +79,14 @@ void main()
world_pos_prev.xy = world_pos_prev.xy/world_pos_prev.w * 0.5 + 0.5;
pay_load.motionVectors = vec4(world_pos_current.xy - world_pos_prev.xy, 0, 0);
pay_load.materialParams= vec4(1.0f, material.specular, 0.0f, 0.0f);
if (material.spec_id > 0){
if (material.spec_id >= 0){
vec4 spec_color = texture(sampler2D(textures[material.spec_id], baseSampler), tc);
pay_load.materialParams = spec_color;
}
if (material.txd_id > 0) {
if (material.txd_id >= 0) {
vec4 tex_color = texture(sampler2D(textures[material.txd_id], baseSampler), tc);
pay_load.albedo = tex_color * unpackUnorm4x8(material.color);
}
else
pay_load.albedo = vec4(unpackUnorm4x8(material.color));
pay_load.albedo = vec4(unpackUnorm4x8(material.color));
}
......@@ -43,11 +43,11 @@ void main()
vec2 tc = v0.uv.xy * barycentrics.x + v1.uv.xy * barycentrics.y + v2.uv.xy * barycentrics.z;
if (material.txd_id > 0) {
if (material.txd_id >= 0) {
vec4 tex_color =texture(sampler2D(textures[material.txd_id], baseSampler), tc);
if (tex_color.a < 0.5)
ignoreIntersectionNV();
}
else if (unpackUnorm4x8(material.color).a < 0.5)
ignoreIntersectionNV();
ignoreIntersectionNV();
}
......@@ -112,11 +112,11 @@ void main()
ndotl *= (shad_pld.hitDistance > 0 ? 1.0f: 0.0f);
}
vec3 lighting = vec3(ndotl) + sky_cfg.skyColor.rgb * 0.3f;
if (material.txd_id > 0) {
if (material.txd_id >= 0) {
vec4 tex_color = texture(sampler2D(textures[material.txd_id], baseSampler), tc);
pay_load.reflection_color = tex_color * unpackUnorm4x8(material.color);
}
else
pay_load.reflection_color = vec4(unpackUnorm4x8(material.color));
pay_load.reflection_color = vec4(unpackUnorm4x8(material.color));
pay_load.reflection_color.rgb *= lighting;
}
......@@ -43,11 +43,11 @@ void main()
vec2 tc = v0.uv.xy * barycentrics.x + v1.uv.xy * barycentrics.y + v2.uv.xy * barycentrics.z;
if (material.txd_id > 0) {
if (material.txd_id >= 0) {
vec4 tex_color =texture(sampler2D(textures[material.txd_id], baseSampler), tc);
if (tex_color.a < 0.5)
ignoreIntersectionNV();
}
else if (unpackUnorm4x8(material.color).a < 0.5)
ignoreIntersectionNV();
ignoreIntersectionNV();
}