Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Instructor
Original Poster
#1 Old 29th Sep 2014 at 10:46 PM Last edited by thesammy58 : 30th Sep 2014 at 12:37 PM.
Default Shadow Map Problem
Hi everyone. I'm currently working on my first custom clothing item; boxer briefs. I'm so close to finishing but now I've run into a last-minute problem.
While making the undies, I noticed that the clothing had a "shadow" layer in S4PE.

So I exported the shadow, made it fit the shape of the new undies in Paint.NET, then exported it as a DDS with "DXT5" and "Generate Mip Maps" on. The shadow looked great in CAS!

But not so great in live mode...

For some reason the shadow makes a bunch of blacks squares all around it when I exit CAS. Does anyone have any advice? Is there a special format I need to save the DDS image as?
Advertisement
Lab Assistant
#2 Old 30th Sep 2014 at 8:39 AM
I've got the same problem. Hope someone could reply and help.
Lab Assistant
#3 Old 30th Sep 2014 at 9:53 AM
How did you edit the shadow map? I posted details on how the shadow map works in the CASTools thread but I'll repost them here:


Quote: Originally posted by Me
Related to texturing issues, I spent some time figuring out the self shadowing map the other day, are there any tutorials for that yet? It's very easy to screw up the shadow map and think you've made a blank one when you haven't because in a properly formatted shadow map the green channel has a different 'zero' colour than the red/blue/alpha channels.

I believe this is a properly formatted blank shadow map:

http://www.myrespace.com/sims4/blank_shadows.dds

If you decompose the channels you'll see that the green channel is cleared to #a2a2a2 (or R:162, G:162, B:162) rather than 0 like the other channels. By maintaining the grey background on the green channel I've successfully added custom self shadowing to a few of my recolours too. I believe the self shadowing maps from multiple parts are composed together just like the diffuse maps, so if you want to keep the self shadowing while using multiple CAS parts together (like tops+ bottoms+ shoes) I believe you need to make your self shadow maps in the right way. Previously, I was just clearing the whole texture to white which would destroy the self shadows on other parts once they are composited together.

Apart from the grey background in the green channel the rules are easy -> white = no shadows, black is darkest shadows. you should use them wherever an item of clothing or hair would frequently cast a shadow on other parts of a mesh. Maxis uses them for hair casting a shadow on the face and skirts casting a shadow on legs for example.


Basically if you treat it as a standard greyscale texture you'll run into problems because your green channel will probably have black where it should have grey (#a2).
Ms. Byte (Deceased)
#4 Old 30th Sep 2014 at 11:26 AM
Also make sure you save the DDS with DXT5 compression and generate mipmaps.

Please do not PM me with mod, tutorial, or general modding questions or problems; post them in the thread for the mod or tutorial or post them in the appropriate forum.

Visit my blogs for other Sims content:
Online Sims - general mods for Sims 3
Offline Sims - adult mods for Sims 3 and Sims 4
Instructor
Original Poster
#5 Old 30th Sep 2014 at 12:17 PM Last edited by thesammy58 : 30th Sep 2014 at 1:00 PM.
Quote: Originally posted by MyreMylar
How did you edit the shadow map? I posted details on how the shadow map works in the CASTools thread but I'll repost them here:




Basically if you treat it as a standard greyscale texture you'll run into problems because your green channel will probably have black where it should have grey (#a2).

Hmm, I'm not sure I totally understand but I'll try tinkering with that. I think I know what you're getting at. Thanks for your help.
Also, to edit the shadow map, all I did was stretch it down to the size I needed. I knew something about that was a bit too easy...

Edit: I'm now thinking this has something to do with the way I'm saving the DDS image. I took the original EA underwear's shadow map, exported it, open it in Paint.NET, and saved it exactly how Cmar said. Even that had black squares all over it, too.

Edit #2: Fixed! I took what you said about white indicating no shadow in the texture, and filled the area around the grayscale texture with white. That eliminated the strange black squares. Thanks again for your help! Now I can finally get back on track.
Lab Assistant
#6 Old 30th Sep 2014 at 2:37 PM
Heh. Yeah that can work, though it is worth being cautious with this strategy in general because the shadow maps for multiple CAS parts are composited together by the game based on the 'transparent' areas of the shadow map. For example if you make the entirety of a shadow maps for a pair of socks white it'll clear out any artefacts on your socks but it will destroy the shadow maps on other CAS parts. Perhaps I explained it badly the first time.

Apparently decomposing an image into it's colour components isn't a core feature of paint.net but there is apparently a plugin available here:

http://forums.getpaint.net/index.php?showtopic=18811

