-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate skybrush material #1299
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,6 +110,8 @@ struct Material { | |
bool enableNormalMapping; | ||
bool enablePhysicalMapping; | ||
|
||
shader_t* skyShader = nullptr; | ||
|
||
cullType_t cullType; | ||
|
||
bool usePolygonOffset = false; | ||
|
@@ -124,7 +126,8 @@ struct Material { | |
|
||
bool operator==( const Material& other ) { | ||
return program == other.program && stateBits == other.stateBits && vbo == other.vbo && ibo == other.ibo | ||
&& cullType == other.cullType && usePolygonOffset == other.usePolygonOffset; | ||
&& cullType == other.cullType && usePolygonOffset == other.usePolygonOffset | ||
&& ( skyShader == nullptr || other.skyShader == nullptr || skyShader == other.skyShader ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why can't it just be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC I did it because if one material has a skybox shader and the other doesn't, then they still can be considered the same. |
||
} | ||
|
||
void AddTexture( Texture* texture ) { | ||
|
@@ -220,6 +223,7 @@ class MaterialSystem { | |
std::vector<PortalSurface> portalBounds; | ||
uint32_t totalPortals; | ||
std::vector<shader_t*> skyShaders; | ||
bool renderSkyBrushDepth = false; | ||
|
||
std::vector<Material*> renderedMaterials; | ||
|
||
|
@@ -237,12 +241,15 @@ class MaterialSystem { | |
} | ||
}; | ||
|
||
MaterialPack materialPacks[3]{ | ||
MaterialPack materialPacks[4] { | ||
{ shaderSort_t::SS_DEPTH, shaderSort_t::SS_DEPTH }, | ||
{ shaderSort_t::SS_ENVIRONMENT_FOG, shaderSort_t::SS_OPAQUE }, | ||
{ shaderSort_t::SS_ENVIRONMENT_NOFOG, shaderSort_t::SS_POST_PROCESS } | ||
{ shaderSort_t::SS_ENVIRONMENT_NOFOG, shaderSort_t::SS_POST_PROCESS }, | ||
{ shaderSort_t::SS_BAD, shaderSort_t::SS_BAD } | ||
}; | ||
|
||
Material skyBrushMaterial; | ||
|
||
bool frameStart = false; | ||
|
||
void AddTexture( Texture* texture ); | ||
|
@@ -303,6 +310,7 @@ class MaterialSystem { | |
|
||
bool AddPortalSurface( uint32_t viewID, PortalSurface* portalSurfs ); | ||
|
||
void RenderMaterialPack( MaterialPack& materialPack, const uint32_t viewID ); | ||
void RenderMaterial( Material& material, const uint32_t viewID ); | ||
void UpdateFrameData(); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5432,6 +5432,13 @@ static void SetStagesRenderers() | |
false, false, | ||
}; | ||
break; | ||
case stageType_t::ST_SKYBRUSHMAP: | ||
stageRendererOptions = { | ||
&Render_materialPassThrough, | ||
&UpdateSurfaceDataGeneric3D, &BindShaderGeneric3D, &ProcessMaterialGeneric3D, | ||
false, false, | ||
}; | ||
break; | ||
case stageType_t::ST_SCREENMAP: | ||
stageRendererOptions = { | ||
&Render_screen, | ||
|
@@ -5806,6 +5813,22 @@ static shader_t *FinishShader() | |
numStages = MAX_SHADER_STAGES; | ||
GroupActiveStages(); | ||
|
||
if ( glConfig2.materialSystemAvailable && shader.isSky ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs a check that we don't overflow the stages array |
||
shaderStage_t* pStage = &stages[numStages]; | ||
|
||
pStage->active = true; | ||
|
||
pStage->type = stageType_t::ST_SKYBRUSHMAP; | ||
pStage->deformIndex = 0; | ||
pStage->stateBits = GLS_COLORMASK_BITS; | ||
pStage->rgbGen = colorGen_t::CGEN_IDENTITY; | ||
pStage->alphaGen = alphaGen_t::AGEN_IDENTITY; | ||
pStage->bundle[TB_COLORMAP].image[0] = tr.whiteImage; | ||
pStage->hasDepthFade = false; | ||
|
||
numStages++; | ||
} | ||
|
||
// set appropriate stage information | ||
for ( size_t stage = 0; stage < numStages; stage++ ) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not needed, it should be 0 to start with
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was breaking otherwise with portals. Maybe not and I put there just in case because it was breaking elsewhere, but either way doesn't matter now because this way of rendering the skybox seems infeasible. Well, maybe I'll actually keep the stenciled skybrush part to reset depth, I'll need to look at it again later.