Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / [SOLVED] Deleting shader problem.

Author
Message
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 6th Jun 2020 19:54 Edited at: 7th Jun 2020 12:32
When I add like a glass shader all is fine,but removing it,it leaves the original texture in a bit of a mess, as seen here:


when I add a Glass shader to the cube, then remove it. Only reloading the level makes it alright!

Edit changed video and made clearer example!
Hail to the king, baby!

The author of this post has marked a post as an answer.

Go to answer

janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 9th Jun 2020 19:04 Edited at: 9th Jun 2020 19:07
Hm, when I remove the use SP_Glass_RemoveObject() at my Glass Shader Demo, it seems it's doing the job just fine.

The environment Texture, left behind from the Glass shader after removing the effect, seems to be still there.
Maybe try updating the Objects image.
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 18th Jun 2020 15:11 Edited at: 18th Jun 2020 15:13
Doesnt work,also after straightening code out a tad, i get a similar error message to that of that shader lights I had!
the index array out of bounds but in the SP_glass this time
Hail to the king, baby!
SFSW
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 18th Jun 2020 18:21
You probably don't need to reload the entire level, just rebuild any object you unhook a shader from (handy to have those operations in functions). I would generally not recommend deleting/removing a shader from an object once it's already been bound if it involves a shader that has interdependencies with other shaders/settings/values. It can produce results like you observed and also potentially cause shader related crashes. For stability/safety, it's best to delete the object first then rebuild the object with its required base images to get it back to the state it was in the first 5 seconds of your video.

You could try singling out the shader you are using, unbind it from any other dependencies so it can operate entirely on its own, and then experiment with it to see if the behavior might change, but I think it would be much easier to simply rebuild any object that has its shader changed or removed.
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 18th Jun 2020 18:59 Edited at: 18th Jun 2020 19:00
!!!!!blimey!!!!!!
this is all I can think to reply!!
But ok it aint a problem if it all happens quick enough.
Which should do coz I am simply cloning from an array of assets!
Hail to the king, baby!
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 18th Jun 2020 19:11 Edited at: 18th Jun 2020 19:14
ok thanks,that worked! I set the shaders in test_level() only now,else it maps the wrong environment, but when calling test_level() I save the level, and on exit of testing reload the level!
Probably best it saves before a test anyhow!
Hail to the king, baby!
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 18th Jun 2020 19:55 Edited at: 18th Jun 2020 19:58
This post has been marked by the post author as the answer.
The video doesnt really explain what your doing so its hard to comment.

The problem looks like what Janbo said above.... Its quite likely that the glass shader environment map is still left in place at one of the texture stages (probably stage 1 - so with a stock shader it behaves as a lightmap). Are you absolutely sure you cleared out the objects texture stages? Just changing a shader doesnt reset all the textures at all the stages back to any default.

Try doing something like this when going back to a standard stock shader:

for i = 1 to 4
SetobjectImage(obj,0, i)
next i

It will clear out texture stages 1-4 and leave you with just a diffuse in stage 0.

I have a few apps which change shaders alot but dont have the problems. you do need to be in control of the images though.
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 19th Jun 2020 07:08
I actually wasnt doing any of that, will give it a go,it seems silly to save and load a whole level when editing one object!
Hail to the king, baby!
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 19th Jun 2020 12:56
Ok this seems to be the correct answer, to remove the shader then clear out the texture stages 1-4, tnx for the help,would've had no idea really,
Hail to the king, baby!
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 19th Jun 2020 16:06 Edited at: 19th Jun 2020 16:08
OK so like SFSW said SetObjectShader(ObjectID,0) to unbind the shader and reuse the old shader as you probably do need the same effect again as you are reloading the level anyway.
But just to be sure here... the SP_RemoveShader funktion does or doesn't work ? keep in mind it doesn't remove any images for the objects texture stages. (Bengismo maybe explained it better)
(not sure if I should iclude it into the funktion and keep trak of all assigned textures )
Else I would have too take a look again of course
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 19th Jun 2020 16:14 Edited at: 19th Jun 2020 16:37
yeh removing the shader works,i was just missing the step of flushing out the stages in the image!
I had an after_run function anyhow,so put it there like so:


of course I also had to put it in the places where I would delete an object that had a shader assigned to it within the engines Level editor,just before resetting all the objects values.


all is cool now..zero errors so forth
Hail to the king, baby!

Login to post a reply

Server time is: 2024-04-19 19:09:12
Your offset time is: 2024-04-19 19:09:12