that adds an 'Extract Channel' effect which may allow you to edit the green independently from the red, blue and alpha components/channels. Colours on a computer can be represented by three 'primary' Red, Green, Blue values and an amount of transparency. Game developers often use these separate channels in slightly weird way for rendering efficiency because you can effectively store four greyscale images in one RGBA texture. The specular map in Sims is a good example of this technique. I think for the shadow map they are possibly just using the green channel because this channel is usually the least compressed in dds (I believe this is because the human eye is better at picking up variation in green than red or blue perhaps due to our evolutionary origins, but I digress). The grey background means they can normalise all the separate textures around 1 to -1 add them up. Then I suspect they add 1 to the result and clamp everything above 1 to 1 so you end up with shadows being colours from black to mid-grey in the original textures and any area that has mid grey to white ends up having no effect. Under this method then if you have two shadow map textures; one with white on a certain area and another with black on the same area - then it would end up as an overall 0 in the compositing calculation and thus eventually the same as no shadows.

Anyway. Basically unless you edit the green channel separately you can't easily make a shadow map that matches the Maxis ones.

Does any of that make sense?
Instructor
Original Poster
#7 Old 30th Sep 2014 at 4:56 PM
Quote: Originally posted by MyreMylar
Heh. Yeah that can work, though it is worth being cautious with this strategy in general because the shadow maps for multiple CAS parts are composited together by the game based on the 'transparent' areas of the shadow map. For example if you make the entirety of a shadow maps for a pair of socks white it'll clear out any artefacts on your socks but it will destroy the shadow maps on other CAS parts. Perhaps I explained it badly the first time.

Apparently decomposing an image into it's colour components isn't a core feature of paint.net but there is apparently a plugin available here:

http://forums.getpaint.net/index.php?showtopic=18811

that adds an 'Extract Channel' effect which may allow you to edit the green independently from the red, blue and alpha components/channels. Colours on a computer can be represented by three 'primary' Red, Green, Blue values and an amount of transparency. Game developers often use these separate channels in slightly weird way for rendering efficiency because you can effectively store four greyscale images in one RGBA texture. The specular map in Sims is a good example of this technique. I think for the shadow map they are possibly just using the green channel because this channel is usually the least compressed in dds (I believe this is because the human eye is better at picking up variation in green than red or blue perhaps due to our evolutionary origins, but I digress). The grey background means they can normalise all the separate textures around 1 to -1 add them up. Then I suspect they add 1 to the result and clamp everything above 1 to 1 so you end up with shadows being colours from black to mid-grey in the original textures and any area that has mid grey to white ends up having no effect. Under this method then if you have two shadow map textures; one with white on a certain area and another with black on the same area - then it would end up as an overall 0 in the compositing calculation and thus eventually the same as no shadows.

Anyway. Basically unless you edit the green channel separately you can't easily make a shadow map that matches the Maxis ones.

Does any of that make sense?

I see now. So just giving it a white background could interfere with other shadows. I'm going to keep this in mind for any future clothing I might make. Who would have guessed one simple shadow could be so complicated.
For now the somewhat amateur strategy I used to make the shadow doesn't seem to be interfering with any other shirt/hair/etc shadows. (I don't feel like changing the shadows of 16 different recolors again, for the 5th time ) I will definitely be sure to check out that extension for PDN. I really appreciate your willingness to help dumbfounded-me on this. It's been a great learning experience.
Test Subject
#8 Old 1st Oct 2014 at 4:04 PM
Quote: Originally posted by MyreMylar
I posted details on how the shadow map works in the CASTools thread but I'll repost them here:

Basically if you treat it as a standard greyscale texture you'll run into problems because your green channel will probably have black where it should have grey (#a2).


Your blank shadow map is completely transparent in GIMP. I can't replicate grey in the green channel either, with only the green and alpha channels active it makes green tinted images, but they still have artifacts in game.

Am I missing something or is it not possible to modify shadow maps with GIMP?
Lab Assistant
#9 Old 1st Oct 2014 at 9:54 PM
Quote: Originally posted by Mateodon
Your blank shadow map is completely transparent in GIMP. I can't replicate grey in the green channel either, with only the green and alpha channels active it makes green tinted images, but they still have artifacts in game.

Am I missing something or is it not possible to modify shadow maps with GIMP?


Do you know about the Decompose option under Colors->Components->Decompose ?

Basically this produces a new image with the colour components as layers and then you can edit them to your hearts content before heading to Colors->Components->Compose to create a new final image.
Test Subject
#10 Old 2nd Oct 2014 at 12:48 AM
Quote: Originally posted by MyreMylar
Do you know about the Decompose option under Colors->Components->Decompose ?

