I have two friends who I talk to regularly. I associate with them on a weekly basis more or less. One of them believes in God though he is not "devoted" as one would say and the other is an atheist. Both of them know clearly that I am a Christian, and they don't discriminate against me (or at least as I know it).
Many times with them, they'd speak of unrighteous things, basically secular conversations, in which I, of course, don't feel comfortable talking about. One time when we were all together, they were having a conversation and I was quiet, as I usually am. They were speaking of basically unproductive things or something sinful. One of them asked me why I was being quiet. I'm an individual who likes to speak about intellectual topics and not someone who likes to say things that are "empty," although it does happen to me from time to time because of social influences. I hope to become more aware in my speech.
Anyway, many times they'd speak about perverted topics and I sometimes wonder why I hang out with them. The individual who's an atheist was more uncaring last year concerning things like school and doing good deeds. I'm glad that I'm being a positive influence, although I take heed to the verse I Corinthians 15:33. For the most part, these two guys are good people, being friendly and nice. Not only with them, others in the school when I try to have casual conversations, but many will also use profane language or state something explicit. How can I avoid such conversations and let my friends know that I don't like taking part in their unproductive conversations without seeming rude or judgmental?
"He who has knowledge spares his words, and a man of understanding is of a calm spirit. Even a fool is counted wise when he holds his peace; when he shuts his lips, he is considered perceptive" (Proverbs 17:27-28).
There is nothing wrong with not joining in a conversation. Too often people want to state their views without taking time to hear what other people have to say.
But you are asking what to do when the conversation is basically lame or silly. When asked why you are not joining in, there is nothing wrong with saying, "I don't have anything worthwhile to contribute to this topic." It may give them a hint that the topic of conversation needs to change. "The words of a wise man's mouth are gracious, but the lips of a fool shall swallow him up; the words of his mouth begin with foolishness, and the end of his talk is raving madness" (Ecclesiastes 10:12-13).
When conversations get profane, you can politely ask people to not swear, but I've found over the years that almost no one listens to the request. The best you can do is leave as soon as you can.
When conversations turn crude, you can sometimes get people to think by asking questions as if you took what they said as literal. You can also mention the hazards of immoral behavior. Most crude topics are discussed because people think the shock is funny. Sometimes having immoral behavior discussed seriously makes people uncomfortable enough that they find other things to talk about.