mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2024-11-28 06:41:59 +00:00
added shader editor auto-completion and syntax hints
- shader editor: added the r_guiShaderEditHints CVar - shader editor: Ctrl+K/L to comment/uncomment the selected lines - shader editor: Ctrl+E opens the shader editor directly for the surface under the crosshair - shader/image explorers: added world surface filter
This commit is contained in:
parent
5b05e7a95d
commit
8063962ed6
10 changed files with 1265 additions and 25 deletions
|
@ -36,6 +36,8 @@ add: r_guiFontFile <string> (default: "") is the file path to the custom .ttf fo
|
|||
|
||||
add: r_guiFontHeight <7 to 48> (default: 24) is the custom font's height
|
||||
|
||||
add: r_guiShaderEditHints <0|1> enables shader editor hints (available keywords, syntax)
|
||||
|
||||
add: r_gpuPreference <0|1|2> (default: 0) sets the GPU selection preference
|
||||
0 - high performance (discrete graphics)
|
||||
1 - low power (integrated graphics)
|
||||
|
|
|
@ -415,7 +415,7 @@ static void ImGUI_ApplyTheme()
|
|||
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.24f);
|
||||
colors[ImGuiCol_FrameBg] = ImVec4(0.05f, 0.05f, 0.05f, 0.54f);
|
||||
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.19f, 0.19f, 0.19f, 0.54f);
|
||||
colors[ImGuiCol_FrameBgActive] = ImVec4(0.40f, 0.44f, 0.46f, 1.00f);
|
||||
colors[ImGuiCol_FrameBgActive] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f);
|
||||
colors[ImGuiCol_TitleBg] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
|
||||
colors[ImGuiCol_TitleBgActive] = ImVec4(0.12f, 0.12f, 0.12f, 1.00f);
|
||||
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
|
||||
|
@ -460,8 +460,8 @@ static void ImGUI_ApplyTheme()
|
|||
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(1.00f, 0.00f, 0.00f, 0.20f);
|
||||
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.00f, 0.00f, 0.10f, 0.35f);
|
||||
|
||||
const ImVec4 hover(0.49f, 0.75f, 0.75f, 0.35f);
|
||||
const ImVec4 active(0.49f, 1.00f, 1.00f, 0.55f);
|
||||
const ImVec4 hover(0.25f, 0.375f, 0.375f, 0.35f);
|
||||
const ImVec4 active(0.25f, 0.50f, 0.50f, 0.35f);
|
||||
colors[ImGuiCol_HeaderHovered] = hover;
|
||||
colors[ImGuiCol_HeaderActive] = active;
|
||||
colors[ImGuiCol_TabHovered] = hover;
|
||||
|
|
|
@ -381,6 +381,19 @@ int Cmd_ArgIndexFromOffset( int offset )
|
|||
}
|
||||
|
||||
|
||||
int Cmd_ContinuousArgIndexFromOffset( int offset )
|
||||
{
|
||||
int index = -1;
|
||||
for (int i = 0; i < cmd_argc; ++i) {
|
||||
const int start = cmd_argoffsets[i];
|
||||
if (offset >= start)
|
||||
index = i;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
const char* Cmd_Args()
|
||||
{
|
||||
return Cmd_ArgsFrom(1);
|
||||
|
|
|
@ -126,6 +126,16 @@ float Q_crandom( int *seed )
|
|||
return 2.0 * ( Q_random( seed ) - 0.5 );
|
||||
}
|
||||
|
||||
float lerp( float a, float b, float t )
|
||||
{
|
||||
return a * ( 1.0f - t ) + b * t;
|
||||
}
|
||||
|
||||
float clamp( float x, float minVal, float maxVal )
|
||||
{
|
||||
return min( max( x, minVal ), maxVal );
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -505,6 +505,14 @@ int Q_rand( int *seed );
|
|||
float Q_random( int *seed );
|
||||
float Q_crandom( int *seed );
|
||||
|
||||
float lerp( float a, float b, float t );
|
||||
float clamp( float x, float min, float max );
|
||||
|
||||
static ID_INLINE float saturate( float x )
|
||||
{
|
||||
return clamp(x, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
#define random() ((rand() & 0x7FFF) / ((float)0x8000))
|
||||
#define crandom() (2.0 * (((rand() & 0x7FFF) / ((float)0x7FFF)) - 0.5))
|
||||
|
||||
|
|
|
@ -416,6 +416,7 @@ const char* Cmd_ArgsFrom( int arg );
|
|||
qbool Cmd_ArgQuoted( int arg );
|
||||
int Cmd_ArgOffset( int arg ); // returns the offset into the Cmd_TokenizeString argument
|
||||
int Cmd_ArgIndexFromOffset( int offset ); // the argument is the offset into the Cmd_TokenizeString argument
|
||||
int Cmd_ContinuousArgIndexFromOffset( int offset );
|
||||
void Cmd_ArgvBuffer( int arg, char *buffer, int bufferLength );
|
||||
void Cmd_ArgsBuffer( char *buffer, int bufferLength );
|
||||
const char* Cmd_Cmd(); // note: this is NOT argv[0], it's the entire cmd as a raw string
|
||||
|
|
|
@ -1627,6 +1627,49 @@ qbool R_GetEntityToken( char* buffer, int size )
|
|||
}
|
||||
|
||||
|
||||
static void FixWorldSurfaceRefCounts()
|
||||
{
|
||||
for ( int s = 0; s < s_worldData.numsurfaces; s++ ) {
|
||||
shader_t* const shader = (shader_t*)s_worldData.surfaces[s].shader;
|
||||
shader->worldSurfaceRefCount++;
|
||||
}
|
||||
|
||||
for ( int s = 0; s < tr.numShaders; s++ ) {
|
||||
shader_t* newShader = tr.shaders[s];
|
||||
if ( newShader->worldSurfaceRefCount == 0 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( newShader->isSky ) {
|
||||
image_t** const boxes[2] = { (image_t**)newShader->sky.outerbox, (image_t**)newShader->sky.innerbox };
|
||||
for ( int b = 0; b < 2; ++b ) {
|
||||
image_t** const images = boxes[b];
|
||||
if ( images == NULL ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < 6; ++i ) {
|
||||
if ( images[i] != NULL ) {
|
||||
images[i]->worldSurfaceRefCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for ( int ss = 0; ss < newShader->numStages; ++ss ) {
|
||||
shaderStage_t* const newStage = newShader->stages[ss];
|
||||
const int numImages = max( newStage->bundle.numImageAnimations, 1 );
|
||||
for ( int i = 0; i < numImages; ++i ) {
|
||||
image_t* const image = newStage->bundle.image[i];
|
||||
if ( image != NULL ) {
|
||||
image->worldSurfaceRefCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// called directly from cgame
|
||||
|
||||
void RE_LoadWorldMap( const char* name )
|
||||
|
@ -1678,6 +1721,9 @@ void RE_LoadWorldMap( const char* name )
|
|||
R_LoadVisibility( &header->lumps[LUMP_VISIBILITY] );
|
||||
R_LoadEntities( &header->lumps[LUMP_ENTITIES] );
|
||||
R_LoadLightGrid( &header->lumps[LUMP_LIGHTGRID] );
|
||||
|
||||
FixWorldSurfaceRefCounts();
|
||||
|
||||
renderPipeline->ProcessWorld( s_worldData );
|
||||
|
||||
s_worldData.dataSize = (byte*)ri.Hunk_Alloc( 0, h_low ) - startMarker;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -61,6 +61,7 @@ cvar_t *r_shadingRate;
|
|||
cvar_t *r_guiFont;
|
||||
cvar_t *r_guiFontFile;
|
||||
cvar_t *r_guiFontHeight;
|
||||
cvar_t *r_guiShaderEditHints;
|
||||
cvar_t *r_novis;
|
||||
cvar_t *r_nocull;
|
||||
cvar_t *r_nocurves;
|
||||
|
@ -614,6 +615,10 @@ static const cvarTableItem_t r_cvars[] =
|
|||
&r_guiFontHeight, "r_guiFontHeight", "24", CVAR_ARCHIVE, CVART_INTEGER, "7", "48", "custom font height",
|
||||
"GUI font height", CVARCAT_GUI, "Height of the custom font", "", NULL
|
||||
},
|
||||
{
|
||||
&r_guiShaderEditHints, "r_guiShaderEditHints", "1", CVAR_ARCHIVE, CVART_BOOL, NULL, NULL, "enable shader editor hints",
|
||||
"GUI shader editor hints", CVARCAT_GUI, "Displays available keywords and syntax", "", NULL
|
||||
},
|
||||
|
||||
//
|
||||
// temporary variables that can change at any time
|
||||
|
|
|
@ -110,6 +110,7 @@ struct image_t {
|
|||
int numShaders; // number of shaders referencing this image
|
||||
int flags0; // flags requested to be 0 by at least 1 shader
|
||||
int flags1; // flags requested to be 1 by at least 1 shader
|
||||
int worldSurfaceRefCount;
|
||||
};
|
||||
|
||||
|
||||
|
@ -437,6 +438,8 @@ struct shader_t {
|
|||
qbool hasLightmapStage;
|
||||
qbool isFog;
|
||||
|
||||
int worldSurfaceRefCount;
|
||||
|
||||
pipeline_t pipelines[MAX_SHADER_STAGES];
|
||||
int numPipelines;
|
||||
|
||||
|
@ -1118,6 +1121,7 @@ extern cvar_t *r_shadingRate; // variable-rate shading (VRS) mode
|
|||
extern cvar_t *r_guiFont; // Dear ImGui font
|
||||
extern cvar_t *r_guiFontFile; // Dear ImGui font, custom .ttf
|
||||
extern cvar_t *r_guiFontHeight; // Dear ImGui font, custom height
|
||||
extern cvar_t *r_guiShaderEditHints; // displays available keywords and syntax in the shader editor
|
||||
extern cvar_t *r_fullbright; // avoid lightmap pass
|
||||
extern cvar_t *r_depthFade; // fades marked shaders based on depth
|
||||
extern cvar_t *r_dither; // enables dithering
|
||||
|
|
Loading…
Reference in a new issue