Basically this produces a new image with the colour components as layers and then you can edit them to your hearts content before heading to Colors->Components->Compose to create a new final image.

Thank you!
Mad Poster
#11 Old 5th Oct 2014 at 12:34 AM
Okay, I can't get my head around this. From everything I have read here, my shadow file should be working but instead I get dark square blocks show up on my Sims legs.

When I examine the shadow file in photoshop though I can't see anything that correlates with them, not even on the green channel. I had the same issue with socks and gloves I have made in the past and all I did in those instances was move the height of the shadow!
The effect really is very subtle on this particular item and I could go without it but I would really like to be able to understand how this is supposed to work.

My deviantART, MTS Yearbook Origin ID = Alistu
Instructor
Original Poster
#12 Old 5th Oct 2014 at 9:44 PM
Quote: Originally posted by Menaceman44
Okay, I can't get my head around this. From everything I have read here, my shadow file should be working but instead I get dark square blocks show up on my Sims legs.

When I examine the shadow file in photoshop though I can't see anything that correlates with them, not even on the green channel. I had the same issue with socks and gloves I have made in the past and all I did in those instances was move the height of the shadow!
The effect really is very subtle on this particular item and I could go without it but I would really like to be able to understand how this is supposed to work.

You might have a slightly different problem from mine, since mine worked in CAS but didn't in Live Mode. I definitely don't have much advice on the subject, but I'll bump this thread to let others see this.
Lab Assistant
#13 Old 5th Oct 2014 at 11:50 PM
Same problem here, I'm making a pants recolour and there are jagged black squares around the top of the pants.
Instructor
#14 Old 6th Oct 2014 at 8:06 AM
Yep same for me too.

FifthAce2007

My Sims 2 creations are no longer supported. Regardless of what the individual post says, feel free to clone, recolour, chuck on a bonfire or mix in a blender! Just credit me/this site with the upload, and upload here only, thanks
Lab Assistant
#15 Old 6th Oct 2014 at 10:32 AM
I have this issue too. However, I just took away a section of the shadow from the channels including the alpha, re-saved it as a DXT5 DDS and used that for one creation. It looks perfectly fine in CAS, however I get the pixelation in live mode which doesn't appear when zoomed-in close to the sim, but becomes more apparent the further away you are from the sim. I did not expect to come across this issue because its just an edited shadowmap with parts removed, not added.

A tutorial with in-game and CAS pictures is really needed for this. Shadowing in TS4 is a lot different to TS3, and its going to take a while to understand how it properly works in order to edit and create new shadowmaps
Lab Assistant
#16 Old 6th Oct 2014 at 10:42 AM
Anyone having problems, feel free to link your packages with problems and I'll have a look when I have time.
Mad Poster
#17 Old 6th Oct 2014 at 11:15 PM
Quote: Originally posted by MyreMylar
Anyone having problems, feel free to link your packages with problems and I'll have a look when I have time.

Would you? That would be wonderful!
I've attached a zip file that contains the grey breifs pictured in my previous post.

The first two items I ever tried changing the shadow image of were a pair of socks (lowering the height) and a pair of gloves (removing a dip in the shadow) which are both accessories. These looked great in CAS but it was once I got in game that flickery black blocks would show up around the mesh seams, particularly when zoomed out.
This is the first time I have tried to edit the shadow of a "bottom" item and the square shadows show up in CAS as well as in game but they don't flicker around the mesh edges so I think they may be two seperate issues.
Attached files:
File Type: zip  GreyBriefs.zip (82.8 KB, 15 downloads) - View custom content

My deviantART, MTS Yearbook Origin ID = Alistu
Lab Assistant
#18 Old 7th Oct 2014 at 11:21 AM
Quote: Originally posted by Menaceman44
Would you? That would be wonderful!
I've attached a zip file that contains the grey breifs pictured in my previous post.

The first two items I ever tried changing the shadow image of were a pair of socks (lowering the height) and a pair of gloves (removing a dip in the shadow) which are both accessories. These looked great in CAS but it was once I got in game that flickery black blocks would show up around the mesh seams, particularly when zoomed out.
This is the first time I have tried to edit the shadow of a "bottom" item and the square shadows show up in CAS as well as in game but they don't flicker around the mesh edges so I think they may be two seperate issues.


Fixing the issues in what I'm calling the 'high mips' that show up in CAS was pretty easy - there were some junk pixels visible in the red, green and blue channels which were obscured by the alpha but still causing problems. Sadly fixing the issues that show up in the 'lower mips' seems to be harder. I'm guessing maxis has some special tool or script that creates their shadow map mips because if you open up a default one they look pretty abnormal as you go down the chain.... Hmm.

Anyway here's where I got to before running out of fiddling time:

http://www.myrespace.com/sims4/pant_shadows_fix.dds


I wonder if a larger area of white around the underpants would help generate better lower mips.
Mad Poster
#19 Old 7th Oct 2014 at 1:02 PM Last edited by Menaceman44 : 7th Oct 2014 at 2:28 PM.
Thanks for that. Looks great in CAS with your image but still no good in the actual game though.
I have absolutely NO idea how you identified the "junk pixels" in the first place though as I can't find anything that appears a different shade or tone or out of place on the file I sent you to begin with.
I'll try adding some more white to it and see what happens.

ETA: Adding a larger area of white around the shadow map seems to have solved the issue with flackering black bits when in the game and it looks great in CAS as well!
Thank you!

Now I just need to figure out how to identify and correct the problem pixels on my own for future projects. I went back to my own texture while testing out yours and increased the white area on that too. This got rid of the flickering as well but I COULD NOT get rid of the pixel mess on the legs. I could make it very, very faint but couldn't get rid of it totally yet your version has none of this mess at all.

My deviantART, MTS Yearbook Origin ID = Alistu
Lab Assistant
#20 Old 7th Oct 2014 at 2:59 PM
@MyreMylar, I just want to say a big thank you! I tried the extra white and it solved the issue in live mode. I selected the existing white areas in the RGB channels, and increased about 20px and it seems to have solved it. I would like to know what Maxis did differently to achieve the same result with less visible white though. The question is whether the increase in the white area will impact overlaying of shadowmaps.
Mad Poster
#21 Old 7th Oct 2014 at 3:02 PM
Quote: Originally posted by peacemaker IC
@MyreMylar, I just want to say a big thank you! I tried the extra white and it solved the issue in live mode. I selected the existing white areas in the RGB channels, and increased about 20px and it seems to have solved it. I would like to know what Maxis did differently to achieve the same result with less visible white though. The question is whether the increase in the white area will impact overlaying of shadowmaps.


The extra white doesn't appear to be affecting the overlaying of shadows in my game. Some of the Sims I tried them on had jackets that overhung the briefs slightly and they still cast shadows on the legs below the hem line fine.

My deviantART, MTS Yearbook Origin ID = Alistu
Lab Assistant
#22 Old 7th Oct 2014 at 3:20 PM
That's good to know Menaceman44. The items I have been testing aren't really suited for testing because of where the shadows are cast; they don't intersect any others. I am just happy knowing what the issue is and this hopefully being a solution. If its not, its on the right path to one. But all seems good. I can now feel comfortable continuing projects and making the custom shadowmaps that are needed for them.
Lab Assistant
#23 Old 7th Oct 2014 at 5:07 PM
Quote: Originally posted by Menaceman44
Now I just need to figure out how to identify and correct the problem pixels on my own for future projects. I went back to my own texture while testing out yours and increased the white area on that too. This got rid of the flickering as well but I COULD NOT get rid of the pixel mess on the legs. I could make it very, very faint but couldn't get rid of it totally yet your version has none of this mess at all.


I use GIMP which has a 'decompose' feature that splits an image's separate colour channels into four individual 'white to black' greyscale layers. I'm sure something similar is possible in photoshop too but don't know it off hand.

The most common problem I've seen with shadow maps is that something has been erased in the alpha channel (and is thus invisible in a normal image) but the image still contains data in one or all of the RGB channels. Also, the green channel's background is mid-grey rather than black which can also cause problems.

I suspect there shouldn't be too many overlapping problems with 'bottom' CAS parts in general anyway as that part of the sim tends not to have too many obvious shadows on it anyway and I think there must be some kind of layering solution in the composition function anyway similar to what goes on with the diffuse textures. Which is a long way of saying as long as the 'white edges' don't reach up all the way to the shoulders and face I don't think anyone will notice. Some of the lowest mips on the maxis underpants have almost the entire bottom half of the texture as white in the RGB channels.
Mad Poster
#24 Old 7th Oct 2014 at 9:14 PM
I am using Photoshop CS2 to create my dds files. There is an option to turn each individual channel, including the alpha, on and off so that they can be edited seperately. Nothing out of the ordinary shows up when I view the channels one by one or as a whole which is what is confusing me. Perhaps I will have to give GIMP a try next time.
Am I alright to use your fixed version in my file? With credit, of course.

My deviantART, MTS Yearbook Origin ID = Alistu
Lab Assistant
#25 Old 8th Oct 2014 at 1:36 PM
Quote: Originally posted by Menaceman44
Am I alright to use your fixed version in my file? With credit, of course.


Yeah no worries at all.

I don't know enough about photoshop to advise on the rest,
Page 1 of 2
Back to top