several fixes after ages
This commit is contained in:
parent
ee178645bf
commit
7ae7b7507a
7 changed files with 33 additions and 5 deletions
|
|
@ -104,7 +104,7 @@ int main(int argc, char** argv){
|
|||
GSVector3 pos = {0, 1, 0};
|
||||
GSVector3 sz = {1, 1, 1};
|
||||
|
||||
mdl = GSModelOpen(engine, "game:/mdl/tetopear.gsm");
|
||||
mdl = GSModelOpen(engine, "game:/mdl/crate.gsm");
|
||||
|
||||
for(i = 0; i < sizeof(obj) / sizeof(obj[0]); i++){
|
||||
obj[i] = GSPhysicsCreateSphere(GSServerGetPhysics(GSEngineGetServer(engine)), 1, 0.5);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ uniform sampler2D shadow_map2;
|
|||
uniform sampler2D current_texture;
|
||||
uniform float enable_lighting;
|
||||
uniform float enable_texture;
|
||||
uniform float enable_shadow;
|
||||
uniform vec3 camera;
|
||||
|
||||
vec4 PhongShading(void)
|
||||
|
|
@ -83,7 +84,11 @@ float ShadowCoef(void){
|
|||
void main(void){
|
||||
vec4 c = PhongShading();
|
||||
vec4 ambient = gl_LightSource[0].ambient;
|
||||
float shadow_coef = ShadowCoef();
|
||||
float shadow_coef = 1.0;
|
||||
|
||||
if(enable_shadow >= 0.5){
|
||||
shadow_coef = ShadowCoef();
|
||||
}
|
||||
|
||||
if(enable_texture >= 0.5){
|
||||
c = c * texture2D(current_texture, gl_TexCoord[0].st);
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ GSDECL void GSGLShadowDeinit(GSGL gl);
|
|||
GSDECL void GSGLShadowDisable(GSGL gl);
|
||||
GSDECL void GSGLShadowEnable(GSGL gl);
|
||||
GSDECL int GSGLShadowCascadeSteps(GSGL gl);
|
||||
GSDECL void GSGLShadowRender(GSGL gl, int toggle);
|
||||
|
||||
/* gl.c */
|
||||
GSDECL GSGL GSGLCreate(GSClient client);
|
||||
|
|
|
|||
|
|
@ -212,6 +212,7 @@ struct _GSGL {
|
|||
GSNumber frustum_clip[16];
|
||||
|
||||
GSBool bold;
|
||||
GSBool shadow;
|
||||
};
|
||||
|
||||
struct _GSSkyBox {
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ void GSClientStep(GSClient client) {
|
|||
|
||||
GSGLTextBold(client->gl, 0);
|
||||
|
||||
#ifdef SHADOW
|
||||
if(GSGLShadowBegin(client->gl)) {
|
||||
int c;
|
||||
for(c = 0; c < GSGLShadowCascadeSteps(client->gl); c++) {
|
||||
|
|
@ -141,12 +142,17 @@ void GSClientStep(GSClient client) {
|
|||
}
|
||||
GSGLShadowApply(client->gl);
|
||||
}
|
||||
#else
|
||||
GSGLShadowRender(client->gl, 0);
|
||||
#endif
|
||||
|
||||
if(client->skybox_enabled) {
|
||||
if(client->skybox != NULL) GSSkyBoxDraw(client->skybox);
|
||||
}
|
||||
scene(client);
|
||||
#ifdef SHADOW
|
||||
GSGLShadowEnd(client->gl);
|
||||
#endif
|
||||
|
||||
GSVersionGet(&ver);
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ void GSGLShadowInit(GSGL gl) {
|
|||
glUniform1i(glGetUniformLocation(gl->shadow_shader, "current_texture"), 0);
|
||||
glUniform1f(glGetUniformLocation(gl->shadow_shader, "enable_lighting"), 1);
|
||||
glUniform1f(glGetUniformLocation(gl->shadow_shader, "enable_texture"), 0);
|
||||
glUniform1f(glGetUniformLocation(gl->shadow_shader, "enable_shadow"), 1);
|
||||
glUseProgram(0);
|
||||
|
||||
gl->shadow_use_shader = 1;
|
||||
|
|
@ -48,6 +49,8 @@ void GSGLShadowInit(GSGL gl) {
|
|||
|
||||
gl->shadow_use_shader = 0;
|
||||
}
|
||||
|
||||
gl->shadow = GSFalse;
|
||||
}
|
||||
|
||||
GSBool GSGLShadowBegin(GSGL gl) {
|
||||
|
|
@ -207,6 +210,8 @@ void GSGLShadowDisable(GSGL gl) {
|
|||
}
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
|
||||
gl->shadow = GSFalse;
|
||||
}
|
||||
|
||||
void GSGLShadowEnable(GSGL gl) {
|
||||
|
|
@ -222,6 +227,16 @@ void GSGLShadowEnable(GSGL gl) {
|
|||
}
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
|
||||
gl->shadow = GSTrue;
|
||||
}
|
||||
|
||||
void GSGLShadowRender(GSGL gl, int toggle){
|
||||
if(gl->shadow_use_shader){
|
||||
if(!gl->shadow) glUseProgram(gl->shadow_shader);
|
||||
glUniform1f(glGetUniformLocation(gl->shadow_shader, "enable_shadow"), toggle);
|
||||
if(!gl->shadow) glUseProgram(0);
|
||||
}
|
||||
}
|
||||
|
||||
void GSGLShadowEnd(GSGL gl) {
|
||||
|
|
|
|||
|
|
@ -171,9 +171,9 @@ static void parse_obj(GSModel model, char* txt) {
|
|||
if(l < bud) l = bud;
|
||||
if(l < bbf) l = bbf;
|
||||
|
||||
model->bbox[0][0] = l;
|
||||
model->bbox[0][1] = l;
|
||||
model->bbox[0][2] = l;
|
||||
model->bbox[0][0] = -l * 2;
|
||||
model->bbox[0][1] = -l * 2;
|
||||
model->bbox[0][2] = -l * 2;
|
||||
|
||||
model->bbox[1][0] = -model->bbox[0][0];
|
||||
model->bbox[1][1] = -model->bbox[0][1];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue